- 在 AppDeathManage 和 AppOutManage 的 add.vue 文件中,为 ai-eartag-remote 组件添加 class="row",优化布局 - 在 AppOutManage 的 add.vue 文件中,修正出栏接口参数 outTime 之前错误使用 deathTime - 在 AiEartagRemote 组件中,简化 API 请求参数结构
168 lines
6.5 KiB
Vue
168 lines
6.5 KiB
Vue
<script>
|
|
import {mapState} from "vuex"
|
|
import AiEartagRemote from "@project/xumu/components/AiEartagRemote.vue";
|
|
|
|
const formImages = [
|
|
{label: "身长测量照片", prop: "heightPic",},
|
|
{label: "生物芯片照片", prop: "biochipPic",},
|
|
{label: "防疫耳标照片", prop: "preventionPic",},
|
|
{label: "其他说明照片", prop: "otherPic",},
|
|
]
|
|
export default {
|
|
name: "deathAdd",
|
|
components: {AiEartagRemote},
|
|
props: {
|
|
instance: Function,
|
|
permissions: Function,
|
|
dict: Object
|
|
},
|
|
data() {
|
|
return {
|
|
formImages,
|
|
detail: {},
|
|
form: {}
|
|
}
|
|
},
|
|
computed: {
|
|
...mapState(["user"]),
|
|
userinfo: v => v.user.info || {},
|
|
isAdd: v => !v.$route.query.id,
|
|
isEdit: v => v.$route.query.edit == 1,
|
|
isAuthing: v => v.detail.auditStatus == 1,
|
|
pageTitle: v => {
|
|
const appName = v.$parent.menuName || v.$parent.$options.label
|
|
return v.$route.query.id ? v.isEdit ? `编辑${appName}` : `${appName}详情` : `新增${appName}`
|
|
},
|
|
},
|
|
methods: {
|
|
back(params = {}) {
|
|
this.$router.push(params)
|
|
},
|
|
getDetail(id) {
|
|
return id && this.instance.post("/api/breed/death/page", {biochipEarNumber: id}).then(res => {
|
|
if (res?.data?.records) {
|
|
const detail = res.data.records[0] || {}
|
|
if (detail.picture) {
|
|
Object.entries(JSON.parse(detail.picture)).forEach(([key, value]) => {
|
|
detail[key] = value
|
|
})
|
|
}
|
|
return this.detail = {...detail}
|
|
}
|
|
})
|
|
},
|
|
submit() {
|
|
this.$refs.detail.validate().then(() => {
|
|
const {biochipEarNumber, id, deathTime, heightPic, biochipPic, preventionPic, otherPic, reason, remarks} = this.detail
|
|
this.instance.post("/api/breed/death/addOrEdit", {
|
|
biochipEarNumber, id, deathTime, picture: JSON.stringify({heightPic, biochipPic, preventionPic, otherPic}), reason, remarks
|
|
}).then(res => {
|
|
if (res?.code == 0 && res?.data != 1) {
|
|
this.$confirm("是否返回列表页?", "提交成功").then(() => this.back()).catch(() => this.getDetail(biochipEarNumber))
|
|
}
|
|
})
|
|
})
|
|
},
|
|
handleAudit() {
|
|
this.$refs.form.validate().then(() => {
|
|
const {id} = this.detail
|
|
this.instance.post("/api/breed/death/audit", null, {params: {id, ...this.form}}).then(res => {
|
|
if (res?.code == 0) {
|
|
this.$message.success("操作成功")
|
|
this.back()
|
|
}
|
|
})
|
|
})
|
|
},
|
|
handlerAutocomplete(value) {
|
|
'biochipEarNumber|farmId|houseId|penId|electronicEarNumber|originalEarNumber|category|variety'.split("|").forEach(prop => this.$set(this.detail, prop, value[prop]))
|
|
},
|
|
},
|
|
created() {
|
|
this.getDetail(this.$route.query.id)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<ai-page :title="pageTitle" class="deathAdd" showBack content-string="blank">
|
|
<el-form size="small" label-width="120px" :model="detail" ref="detail">
|
|
<ai-card title="基础信息">
|
|
<div class="grid c-4">
|
|
<ai-eartag-remote :instance="instance" @enter="handlerAutocomplete" class="row"/>
|
|
<el-form-item label="生物芯片耳标号">
|
|
<b v-text="detail.biochipEarNumber"/>
|
|
</el-form-item>
|
|
<el-form-item label="养殖场" prop="farmId">
|
|
<b v-text="detail.farmName"/>
|
|
</el-form-item>
|
|
<el-form-item label="养殖舍" prop="houseId">
|
|
<b v-text="detail.houseName"/>
|
|
</el-form-item>
|
|
<el-form-item label="养殖栏" prop="penId">
|
|
<b v-text="detail.penName"/>
|
|
</el-form-item>
|
|
<el-form-item label="电子耳标号" prop="electronicEarNumber">
|
|
<b v-text="detail.electronicEarNumber"/>
|
|
</el-form-item>
|
|
<el-form-item label="原厂耳标号" prop="originalEarNumber">
|
|
<b v-text="detail.originalEarNumber"/>
|
|
</el-form-item>
|
|
<el-form-item label="类别" prop="category">
|
|
<b v-text="detail.category"/>
|
|
</el-form-item>
|
|
<el-form-item label="品种" prop="variety">
|
|
<b v-text="detail.variety"/>
|
|
</el-form-item>
|
|
</div>
|
|
</ai-card>
|
|
<ai-card title="上传照片">
|
|
<div class="grid c-4">
|
|
<el-form-item v-for="(img,i) in formImages" :key="i" v-bind="img">
|
|
<ai-uploader v-if="isAdd||isEdit" v-model="detail[img.prop]" :instance="instance" :limit="1" value-is-url/>
|
|
<el-image :src="detail[img.prop]" :preview-src-list="[detail[img.prop]]" v-else/>
|
|
</el-form-item>
|
|
</div>
|
|
</ai-card>
|
|
<ai-card title="死亡录入">
|
|
<div class="grid">
|
|
<el-form-item label="死亡日期" prop="deathTime" :rules="[{required:isAdd||isEdit,message:'请选择死亡日期'}]">
|
|
<el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-if="isAdd||isEdit" v-model="detail.deathTime"/>
|
|
<b v-else v-text="detail.deathTime"/>
|
|
</el-form-item>
|
|
<el-form-item label="死亡原因" prop="reason" :rules="[{required:isAdd||isEdit,message:'请选择死亡原因'}]">
|
|
<ai-select v-if="isAdd||isEdit" v-model="detail.reason" dict="deathReason"/>
|
|
<b v-else v-text="dict.getLabel('deathReason',detail.reason)"/>
|
|
</el-form-item>
|
|
<el-form-item label="备注" prop="remark" class="row">
|
|
<ai-input type="textarea" :row="3" v-model="detail.remark" :edit="isAdd||isEdit"/>
|
|
</el-form-item>
|
|
</div>
|
|
</ai-card>
|
|
<ai-card title="审批信息" v-if="isAuthing">
|
|
<el-form :model="form" size="small" ref="form" label-width="120px">
|
|
<el-form-item label="是否同意" prop="auditStatus" :rules="[{required:true,message:'请选择是否同意'}]">
|
|
<ai-select v-model="form.auditStatus" :select-list="[{dictValue: 2, dictName: '同意'}, {dictValue: 3, dictName: '不同意'}]"/>
|
|
</el-form-item>
|
|
<el-form-item label="审批意见" prop="auditReason">
|
|
<el-input type="textarea" :row="3" v-model="form.auditReason" clearable placeholder="请输入"/>
|
|
</el-form-item>
|
|
</el-form>
|
|
</ai-card>
|
|
</el-form>
|
|
<div slot="footer">
|
|
<el-button type="primary" @click="submit" v-if="isAdd||isEdit">提交</el-button>
|
|
<el-button type="primary" @click="handleAudit" v-if="isAuthing">提交</el-button>
|
|
<el-button @click="back">返回</el-button>
|
|
</div>
|
|
</ai-page>
|
|
</template>
|
|
|
|
<style scoped lang="scss">
|
|
.deathAdd {
|
|
.el-date-editor {
|
|
width: 100%;
|
|
}
|
|
}
|
|
</style>
|