主表

<template><div class="mod-useinfo"><el-form:inline="true":model="searchForm"@keyup.enter.native="getDataList()"><el-form-item><el-inputv-model="searchForm.farmerId"placeholder="户主编号"clearable></el-input></el-form-item><!-- <el-form-item><el-inputv-model="searchForm.year"placeholder="年份"clearable></el-input></el-form-item> --><el-form-item><!-- <el-inputv-model="dataForm.dateyear":disabled="disabled"placeholder="年份"></el-input> --><el-date-pickertype="year"placeholder="选择年份"v-model="searchForm.year"style="width: 100%"format="yyyy"value-format="yyyy":disabled="disabled"></el-date-picker></el-form-item><el-form-item><el-inputv-model="searchForm.taskId"placeholder="任务id"clearable></el-input></el-form-item><el-form-item><el-button @click="getDataList()">查询</el-button><el-buttonv-if="isAuth('pesticide:useinfo:save')"type="primary"@click="addOrUpdateHandle()">新增</el-button><el-buttonv-if="isAuth('pesticide:useinfo:delete')"type="danger"@click="deleteHandle()":disabled="dataListSelections.length <= 0">批量删除</el-button></el-form-item></el-form><el-table:data="dataList"border@selection-change="selectionChangeHandle"style="width: 100%"><el-table-columntype="selection"header-align="center"align="center"width="50"></el-table-column><el-table-columnprop="taskId"header-align="center"align="center"label="户主编号"></el-table-column><el-table-columnprop="dateyear"header-align="center"align="center"label="年份"></el-table-column><el-table-columnprop="taskId"header-align="center"align="center"label="任务id"></el-table-column><el-table-columnfixed="right"header-align="center"align="center"width="150"label="操作"><template slot-scope="scope"><el-buttonv-if="isAuth('pesticide:useinfo:info')"type="text"size="small"@click="showDetails(scope.row.id)">查看</el-button><el-buttonv-if="isAuth('pesticide:useinfo:update')"type="text"size="small"@click="addOrUpdateHandle(scope.row.id)">修改</el-button><el-buttonv-if="isAuth('pesticide:useinfo:delete')"type="text"size="small"@click="deleteHandle(scope.row.id)">删除</el-button></template></el-table-column></el-table><el-pagination@size-change="sizeChangeHandle"@current-change="currentChangeHandle":current-page="pageIndex":page-sizes="[10, 20, 50, 100]":page-size="pageSize":total="totalPage"layout="total, sizes, prev, pager, next, jumper"></el-pagination><!-- 弹窗, 新增 / 修改 --><add-or-updatev-if="addOrUpdateVisible"ref="addOrUpdate"@refreshDataList="getDataList"></add-or-update></div>
</template><script>
import AddOrUpdate from './useinfo-add-or-update'export default {data () {return {searchForm: {taskId: '',farmerId: '',year: ''},dataList: [],pageIndex: 1,pageSize: 10,totalPage: 0,dataListSelections: [],addOrUpdateVisible: false}},components: {AddOrUpdate},activated () {this.getDataList()},methods: {// 获取数据列表getDataList () {this.$http({url: '/pesticide/useinfo/list',method: 'get',params: {'page': this.pageIndex,'limit': this.pageSize,'taskId': this.searchForm.taskId,'farmerId': this.searchForm.farmerId,'year': this.searchForm.year}}).then(({ data }) => {if (data && data.code === 0) {this.dataList = data.page.recordsthis.totalPage = data.page.total} else {this.dataList = []this.totalPage = 0}})},// 每页数sizeChangeHandle (val) {this.pageSize = valthis.pageIndex = 1this.getDataList()},// 当前页currentChangeHandle (val) {this.pageIndex = valthis.getDataList()},// 多选selectionChangeHandle (val) {this.dataListSelections = val},// 查看详情showDetails (id) {this.$router.push({name: 'backUseinfo',params: {id: id,disable: true}})// this.addOrUpdateVisible = true// this.$nextTick(() => {//   this.$refs.addOrUpdate.init(id, true)// })},// 新增 / 修改addOrUpdateHandle (id) {this.$router.push({name: 'backUseinfo',params: {id: id,disable: false}})// this.addOrUpdateVisible = true// this.$nextTick(() => {//   this.$refs.addOrUpdate.init(id)// })},// 删除deleteHandle (id) {let ids = id ? [id] : this.dataListSelections.map(item => {return item.id})this.$confirm('确定对所选项进行[删除]操作?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {this.$http({url: '/pesticide/useinfo/delete',method: 'post',data: ids}).then(({ data }) => {if (data && data.code === 0) {this.$message({message: '操作成功',type: 'success',duration: 1500})this.getDataList()}})}).catch(() => {})}}
}
</script>

子表

<template><div style="margin-top: 20px"><!-- <h2 align="center">农药购买与使用去向记载表</h2> --><!-- <el-dialog:title="!dataForm.id ? '新增' : !disabled ? '修改' : '查看'":close-on-click-modal="false":visible.sync="visible"> --><div><!-- <div style="margin-bottom: 20px"><el-buttontype="white"@click="$router.push({name: 'pesticide-useinfo',})">返回</el-button><el-buttonv-if="!disabled"type="primary"@click="dataFormSubmit()">保存</el-button><el-button@click="addOneLine()"style="right: 75px; position: absolute; margin-top: 20px"type="primary":disabled="isnewone">新增记录</el-button><el-button@click="deleteHandle()"style="right: 200px; position: absolute; margin-top: 20px"type="danger":disabled="dataListSelections.length <= 0">批量删除</el-button><el-buttonv-if="!disabled"type="primary"@click="dataFormSubmit()">新增</el-button> --><!-- </div> --><!-- :rules="dataRule" --><el-form:model="dataForm":rules="dataRule"ref="dataForm"@keyup.enter.native="dataFormSubmit()"label-width="80px":inline="true"><div style="margin-bottom: 20px"><el-buttontype="white"@click="$router.push({name: 'pesticide-useinfo',})">返回</el-button><el-buttonv-if="!disabled"type="primary"@click="dataFormSubmit()">保存</el-button><el-button@click="addOneLine()"style="right: 75px; position: absolute; margin-top: 20px"type="primary":disabled="isnewone">新增记录</el-button><el-button@click="deleteHandle()"style="right: 200px; position: absolute; margin-top: 20px"type="danger":disabled="dataListSelections.length <= 0">批量删除</el-button><!--            <el-buttonv-if="!disabled"type="primary"@click="dataFormSubmit()">新增</el-button> --></div><div><el-form-item label="户主编号" prop="farmerId"><el-inputv-model="dataForm.farmerId":disabled="disabled"placeholder="户主编号"onkeyup="this.value = this.value.replace(/[^\d.]/g,'');":maxlength="15"></el-input></el-form-item><el-form-item label="年份" prop="dateyear"><!-- <el-inputv-model="dataForm.dateyear":disabled="disabled"placeholder="年份"></el-input> --><el-date-pickertype="year"placeholder="选择年份"v-model="dataForm.dateyear"style="width: 100%"format="yyyy"value-format="yyyy":disabled="disabled"></el-date-picker></el-form-item><el-form-item label="任务id" prop="taskId"><el-inputonkeyup="this.value = this.value.replace(/[\u4E00-\u9FA5]/g,'');"v-model="dataForm.taskId":disabled="disabled"placeholder="任务id":maxlength="15"></el-input></el-form-item></div></el-form><!-- <el-form:model="dataForm"ref="dataForm"@keyup.enter.native="dataFormSubmit()"label-width="80px"> --><!-- <el-input v-model="dataForm.farmerId"></el-input> --><!-- <el-form-itemlabel="户主编号"style="float: left; white-space: nowrap"prop="farmerId"><el-inputv-model="dataForm.farmerId":disabled="disabled"placeholder="户主编号"style="width: 250px"></el-input></el-form-item> --><!-- <el-form-itemlabel="年份"prop="dateyear":rules="[{ required: true, message: '请选择年份', trigger: 'blur' }]"style="width: 350px; float: left; white-space: nowrap"><el-date-pickertype="year"placeholder="选择年份"v-model="dataForm.dateyear"style="width: 100%"format="yyyy"value-format="yyyy":disabled="disabled"></el-date-picker></el-form-item><el-form-itemlabel="任务id"style="float: left; white-space: nowrap"prop="taskId"><el-inputv-model="dataForm.taskId":disabled="disabled"placeholder="任务id"style="width: 250px"></el-input></el-form-item> --><!-- </el-form> --><el-table:data="dataForm.details"@selection-change="selectionChangeHandle":default-sort="{ prop: 'date', order: 'descending' }"><el-table-column type="selection" width="55"> </el-table-column><el-table-columnprop="id"align="center"label="农药购买记录"width="150"><el-table-column align="center" type="index" width="50"></el-table-column><el-table-columnprop="purchaseDate"align="center"label="日期"width="140"><template slot-scope="scope"><!-- <el-inputv-model="scope.row.sowingDate":disabled="disabled"placeholder=""></el-input> --><el-date-pickersize="small"type="datetime"placeholder="播种日期"v-model.trim="scope.row.purchaseDate"style="width: 100%":disabled="disabled"format="MM-dd"value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker></template></el-table-column><el-table-columnprop="pdNo"align="center"label="农药登记证号"filterablewidth="180"><template slot-scope="scope"><el-selectv-model="scope.row.pdNo"filterableremoteclearablereserve-keywordplaceholder="请输入农药登记证号":remote-method="remoteMethod":loading="remoteLoading"><el-optionv-for="item in remoteOptions":key="item.value":label="item.label":value="item.value"></el-option></el-select></template></el-table-column><el-table-columnprop="commonName"align="center"label="农药通用名"width="180"><template slot-scope="scope"><!-- <el-inputv-model.trim="scope.row.commonName":disabled="disabled":maxlength="15"placeholder="农药通用名"></el-input> --><el-selectv-model="scope.row.commonName"filterableremotereserve-keywordplaceholder="请输入农药通用名":remote-method="remoteMethodName":loading="nameLoading"><el-optionv-for="item in nameOptions":key="item.value":label="item.label":value="item.value"></el-option></el-select></template></el-table-column><el-table-columnprop="purchaseAmount"align="center"label="农药购买量(克、毫升)"width="180"><template slot-scope="scope"><el-input-numbersize="small":disabled="disabled"v-model.trim="scope.row.purchaseAmount":min="0":max="10000"label="农药购买量(克、毫升)"></el-input-number></template></el-table-column><el-table-columnprop="purchaseCost"align="center"label="购买费用"width="160"><template slot-scope="scope"><el-input-numbersize="small":disabled="disabled"v-model.trim="scope.row.purchaseCost":min="0":max="1000000"label="购买费用"></el-input-number></template></el-table-column><el-table-columnprop="packagings"align="center"label="包装物"width="180"><template slot-scope="scope"><el-inputv-model.trim="scope.row.packagings":disabled="disabled":maxlength="10"placeholder="包装物"></el-input></template></el-table-column><el-table-columnprop="packingSpecification"align="center"label="包装规格(克、毫升)/(瓶、袋)"width="180"><!-- <template slot-scope="scope"><el-inputv-model.trim="scope.row.packingSpecification":disabled="disabled":maxlength="10"placeholder="包装规格(克、毫升)/(瓶、袋)"></el-input></template> --><template slot-scope="scope"><el-input-numbersize="small":disabled="disabled"v-model.trim="scope.row.packingSpecification":min="0":max="10000"label="包装规格(克、毫升)/(瓶、袋)"></el-input-number></template></el-table-column></el-table-column><el-table-columnprop="name"align="center"label="农药使用去向记录"width="180"><el-table-columnprop="medicationDate"align="center"label="用药日期"width="180"><template slot-scope="scope"><!-- <el-inputv-model="scope.row.sowingDate":disabled="disabled"placeholder=""></el-input> --><el-date-pickertype="datetime"placeholder="播种日期"v-model.trim="scope.row.medicationDate"style="width: 100%":disabled="disabled"format="MM-dd"value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker></template></el-table-column><el-table-columnprop="cropId"align="center"label="用药作物名称"width="180"><template slot-scope="scope"><!-- <el-inputv-model.trim="scope.row.cropId":disabled="disabled":maxlength="10"placeholder="用药作物名称"></el-input> --><el-selectv-model.trim="scope.row.cropId":disabled="disabled":maxlength="10"clearableplaceholder="用药作物名称"><el-optionv-for="item in cropList":key="item.value":label="item.label":value="item.value"></el-option></el-select></template></el-table-column><el-table-columnprop="controlObject"label="防治对象名称(病虫草鼠种类)"width="180"align="center"><template slot-scope="scope"><el-inputv-model.trim="scope.row.controlObject":disabled="disabled":maxlength="10"placeholder="防治对象名称(病虫草鼠种类)"></el-input></template></el-table-column><el-table-columnprop="medicationArea"align="center"label="用药面积(亩)"width="200"><template slot-scope="scope"><!-- <el-inputv-model="scope.row.plantingArea":disabled="disabled"placeholder=""></el-input> --><el-input-number:disabled="disabled"v-model.trim="scope.row.medicationArea":min="0":max="10000000"label="种植面积(亩)"size="small"></el-input-number></template></el-table-column><el-table-columnprop=" totalDosage"align="center"label="合计用药量(克、毫升)"width="220"><!-- <template slot-scope="scope"><el-inputv-model.trim="scope.row.totalDosage":disabled="disabled":maxlength="10"placeholder="合计用药量(克、毫升)"></el-input></template> --><template slot-scope="scope"><el-input-numbersize="small":disabled="disabled"v-model.trim="scope.row.totalDosage":min="0":max="10000"label="合计用药量(克、毫升)"></el-input-number></template></el-table-column></el-table-column><!-- <el-table-columnheader-align="center"align="center"width="150"label="操作"><el-buttonv-if="isAuth('pesticide:useinfo:delete')"type="text"size="small"@click="deleteHandle()">删除</el-button></el-table-column> --></el-table><!-- <el-pagination@size-change="sizeChangeHandle"@current-change="currentChangeHandle":current-page="pageIndex":page-sizes="[10, 20, 50, 100]":page-size="pageSize":total="totalPage"layout="total, sizes, prev, pager, next, jumper"></el-pagination> --></div></div>
</template><script>
export default {data () {return {notifylist: [],notifylisttrans: {purchaseDate: '日期',pdNo: '农药登记证号',commonName: '农药通用名',purchaseAmount: '农药购买量(克,毫升)',purchaseCost: '购买费用',packagings: '包装物',packingSpecification: '包装规格(克、毫升)',medicationDate: ' 用药日期',cropId: '用药作物id',controlObject: '防治对象名称',medicationArea: '用药面积(亩)',totalDosage: '合计用药量(克、毫升)'},isnewone: false,cropList: [],restaurants: [],state: '',timeout: null,disabled: false,visible: false,dataForm: {id: 0,farmerId: '',dateyear: '',taskId: ''},detail: {id: '',purchaseDate: '',pdNo: '',commonName: '',purchaseAmount: '',purchaseCost: '',packagings: '',packingSpecification: '',medicationDate: '',cropId: '',controlObject: '',medicationArea: '',totalDosage: '',},list: [],dataListSelections: [],//跟多选有关的一个数组??remoteOptions: [], // 远程农户证号 for循环的返回数据的数组remoteLoading: false, // 是否正在从远程获取数据nameOptions: [],nameLoading: false,dataRule: {farmerId: [{ required: true, message: '农户编号不能为空', trigger: ['blur', 'change'] }],taskId: [{ required: true, message: '任务id不能为空', trigger: ['blur', 'change'] }],dateyear: [{ required: true, message: '年份不能为空', trigger: ['blur', 'change'] }],}}},watch: {'dataForm.details': {handler (newVal, oldVal) {// debugger// console.log(this.dataForm.details);let a = []newVal = newVal[newVal.length - 1]for (let key in this.dataForm.details[this.dataForm.details.length - 1]) {if (typeof newVal[key] === 'number') {if (newVal[key] == 0) {if (key != "id")a.push(key)}} else {if (newVal[key] == null || newVal[key] == "") {if (key != "id")a.push(key)}}}this.notifylist = a// if (a.length > 0) {//   this.isnewone = true//   // this.$notify({//   //   message: "aaa ",//   //   type: "warning"//   // })//   this.notifylist = a// } else {//   this.isnewone = false// }// if (this.isnewone != false) {//   this.isnewone = true// }// console.log(this.isnewone)// console.log(a)// if (1 == 1) {啊// }},deep: true}},mounted () {let id = this.$route.params.idlet disable = this.$route.params.disablethis.init(id, disable)// this.getAllPdNo()this.getAllCrop()// this.getPesIdData()},// created () {//   // 获取当前登录人的中支//   // this.formResult.branchComCode = this.$cookies.get('branchCom')//   // console.log(this.formResult.branchComCode)//   this.getPesIdData() // 获取管理机构列表// },activated () {// this.getDataList()},methods: {// 清空选择项// repeatList () {//   this.remoteOptions = this.remoteList.filter(item => {//     return item.label//   })// },// 选中农药证号时触发// handleSelectBranchCom (item) {//   console.log('远程搜索选中后返回的item:::::即value的值')//   console.log(item)//   this.detail.pdNo = item.split(',')[0]// this.details[i].pdNo = item.split(',')[0]//   },// },// 每页数sizeChangeHandle (val) {this.pageSize = valthis.pageIndex = 1this.getDataList()},// 当前页currentChangeHandle (val) {this.pageIndex = valthis.getDataList()},getDataList () {this.$http({url: '/pesticide/useinfo/list',method: 'get',params: {'page': this.pageIndex,'limit': this.pageSize,}}).then(({ data }) => {if (data && data.code === 0) {this.dataList = data.page.recordsthis.totalPage = data.page.total} else {this.dataList = []this.totalPage = 0}})},// selectionChangeHandle (selectedDetails) {// console.log(selectedDetails);//this调用selectedDetails,然后把它存到data中//   this.selectedDetails = selectedDetails// },addOneLine () {// let data = JSON.parse(JSON.stringify(this.dataForm))// let details = data.details// details.push(JSON.parse(JSON.stringify(this.detail)))// data.details = details// this.dataForm = dataif (this.notifylist.length > 0) {this.$notify({message: this.notifylisttrans[this.notifylist[0]] + "不能为空",type: 'warning'})return}let data = this.dataForm// data.details.push(JSON.parse(JSON.stringify(this.detail)))let details = this.dataForm.details// console.log(plants, 111);// debugger// for (let i = 0; i < details.length; i++) {//   //对表格内要填的值做一个是否为空的判断//   //如果表格中的每一行的参数有任意一个不为null或者“”//   if (details[i].pdNo != "" || details[i].commonName != "" || details[i].packagings != ""//     || details[i].cropId != "" || details[i].controlObject != "" || !(details[i].purchaseDate == null ||//       details[i].purchaseDate == "") || !(details[i].medicationDate == null || details[i].medicationDate == "") ||//     details[i].purchaseAmount != 0 || details[i].purchaseCost != 0 || details[i].packingSpecification != 0 || details[i].medicationArea != 0//     || details[i].totalDosage != 0) {//     //就判断这一行是否都有数据 如果都有数据 则放行//     if (details[i].pdNo != "" && details[i].commonName != "" && details[i].packagings != "" && details[i].cropId != "" && details[i].controlObject != "" && !(details[i].purchaseDate == null && details[i].purchaseDate == "") && !(details[i].medicationDate == null && details[i].medicationDate == "") && details[i].purchaseAmount != 0 && details[i].purchaseCost != 0 && details[i].packingSpecification != 0 && details[i].medicationArea != 0 && details[i].totalDosage != 0) {data.details.push(JSON.parse(JSON.stringify(this.detail)))//     } else {//       //如果不是 {都有} 数据,就提示用户哪一行没有数据,并终止方法的执行,目的是校验不通过 就不提交表单//       if (details[i].purchaseAmount == 0 || details[i].purchaseAmount == "" || details[i].purchaseAmount == null) {//         this.$notify({//           // title: `第${i + 1}行作物种类`,//           title: `第${i + 1}行的农药购买量(克,毫升)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].purchaseCost == 0 || details[i].purchaseCost == "" || details[i].purchaseCost == null) {//         this.$notify({//           // title: `第${i + 1}行作物种类`,//           title: `第${i + 1}行的购买费用(元)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].packingSpecification == 0 || details[i].packingSpecification == "" || details[i].packingSpecification == null) {//         this.$notify({//           // title: `第${i + 1}行作物种类`,//           title: `第${i + 1}行的包装规格(克、毫升)/(瓶、袋)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].medicationArea == 0 || details[i].medicationArea == "" || details[i].medicationArea == null) {//         this.$notify({//           // title: `第${i + 1}行作物种类`,//           title: `第${i + 1}行的用药面积(亩)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].totalDosage == 0 || details[i].totalDosage == "" || details[i].totalDosage == null) {//         this.$notify({//           // title: `第${i + 1}行作物种类`,//           title: `第${i + 1}行的合计用药量(克、毫升)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].pdNo == "" || details[i].pdNo == null) {//         this.$notify({//           title: `第${i + 1}行的农药登记证号未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].commonName == "" || details[i].commonName == null) {//         this.$notify({//           title: `第${i + 1}行的农药通用名未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].packagings == "" || details[i].packagings == null) {//         this.$notify({//           title: `第${i + 1}行的包装物未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       // if (details[i].cropId == "" || details[i].cropId == null) {//       //   this.$notify({//       //     title: `第${i + 1}行的用药作物id未填`,//       //     message: `请填写该数据`,//       //     type: 'warning',//       //     duration: 4500,//       //     offset: 200,//       //     dangerouslyUseHTMLString: true,//       //   })//       //   return//       // }//       if (details[i].controlObject == "" || details[i].controlObject == null) {//         this.$notify({//           title: `第${i + 1}行的防治对象名称(病虫草鼠种类)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//     }//   }// }},deleteHandle () {// if (rows) {//   rows.forEach((row) => {//     this.$refs.multipleTable.toggleRowSelection(row);//   });// } else {//   this.$refs.multipleTable.clearSelection();// }//首先获取到对象(要删除的对象)//在获取到整个table里面的数据//判断是否相等 是的话就删除let finalData = JSON.parse(JSON.stringify(this.dataForm.details));let delIds = [];this.dataListSelections.forEach((item) => {this.dataForm.details.forEach((tableDataItem, i) => {// console.log(item == tableDataItem);if (item == tableDataItem) {// delete finalData[i];delIds.push(i);}});});function sortNumber (a, b) {//升序return a - b;}delIds.sort(sortNumber);let delNum = 0;for (let i = 0; i < delIds.length; i++) {finalData.splice(delIds[i] - delNum, 1);delNum++;}// delIds.forEach((item) => {// i = i - 1;// });this.dataForm.details = finalData;},// getAllCrop () {//   this.dataForm = {}//   this.cropList = []//   let dictList = sessionStorage.getItem("dictList")//   dictList = JSON.parse(dictList)//   // console.log(dictList);//   this.dataForm.plants = []//   // console.log(this.cropList);//   console.log(this.dataForm);//   this.init(this.id, this.disable)// },// wodetest1hao () {//要动态地添加数据//我要干什么//为什么这么做// 1.// 2.// },init (id, disabled) {this.disabled = disabledthis.dataForm.id = id || ''this.visible = truethis.$nextTick(() => {this.$refs['dataForm'].resetFields()//判断是修改还是新增if (this.dataForm.id) {this.$http({url: `/pesticide/useinfo/info/${this.dataForm.id}`,method: 'get'}).then(({ data }) => {if (data && data.code === 0) {this.dataForm = data.useinfoconsole.log(this.dataForm, 5555555555555555);}})} else {//如果是新增就 插入一条空数据(dataForm.details [detail])//插入一条空数据怎么写呢//// this.dataForm = this.dataForm.details [this.detail]//  <template slot-scope="scope">//  {{(scope.row.id)}}// </template>// debuggerlet data = JSON.parse(JSON.stringify(this.dataForm))let details = []details.push(JSON.parse(JSON.stringify(this.detail)))data.details = detailsthis.dataForm = data// this.dataForm.details = []// this.dataForm.details.push(JSON.parse(JSON.stringify(this.detail)))// console.log(this.dataForm);}})},// 表单提交dataFormSubmit () {// this.$refs['dataForm']//   .validate((valid) => {// ``''for (let i = 0; i < this.dataForm.details.length; i++) {for (let key in this.dataForm.details[i]) {if (typeof this.dataForm.details[i][key] === 'number') {if (this.dataForm.details[i][key] == 0) {if (key != "id") {this.$notify({message: `第${i + 1}行` + this.notifylisttrans[key] + `未填`,type: "warning"})return}}} else {if (this.dataForm.details[i][key] == null || this.dataForm.details[i][key] == "") {if (key != "id") {this.$notify({message: `第${i + 1} 行` + this.notifylisttrans[key] + `未填`,type: "warning"})return}}}}}this.$refs['dataForm'].validate((valid) => {console.log(valid, 1111111111111111111);if (valid) {// console.log(valid);// let plants = this.dataForm.plantslet details = this.dataForm.details// console.log(plants, 111);// debugger// for (let i = 0; i < details.length; i++) {//   //对表格内要填的值做一个是否为空的判断//   //如果表格中的每一行的参数有任意一个不为null或者“”//   if (details[i].pdNo != "" || details[i].commonName != "" || details[i].packagings != ""//     || details[i].cropId != "" || details[i].controlObject != "" || !(details[i].purchaseDate == null ||//       details[i].purchaseDate == "") || !(details[i].medicationDate == null || details[i].medicationDate == "") ||//     details[i].purchaseAmount != 0 || details[i].purchaseCost != 0 || details[i].packingSpecification != 0 || details[i].medicationArea != 0//     || details[i].totalDosage != 0) {//     //就判断这一行是否都有数据 如果都有数据 则放行//     if (details[i].pdNo != "" && details[i].commonName != "" && details[i].packagings != "" && details[i].cropId != "" && details[i].controlObject != "" && !(details[i].purchaseDate == null && details[i].purchaseDate == "") && !(details[i].medicationDate == null && details[i].medicationDate == "") && details[i].purchaseAmount != 0 && details[i].purchaseCost != 0 && details[i].packingSpecification != 0 && details[i].medicationArea != 0 && details[i].totalDosage != 0) {//     } else {//       //如果不是 {都有} 数据,就提示用户哪一行没有数据,并终止方法的执行,目的是校验不通过 就不提交表单//       if (details[i].purchaseDate == "" || details[i].purchaseDate == null) {//         this.$notify({//           // title: `第${ i + 1 } 行作物种类`,//           title: `第${i + 1} 行的日期未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].purchaseAmount == 0 || details[i].purchaseAmount == "" || details[i].purchaseAmount == null) {//         this.$notify({//           // title: `第${ i + 1 } 行作物种类`,//           title: `第${i + 1} 行的农药购买量(克,毫升)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].purchaseCost == 0 || details[i].purchaseCost == "" || details[i].purchaseCost == null) {//         this.$notify({//           // title: `第${ i + 1 } 行作物种类`,//           title: `第${i + 1} 行的购买费用(元)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].packingSpecification == 0 || details[i].packingSpecification == "" || details[i].packingSpecification == null) {//         this.$notify({//           // title: `第${ i + 1 } 行作物种类`,//           title: `第${i + 1} 行的包装规格(克、毫升)/(瓶、袋)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].medicationArea == 0 || details[i].medicationArea == "" || details[i].medicationArea == null) {//         this.$notify({//           // title: `第${i + 1}行作物种类`,//           title: `第${i + 1}行的用药面积(亩)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].totalDosage == 0 || details[i].totalDosage == "" || details[i].totalDosage == null) {//         this.$notify({//           // title: `第${i + 1}行作物种类`,//           title: `第${i + 1}行的合计用药量(克、毫升)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].pdNo == "" || details[i].pdNo == null) {//         this.$notify({//           title: `第${i + 1}行的农药登记证号未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].commonName == "" || details[i].commonName == null) {//         this.$notify({//           title: `第${i + 1}行的农药通用名未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       if (details[i].packagings == "" || details[i].packagings == null) {//         this.$notify({//           title: `第${i + 1}行的包装物未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//       // if (details[i].cropId == "" || details[i].cropId == null) {//       //   this.$notify({//       //     title: `第${i + 1}行的用药作物id未填`,//       //     message: `请填写该数据`,//       //     type: 'warning',//       //     duration: 4500,//       //     offset: 200,//       //     dangerouslyUseHTMLString: true,//       //   })//       //   return//       // }//       if (details[i].controlObject == "" || details[i].controlObject == null) {//         this.$notify({//           title: `第${i + 1}行的防治对象名称(病虫草鼠种类)未填`,//           message: `请填写该数据`,//           type: 'warning',//           duration: 4500,//           offset: 200,//           dangerouslyUseHTMLString: true,//         })//         return//       }//     }//   }//   // if (plants[i].controlTimes != 0 || plants[i].plantingArea != 0) {//   //   if ((plants[i].controlTimes != 0 && plants[i].plantingArea == 0) || (plants[i].controlTimes == 0 && plants[i].plantingArea != 0)) {//   //     this.$notify({//   //       title: `第${i + 1}行`,//   //       message: '施药次数和种植面积不能为0 !',//   //       type: 'warning'//   //     })//   //     return//   //   }//   //   if (plants[i].applicatorMachinery == "" || plants[i].cultivationType == null || plants[i].sowingDate == null) {//   //     this.$notify({//   //       title: `第${i + 1}行`,//   //       message: '请填写数据',//   //       type: 'warning'//   //     })//   //     return//   //   }//   // }// },this.$http({url: `/pesticide/useinfo/${!this.dataForm.id ? 'save' : 'update'}`,method: 'post',data: this.dataForm}).then(({ data }) => {if (data && data.code === 0) {this.$message({message: '操作成功',type: 'success',duration: 1500})this.visible = falsethis.$emit('refreshDataList')}})}})},// 多选selectionChangeHandle (val) {this.dataListSelections = val},getAllCrop () {// this.dataForm = {}this.cropList = []let _this = thisthis.$http({url: '/pesticide/crop/queryAll',method: 'get',}).then(({ data }) => {if (data && data.code === 0) {console.log(data);//  this.remoteOptions = data.data.map(item => {// return { value: `${item}`, label: `${item}` };// });this.cropList = data.list.map((item) => {return {value: item.id,label: item.cropName}})// console.log(this.cropList);}})// console.log(dictList);},// 农药证号搜索(模糊搜索)// querySearch (queryString, cb) {//   var restaurants = this.restaurants;//   var results = queryString ?//     restaurants.filter(this.createStateFilter(queryString)) : restaurants;//   clearTimeout(this.timeout);//   this.timeout = setTimeout(() => {//     cb(results);//   }, 3000 * Math.random());// },// createStateFilter (queryString) {//   return (state) => {//     return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);//   };// },// handleSelect (item) {//   console.log(item);// },// remoteOptionsremoteMethod (query) {try {clearTimeout(a)} catch (e) {}var a = setTimeout(() => {this.remoteLoading = true//获取农药证号数据if (query.length > 3) {this.$http({url: '/pesticide/register/registNoLike',method: 'get',params: {noLike: query}}).then(({ data }) => {if (data && data.code === 0) {// this.list = data.datathis.remoteOptions = data.data.map(item => {return { value: `${item}`, label: `${item}` };});this.remoteLoading = false// this.$message({//   message: '操作成功',//   type: 'success',//   duration: 1500// })}})// this.loading = true;// setTimeout(() => {//   this.loading = false;//   this.options = this.list.filter(item => {//     return item.label.toLowerCase()//       .indexOf(query.toLowerCase()) > -1;//   });// }, 200);}else {this.remoteLoading = falsethis.remoteOptions = [{label: "请至少填写四位",value: ""}];}}, 300);},remoteMethodName (query) {try {clearTimeout(a)} catch (e) {}var a = setTimeout(() => {this.nameLoading = true//获取农药证号数据if (query.length >= 2) {this.$http({url: '/pesticide/register/pesNameLike',method: 'get',params: {nameLike: query}}).then(({ data }) => {if (data && data.code === 0) {// this.list = data.datathis.nameOptions = data.data.map(item => {return { value: `${item}`, label: `${item}` };});this.nameLoading = false// this.$message({//   message: '操作成功',//   type: 'success',//   duration: 1500// })}})// this.loading = true;// setTimeout(() => {//   this.loading = false;//   this.options = this.list.filter(item => {//     return item.label.toLowerCase()//       .indexOf(query.toLowerCase()) > -1;//   });// }, 200);}else {this.nameLoading = falsethis.nameOptions = [{label: "请至少填写两位",value: ""}];}}, 300);}},}</script>

农药购买与去向记载表相关推荐

  1. 农药购买与使用情况表

    效果图: 主表 点击新增跳转 .

  2. 数据库实验:数据库和表、查询、视图与安全性、存储过程及游标、触发器、综合实验-水果商店进阶

    数据库实验:数据库和表.查询.视图与安全性.存储过程及游标.触发器.综合实验-水果商店进阶 实验一.数据库和表 源码1: 源码2: 小结 实验二.查询 源码 小结 实验三.视图.安全性 源码: 小结 ...

  3. mysql如何根据业务分表设计_mysql分表分库的应用场景和设计方式

    很多朋友在论坛和留言区域问mysql在什么情况下才需要进行分库分表,以及采用何种设计方式才是最优的选择,根据这些问题,小编为大家整理了关于MySQL分库分表的应用场景和最优的设计方式举例. 一. 分表 ...

  4. @onetoone中被控表不能做自我删除吗?_儿童生活自律表,孩子总是不能坚持,那是因为父母犯了这4个错误...

    家长群是一个比较有意思的群体,经常看到各种父母发的育儿方法心得. 前段时间,我在的家长群里就有一位妈妈向其他父母大肆的安利一种育儿工具---儿童生活自律表.就是类似于下面这种. 自律表一般包括自己吃饭 ...

  5. 分表分库时机选择及策略

    转载自   分表分库时机选择及策略 一. 分表 应用场景: 对于大型的互联网应用来说,数据库单表的记录行数可能达到千万级甚至是亿级,并且数据库面临着极高的并发访问.采用Master-Slave复制模式 ...

  6. 前端开发 表单标签 完成一个简单登陆的效果 0228

    表单标签的功能 提交数据给服务器 表单的基本结构 格式各样的控件 input标签的多样性 目标效果 表格的结构 设置宽高 合并单元格 继续合并单元格 填写内容 . 插入表单控件 按钮添加 按钮居中 用 ...

  7. oracle 月累计,oracle 可有什么方法 统计每月累积购买人数?

    oracle 可有什么方法 统计每月累积购买人数? oracle 可有什么方法 统计每月累积购买人数 比如说有个门店 2008年购买商品的人数 表:t_buy_log  字段 f_username 用 ...

  8. 吉时利源表软件Kickstart与纳米NS-SourceMeter源表软件各有何特点

    在电测行业中,对高精度的电压.电流或电流电压源进行测量扫描时都会使用到源测量单元(SMU)即:源表(又被成为数字源表).它精确的采集能力以及为各种低电平测量应用提供额外的灵活性让它成为了电测行业中不和 ...

  9. 全球与中国微生物农药市场深度研究分析报告

    [报告篇幅]:98 [报告图表数]:139 [报告出版时间]:2021年12月 报告摘要 2021年全球微生物农药市场销售额达到了 亿美元,预计2028年将达到 亿美元,年复合增长率(CAGR)为 % ...

最新文章

  1. 我在MongoDB年终大会上获二等奖文章:由数据迁移至MongoDB导致的数据不一致问题及解决方案...
  2. 小小攻城师,步步达成梦想!
  3. linux初学者-普通磁盘分区篇
  4. 前端工程师和设计师必读文章推荐【系列三十六】
  5. MySQL实现当前数据表的所有时间都增加或减少指定的时间间隔
  6. 分布式SESSION一致性
  7. golang超时控制
  8. Spark提交任务到集群
  9. 网络虚拟信用卡如何申请?Yandex万事达虚拟信用卡申请教程
  10. 四川大学计算机在线作业,四川大学计算机操作系统试题
  11. python爬取网易云音乐评论并制作词云
  12. 咻咻验证码,见证百合网发展壮大!
  13. nginx 使用总结
  14. android 电话管理
  15. 算术左、右移位与逻辑左、右移位,右移一位和除二的区别、算术溢出
  16. Android_TextView
  17. 看完南京前11年房价,我哭了!今年实在太特么狠了
  18. ffmpeg AVFrame 插入静音帧
  19. Box and Ball
  20. 互联网厂商介入智能手机业成趋势 前景不明朗

热门文章

  1. 使用 kubeadm 部署 kubernetes 1.27.1 版本
  2. JDBC连接数据库读超时
  3. C语言游戏开发第一课:数字华容道
  4. 《程序员入职甲乙方公司的套路》。送给要入职的程序员们,避免踩坑。
  5. django高级用法
  6. 全彩控制器的编程软件有哪些_【全彩控制器编辑系统下载】全彩控制器编辑系统2020版 v2.1 官方版-开心电玩...
  7. Java中以时钟的效果显示时间
  8. 20159302《网络攻击与防范》第九周学习总结
  9. 嘀嗒出行能识别手机卡吗_面具竟然能替代人脸解锁手机!人脸识别还安全吗?|人脸识别|手机|面具|人脸识别系统...
  10. 来来来 给我求出0-999之间的所有水仙花数 求不出放学不许走