diff --git a/pages/massif/add_farming.vue b/pages/massif/add_farming.vue index 3965040..a60a2d0 100644 --- a/pages/massif/add_farming.vue +++ b/pages/massif/add_farming.vue @@ -192,7 +192,7 @@ - {{v.goodsType}} {{v.substanceName}} {{v.inputQuantity}}{{v.specs[1]}} + {{v.goodsType}} {{v.substanceName}} {{v.inputTotal}}{{v.specs[1]}} @@ -296,13 +296,22 @@ export default { } this.fields.images.value=e.images this.fields.farmingPlanId.value=[e.farmingPlanId] - this.saveInput=e?.inputList?.map?.(v=>({...v})) + this.saveInput=e?.inputList?.map?.(v=>({ + id:v.inOutId, + equivalentAmount: v.equivalentAmount, + goodsType:v.goodsType, + surplus:v.number*parseFloat(v.specs[0])+v.inputTotal,//剩余 + inputTotal: v.inputTotal, + substanceName: v.substanceName, + inOutBatchNo: v.inOutBatchNo, + operateTime: v.operateTime, + specificationId:v.specificationId, + specs:v.specs, + })) }) this.formData.plotId=options.plotId this.init() this.getMassifDetail() - //添加监听 - this.$provise.on("forming_agr",e=>e(this.formData.inputList)) }, methods:{ async init(){ @@ -352,9 +361,9 @@ export default { uni.navigateTo({ url:"/pages/massif/collectList", events:{ addSpecs: e=>{ - if(!this.formData.inputList.some(v=>{ - if(v.inventoryId==e.inventoryId){ - v.inputQuantity=e.inputQuantity + if(!this.formData.inputList.some((v,k)=>{ + if(v.inOutId==e.inOutId){ + v.inputTotal=e.inputTotal return true }else{ return false @@ -362,7 +371,10 @@ export default { })){ this.formData.inputList.push(e) } - } } + } }, + success:res=>{ + res.eventChannel.emit("list", this.saveInput) + } }) }, check(){ @@ -457,8 +469,5 @@ export default { }) }, }, - onUnload(){ - this.$provise.off('forming_agr') - }, } diff --git a/pages/massif/collectList.vue b/pages/massif/collectList.vue index 6fbabed..0433334 100644 --- a/pages/massif/collectList.vue +++ b/pages/massif/collectList.vue @@ -91,28 +91,30 @@ @@ -128,6 +130,7 @@ export default { pageSize:50, search:"", }, + loading:true, list:[], saveList:[], detail:null, @@ -135,63 +138,63 @@ export default { eventChannel:null, } }, + computed:{ + comList(){ + return this.saveList.concat(this.list.filter(v=>!this.saveList.some(i=>i.id==v.id))) + }, + }, onLoad(){ this.eventChannel=this.getOpenerEventChannel() + this.eventChannel.on("list", e=>this.saveList=e) this.search() }, methods:{ - clean(){ - this.list=[] - this.total=0 - this.searchVal.pageNo=1 - }, async search(){ - if(this.total==0 || this.list.length({ + ...v, + unitNum:parseFloat(v.specDescribe.match(/^[\d\.]+/)?.[0]||0), + })) + }else{ + uni.showModal({ + title:"提示", + content:res.msg||"获取领用农资失败!", + showCancel:false, }) - if(res.statu){ - this.list=this.list.concat(res.data.records.map(v=>({...v,unitNum:parseFloat(v.specDescribe.match(/^[\d\.]+/)?.[0]||0)}))) - this.total=res.data.total - this.searchVal.pageNo++ - if(this.list.length==this.total)uni.showToast({title:"加载完成!",icon:"none"}) - }else{ - uni.showModal({ - title:"提示", - content:res.msg||"获取领用农资失败!", - showCancel:false, - }) - } } }, toSpecs(e){ this.detail={ goodsType: e.goodsType, - inputQuantity:'', - inventoryId: e.inventoryId, - number:e.number, - specDescribe:e.specDescribe, - specificationId: e.specId, - specs: (e.specDescribe.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4), + inputTotal:'', + inOutId: e.id, + surplus:e.surplus, + specificationId: e.specificationId||e.specId, + specs: e.specs||(e.specDescribe.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4), substanceName: e.substanceName, } }, confirm(){ - if(!(parseFloat(this.detail.inputQuantity))){ + if(!(parseFloat(this.detail.inputTotal))){ this.$refs.toast.show({ type:"error", icon:false, message:"请输入数量!", }) - }else if(parseFloat(this.detail.inputQuantity)>this.detail.number*this.detail.specs[0]){ + }else if(parseFloat(this.detail.inputTotal)>this.detail.surplus){ this.$refs.toast.show({ type:"error", icon:false, message:"输入数量不能大于剩余数量!", }) }else{ - this.eventChannel.emit("addSpecs", {...this.detail, inputQuantity:parseFloat(this.detail.inputQuantity)}) + this.eventChannel.emit("addSpecs", {...this.detail, inputTotal:parseFloat(this.detail.inputTotal)}) uni.navigateBack() } }, diff --git a/pages/massif/mana/farmRecord.vue b/pages/massif/mana/farmRecord.vue index 24637eb..13945cf 100644 --- a/pages/massif/mana/farmRecord.vue +++ b/pages/massif/mana/farmRecord.vue @@ -157,11 +157,11 @@ {{v.pests}} - 负责人:{{v.principal}} 记录日期:{{new Date(v.time).format('yyyy-MM-dd')}} + 负责人:{{v.principal}} 记录日期:{{new Date(v.farmingTime).format('yyyy-MM-dd')}} - {{v.farmingType}} 负责人:{{v.principal}} 记录日期:{{new Date(v.time).format('yyyy-MM-dd')}} + {{v.farmingType}} 负责人:{{v.principal}} 记录日期:{{new Date(v.farmingTime).format('yyyy-MM-dd')}} @@ -215,7 +215,10 @@ export default { }}, success:res=>{ if(v){ - res.eventChannel.emit("detail", v) + res.eventChannel.emit("detail", { + ...v, + inputList: v.inputList.map(v=>({...v,specs: (v.specDescribe.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4)})) + }) } } })