feat(xumu): 新增死亡登记功能
- 添加死亡登记列表页面和新增/编辑页面 - 实现死亡登记数据的查询、新增、编辑和删除功能 -集成审批流,支持再次提交审批 - 优化搜索功能,支持多条件筛选
This commit is contained in:
		
							
								
								
									
										35
									
								
								project/xumu/AppDeathManage/AppDeathManage.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								project/xumu/AppDeathManage/AppDeathManage.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | |||||||
|  | <script> | ||||||
|  | import add from "./add.vue"; | ||||||
|  | import list from "./list.vue"; | ||||||
|  |  | ||||||
|  | export default { | ||||||
|  |   name: "AppDeathManage", | ||||||
|  |   label: "死亡登记", | ||||||
|  |   props: { | ||||||
|  |     instance: Function, | ||||||
|  |     dict: Object, | ||||||
|  |     permissions: Function | ||||||
|  |   }, | ||||||
|  |   computed: { | ||||||
|  |     currentPage() { | ||||||
|  |       let {hash} = this.$route | ||||||
|  |       return hash == "#add" ? add : list | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return {} | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  | <template> | ||||||
|  |   <section class="AppDeathManage"> | ||||||
|  |     <component :is="currentPage" v-bind="$props"/> | ||||||
|  |   </section> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <style scoped lang="scss"> | ||||||
|  | .AppDeathManage { | ||||||
|  |   height: 100%; | ||||||
|  | } | ||||||
|  | </style> | ||||||
							
								
								
									
										163
									
								
								project/xumu/AppDeathManage/add.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										163
									
								
								project/xumu/AppDeathManage/add.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,163 @@ | |||||||
|  | <script> | ||||||
|  | import {mapState} from "vuex" | ||||||
|  |  | ||||||
|  | const formImages = [ | ||||||
|  |   {label: "身长测量照片", prop: "heightPic", rules: {required: true, message: '请上传 身长测量照片'}}, | ||||||
|  |   {label: "生物芯片照片", prop: "biochipPic", rules: {required: true, message: '请上传 生物芯片照片'}}, | ||||||
|  |   {label: "防疫耳标照片", prop: "preventionPic", rules: {required: true, message: '请上传 防疫耳标照片'}}, | ||||||
|  |   {label: "其他说明照片", prop: "otherPic", rules: {required: true, message: '请上传 其他说明照片'}}, | ||||||
|  | ] | ||||||
|  | export default { | ||||||
|  |   name: "deathAdd", | ||||||
|  |   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: {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() | ||||||
|  |           } | ||||||
|  |         }) | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   created() { | ||||||
|  |     this.dict.load("yesOrNo", "category", "variety", "deathReason") | ||||||
|  |     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-input class="row" v-model="detail.biochipEarNumber" placeholder="请输入耳标号按回车查询,或扫描耳标号" @input="getDetail"/> | ||||||
|  |           <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="category"> | ||||||
|  |             <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="createTime" :rules="[{required:true,message:'请选择死亡日期'}]"> | ||||||
|  |             <el-date-picker v-if="isAdd||isEdit" v-model="detail.createTime"/> | ||||||
|  |             <b v-text="detail.createTime"/> | ||||||
|  |           </el-form-item> | ||||||
|  |           <el-form-item label="死亡原因" prop="reason" :rules="[{required:true,message:'请选择死亡原因'}]"> | ||||||
|  |             <ai-select v-if="isAdd||isEdit" v-model="detail.reason" dict="deathReason"/> | ||||||
|  |             <b v-text="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> | ||||||
							
								
								
									
										143
									
								
								project/xumu/AppDeathManage/list.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										143
									
								
								project/xumu/AppDeathManage/list.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,143 @@ | |||||||
|  | <script> | ||||||
|  | import {mapState} from "vuex" | ||||||
|  |  | ||||||
|  | const columns = [ | ||||||
|  |   {label: "序号", type: "index"}, | ||||||
|  |   {label: "养殖场", prop: "userName", format: (v, row) => `${[row.farmName, row.houseName, row.penName].join("-")}`}, | ||||||
|  |   {label: "生物芯片耳标号", prop: "biochipEarNumber"}, | ||||||
|  |   {label: "类别", prop: "category", dict: "category", width: 120}, | ||||||
|  |   {label: "品种", prop: "variety", dict: "variety", width: 120}, | ||||||
|  |   {label: "日龄(天)", prop: "age", width: 80}, | ||||||
|  |   {label: "死亡时间", prop: "deathTime"}, | ||||||
|  |   {label: "死亡原因", prop: "reason", dict: "deathReason", width: 80}, | ||||||
|  |   {label: "登记时间", prop: "createTime"}, | ||||||
|  |   {label: "操作人", prop: "userName", width: 100}, | ||||||
|  |   {label: "审核状态", prop: "auditStatus", dict: "auditStatus", width: 80}, | ||||||
|  | ] | ||||||
|  | export default { | ||||||
|  |   name: "deathList", | ||||||
|  |   props: { | ||||||
|  |     instance: Function, | ||||||
|  |     dict: Object, | ||||||
|  |     permissions: Function | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       columns, | ||||||
|  |       tableData: [], | ||||||
|  |       page: {pageNum: 1, pageSize: 10, total: 0}, | ||||||
|  |       search: {}, | ||||||
|  |       dialog: false, | ||||||
|  |       form: {} | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   computed: { | ||||||
|  |     ...mapState(['user']), | ||||||
|  |     userinfo: v => v.user.info || {}, | ||||||
|  |     pageTitle: v => v.$parent.menuName || v.$parent.$options.label | ||||||
|  |   }, | ||||||
|  |   watch: { | ||||||
|  |     search: { | ||||||
|  |       deep: true, | ||||||
|  |       handler() { | ||||||
|  |         this.page.pageNum = 1 | ||||||
|  |         this.getTableData() | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     getTableData() { | ||||||
|  |       this.instance.post("/api/breed/death/page", {...this.page, ...this.search}).then(res => { | ||||||
|  |         if (res?.data) { | ||||||
|  |           this.tableData = res.data?.records | ||||||
|  |           this.page.total = res.data.total | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     handleDelete(id) { | ||||||
|  |       this.$confirm("确定删除该条数据?").then(() => { | ||||||
|  |         this.instance.post("/api/breed/weight/del", null, { | ||||||
|  |           params: {id} | ||||||
|  |         }).then(res => { | ||||||
|  |           if (res?.code == 0) { | ||||||
|  |             this.getTableData() | ||||||
|  |           } | ||||||
|  |         }) | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     handleAuditAgain(id) { | ||||||
|  |       this.$confirm("是否要再次提交审批?").then(() => { | ||||||
|  |         this.instance.post("/api/breed/death/audit", null, { | ||||||
|  |           params: {id, auditStatus: 1} | ||||||
|  |         }).then(res => { | ||||||
|  |           if (res?.code == '0') { | ||||||
|  |             this.$message.success("提交成功") | ||||||
|  |             this.getTableData() | ||||||
|  |           } | ||||||
|  |         }) | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   created() { | ||||||
|  |     this.dict.load("auditStatus", "category", "variety") | ||||||
|  |     this.getTableData() | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  | <template> | ||||||
|  |   <ai-page class="deathList" :title="pageTitle"> | ||||||
|  |     <ai-search-bar> | ||||||
|  |       <template #left> | ||||||
|  |         <ai-select placeholder="全部养殖场" v-model="search.farmId" :instance="instance" :action="`/api/siteUser/querySiteByUserId?userId=${userinfo.id}`" :prop="{label:'name'}"/> | ||||||
|  |         <ai-select placeholder="全部养殖舍" v-model="search.houseId" :instance="instance" :action="`/api/siteUser/querySiteById?id=${search.farmId||-1}`" :prop="{label:'name'}"/> | ||||||
|  |         <ai-select placeholder="全部养殖栏" v-model="search.penId" :instance="instance" :action="`/api/siteUser/querySiteById?id=${search.houseId||-1}`" :prop="{label:'name'}"/> | ||||||
|  |         <ai-select placeholder="全部审核状态" v-model="search.auditStatus" dict="auditStatus"/> | ||||||
|  |         <ai-search label="死亡日期"> | ||||||
|  |           <el-date-picker v-model="search.deathBeginDate" type="datetime" placeholder="开始日期" size="small"/> | ||||||
|  |           <el-date-picker v-model="search.deathEndDate" type="datetime" placeholder="结束日期" size="small"/> | ||||||
|  |         </ai-search> | ||||||
|  |         <ai-search label="登记日期"> | ||||||
|  |           <el-date-picker v-model="search.beginDate" type="datetime" placeholder="开始日期" size="small"/> | ||||||
|  |           <el-date-picker v-model="search.endDate" type="datetime" placeholder="结束日期" size="small"/> | ||||||
|  |         </ai-search> | ||||||
|  |         <ai-input placeholder="原场耳标号" v-model="search.originalEarNumber"/> | ||||||
|  |         <ai-input placeholder="生物芯片耳标号" v-model="search.biochipEarNumber"/> | ||||||
|  |         <ai-input placeholder="电子耳标号" v-model="search.electronicEarNumber"/> | ||||||
|  |       </template> | ||||||
|  |     </ai-search-bar> | ||||||
|  |     <ai-search-bar> | ||||||
|  |       <template #left> | ||||||
|  |         <el-button type="primary" icon="iconfont iconAdd" @click="$router.push({hash:'#add'})">新增</el-button> | ||||||
|  |         <ai-download :instance="instance" url="/api/breed/death/export" :params="{...search,...page}" :fileName="`死亡导出表-${Date.now()}`"/> | ||||||
|  |       </template> | ||||||
|  |     </ai-search-bar> | ||||||
|  |     <ai-table :tableData="tableData" :colConfigs="columns" :dict="dict" @getList="getTableData" | ||||||
|  |               :total="page.total" :current.sync="page.pageNum" :size.sync="page.pageSize"> | ||||||
|  |       <el-table-column slot="options" label="操作" fixed="right" align="center"> | ||||||
|  |         <template slot-scope="{row}"> | ||||||
|  |           <div class="table-options"> | ||||||
|  |  | ||||||
|  |             <el-button v-if="row.auditStatus==1" type="text" @click="$router.push({hash:'#add',query:{id:row.biochipEarNumber}})">查看</el-button> | ||||||
|  |             <template v-else> | ||||||
|  |               <el-button v-if="row.auditStatus==2" type="text" @click="$router.push({hash:'#add',query:{id:row.biochipEarNumber}})">查看</el-button> | ||||||
|  |               <el-button v-if="row.auditStatus==2" type="text" @click="$router.push({hash:'#add',query:{id:row.biochipEarNumber,edit:1}})">编辑</el-button> | ||||||
|  |               <el-button v-if="row.auditStatus==3" type="text" @click="handleAuditAgain(row.id)">再次提交</el-button> | ||||||
|  |               <el-button type="text" @click="handleDelete(row.id)">删除</el-button> | ||||||
|  |             </template> | ||||||
|  |           </div> | ||||||
|  |         </template> | ||||||
|  |       </el-table-column> | ||||||
|  |     </ai-table> | ||||||
|  |   </ai-page> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <style scoped lang="scss"> | ||||||
|  | .deathList { | ||||||
|  |   height: 100%; | ||||||
|  |  | ||||||
|  |   .deleteBtn { | ||||||
|  |     color: $errorColor; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </style> | ||||||
		Reference in New Issue
	
	Block a user