146 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			146 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
| <script>
 | |
| import {mapState} from "vuex"
 | |
| import AiSelect from "dui/packages/basic/AiSelect.vue";
 | |
| import AiDialog from "dui/packages/basic/AiDialog.vue";
 | |
| 
 | |
| const columns = [
 | |
|   {label: "序号", type: "index"},
 | |
|   {label: "数据来源", prop: "source", dict: "source"},
 | |
|   {label: "重量", prop: "weight"},
 | |
|   {label: "称重时间", prop: "createTime"},
 | |
|   {label: "是否变更过", prop: "isUpdate", dict: "yesOrNo"},
 | |
| ]
 | |
| export default {
 | |
|   name: "weightAdd",
 | |
|   components: {AiDialog, AiSelect},
 | |
|   props: {
 | |
|     instance: Function,
 | |
|     permissions: Function,
 | |
|     dict: Object
 | |
|   },
 | |
|   data() {
 | |
|     return {
 | |
|       detail: {detailList: []},
 | |
|       columns,
 | |
|       dialog: false,
 | |
|       form: {}
 | |
|     }
 | |
|   },
 | |
|   computed: {
 | |
|     ...mapState(["user"]),
 | |
|     userinfo: v => v.user.info || {},
 | |
|     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() {
 | |
|       const {id} = this.$route.query
 | |
|       return id && this.instance.post("/api/breed/weight/getInfo", null, {params: {biochipEarNumber: id}}).then(res => {
 | |
|         if (res?.data) {
 | |
|           const detail = res.data
 | |
|           detail.detailList = detail.weightList || []
 | |
|           return this.detail = {...detail}
 | |
|         }
 | |
|       })
 | |
|     },
 | |
|     handleDelete(id) {
 | |
|       this.$confirm("确定删除该条数据?").then(() => {
 | |
|         this.instance.post("/api/breed/weight/del", null, {
 | |
|           params: {id}
 | |
|         }).then(res => {
 | |
|           if (res?.code == 0) {
 | |
|             this.getDetail()
 | |
|           }
 | |
|         })
 | |
|       })
 | |
|     },
 | |
|     submit() {
 | |
|       this.$refs.detail.validate().then(() => {
 | |
|         this.form.biochipEarNumber = this.detail.biochipEarNumber
 | |
|         this.instance.post("/api/breed/weight/addOrEdit", this.form).then(res => {
 | |
|           if (res?.code == 0) {
 | |
|             this.dialog = false
 | |
|             this.getDetail()
 | |
|           }
 | |
|         })
 | |
|       })
 | |
|     }
 | |
|   },
 | |
|   created() {
 | |
|     this.dict.load("yesOrNo", "category", "variety", "source")
 | |
|     this.getDetail()
 | |
|   }
 | |
| }
 | |
| </script>
 | |
| 
 | |
| <template>
 | |
|   <ai-page :title="pageTitle" class="weightAdd" showBack content-string="blank">
 | |
|     <el-form size="small" label-width="120px">
 | |
|       <ai-card title="基础信息">
 | |
|         <div class="grid c-4">
 | |
|           <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="penId">
 | |
|             <b v-text="detail.category"/>
 | |
|           </el-form-item>
 | |
|           <el-form-item label="品种" prop="penId">
 | |
|             <b v-text="detail.variety"/>
 | |
|           </el-form-item>
 | |
|           <el-form-item label="最近称重时间">
 | |
|             <b v-text="detail.lastCreateTime"/>
 | |
|           </el-form-item>
 | |
|           <el-form-item label="最新体重(公斤)">
 | |
|             <b v-text="detail.todayWeight||detail.lastWeight"/>
 | |
|           </el-form-item>
 | |
|         </div>
 | |
|       </ai-card>
 | |
|       <ai-card title="体重录入">
 | |
|         <el-button type="text" slot="right" @click="dialog=true">新增</el-button>
 | |
|         <ai-table :tableData="detail.detailList" :colConfigs="columns" :isShowPagination="!1">
 | |
|           <el-table-column slot="options" label="操作" fixed="right" align="center">
 | |
|             <template slot-scope="{row,$index}">
 | |
|               <div class="table-options">
 | |
|                 <el-button type="text" @click="dialog=true,form=row">编辑</el-button>
 | |
|                 <el-button type="text" class="deleteBtn" @click="handleDelete(row.id)">删除</el-button>
 | |
|               </div>
 | |
|             </template>
 | |
|           </el-table-column>
 | |
|         </ai-table>
 | |
|       </ai-card>
 | |
|       <ai-dialog v-model="dialog" title="体重录入" @closed="form={}" @confirm="submit">
 | |
|         <el-form size="small" label-width="120px" :model="form" ref="detail" class="grid">
 | |
|           <el-form-item label="办理时间" prop="createTime" :rules="[{required:true,message:'请选择办理时间'}]">
 | |
|             <el-date-picker v-model="form.createTime" :readonly="form.id"/>
 | |
|           </el-form-item>
 | |
|           <el-form-item label="体重(公斤)" prop="weight" :rules="[{required:true,message:'请输入体重(公斤)'}]">
 | |
|             <el-input v-model.number="form.weight" clearable placeholder="请输入"/>
 | |
|           </el-form-item>
 | |
|         </el-form>
 | |
|       </ai-dialog>
 | |
|     </el-form>
 | |
|     <div slot="footer">
 | |
|       <el-button @click="back">返回</el-button>
 | |
|     </div>
 | |
|   </ai-page>
 | |
| </template>
 | |
| 
 | |
| <style scoped lang="scss">
 | |
| .weightAdd {
 | |
| }
 | |
| </style>
 |