Browse Source

农事操作 修改投入品选择

master
邓宏 2 months ago
parent
commit
f835ab6569
  1. 31
      pages/massif/add_farming.vue
  2. 91
      pages/massif/collectList.vue
  3. 9
      pages/massif/mana/farmRecord.vue

31
pages/massif/add_farming.vue

@ -192,7 +192,7 @@
<u-swipe-action v-for="(v,k) in formData.inputList" :key="k"> <u-swipe-action v-for="(v,k) in formData.inputList" :key="k">
<u-swipe-action-item> <u-swipe-action-item>
<view> <view>
<text>{{v.goodsType}}</text> <text>{{v.substanceName}}</text> <text>{{v.inputQuantity}}{{v.specs[1]}}</text> <text>{{v.goodsType}}</text> <text>{{v.substanceName}}</text> <text>{{v.inputTotal}}{{v.specs[1]}}</text>
</view> </view>
<view slot="button" class="u-swipe-action-item__right__button"> <view slot="button" class="u-swipe-action-item__right__button">
<button class="cu-btn bg-red" style="margin:auto;" @click="formData.inputList.splice(k,1)">删除</button> <button class="cu-btn bg-red" style="margin:auto;" @click="formData.inputList.splice(k,1)">删除</button>
@ -296,13 +296,22 @@ export default {
} }
this.fields.images.value=e.images this.fields.images.value=e.images
this.fields.farmingPlanId.value=[e.farmingPlanId] 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.formData.plotId=options.plotId
this.init() this.init()
this.getMassifDetail() this.getMassifDetail()
//
this.$provise.on("forming_agr",e=>e(this.formData.inputList))
}, },
methods:{ methods:{
async init(){ async init(){
@ -352,9 +361,9 @@ export default {
uni.navigateTo({ uni.navigateTo({
url:"/pages/massif/collectList", url:"/pages/massif/collectList",
events:{ addSpecs: e=>{ events:{ addSpecs: e=>{
if(!this.formData.inputList.some(v=>{ if(!this.formData.inputList.some((v,k)=>{
if(v.inventoryId==e.inventoryId){ if(v.inOutId==e.inOutId){
v.inputQuantity=e.inputQuantity v.inputTotal=e.inputTotal
return true return true
}else{ }else{
return false return false
@ -362,7 +371,10 @@ export default {
})){ })){
this.formData.inputList.push(e) this.formData.inputList.push(e)
} }
} } } },
success:res=>{
res.eventChannel.emit("list", this.saveInput)
}
}) })
}, },
check(){ check(){
@ -457,8 +469,5 @@ export default {
}) })
}, },
}, },
onUnload(){
this.$provise.off('forming_agr')
},
} }
</script> </script>

91
pages/massif/collectList.vue

@ -91,28 +91,30 @@
</style> </style>
<template> <template>
<view class="container flex"> <view class="container flex">
<d-search v-model="searchVal.search" @search="clean();search()"/> <d-search v-model="searchVal.search" @search="search()"/>
<scroll-view scroll-y> <scroll-view scroll-y>
<view class="card" v-for="(v,k) in list" :key="k" @click="toSpecs(v)"> <block v-if="!loading">
<view class="head"> <view class="card" v-for="(v,k) in comList" :key="k" @click="toSpecs(v)">
<text class="type">{{v.goodsType}}</text> <view class="head">
<text class="name over">{{v.substanceName}}</text> <text class="type">{{v.goodsType}}</text>
<text class="name over">{{v.substanceName}}</text>
</view>
<view class="item">
<text class="over PA-hebing">入库编号{{v.inOutBatchNo}}</text> <text class="amount" :data-unit="v.unit">{{v.equivalentAmount}}</text>
</view>
<view class="item">
<text class="PA-path1">入库日期{{v.operateTime}}</text> <text class="surplus">剩余{{v.surplus}}{{v.unit||v.specs[1]}}</text>
</view>
</view> </view>
<view class="item"> </block>
<text class="over PA-hebing">入库编号{{v.inOutBatchNo}}</text> <text class="amount" :data-unit="v.unit">{{v.equivalentAmount}}</text> <u-empty v-else-if="comList.length==0||loading" text="未查询到相关信息" width="70%" icon="/static/noData.png"/>
</view>
<view class="item">
<text class="PA-path1">入库日期{{v.operateTime}}</text> <text class="surplus">剩余{{Math.round(v.number*v.unitNum*100)/100+(saveList.find(i=>i.inventoryId==v.inventoryId)?saveList.find(i=>i.inventoryId==v.inventoryId).inputTotal:0)}}{{v.unit}}</text>
</view>
</view>
<u-empty v-if="list.length==0" text="未查询到相关信息" width="70%" icon="/static/noData.png"/>
<view style="border:0.5rpx solid transparent"/> <view style="border:0.5rpx solid transparent"/>
</scroll-view> </scroll-view>
<u-toast ref="toast"/> <u-toast ref="toast"/>
<u-modal :show="!!detail" @close="detail=null" @cancel="detail=null" showCancelButton closeOnClickOverlay @confirm="confirm"> <u-modal :show="!!detail" @close="detail=null" @cancel="detail=null" showCancelButton closeOnClickOverlay @confirm="confirm">
<input v-if="!!detail" placeholder="请输入数量" type="digit" v-model="detail.inputQuantity"/> <input v-if="!!detail" placeholder="请输入数量" type="digit" v-model="detail.inputTotal"/>
</u-modal> </u-modal>
</view> </view>
</template> </template>
@ -128,6 +130,7 @@ export default {
pageSize:50, pageSize:50,
search:"", search:"",
}, },
loading:true,
list:[], list:[],
saveList:[], saveList:[],
detail:null, detail:null,
@ -135,63 +138,63 @@ export default {
eventChannel:null, eventChannel:null,
} }
}, },
computed:{
comList(){
return this.saveList.concat(this.list.filter(v=>!this.saveList.some(i=>i.id==v.id)))
},
},
onLoad(){ onLoad(){
this.eventChannel=this.getOpenerEventChannel() this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("list", e=>this.saveList=e)
this.search() this.search()
}, },
methods:{ methods:{
clean(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
},
async search(){ async search(){
if(this.total==0 || this.list.length<this.total){ this.loading=true
var res=await request("/api/Inventory/queryCollectingList",{ var res=await request("/api/Inventory/queryCollectingList",{
method:"post", method:"post",
body: this.searchVal body: this.searchVal
})
this.loading=false
if(res.statu){
this.list=res.data.records.map(v=>({
...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){ toSpecs(e){
this.detail={ this.detail={
goodsType: e.goodsType, goodsType: e.goodsType,
inputQuantity:'', inputTotal:'',
inventoryId: e.inventoryId, inOutId: e.id,
number:e.number, surplus:e.surplus,
specDescribe:e.specDescribe, specificationId: e.specificationId||e.specId,
specificationId: e.specId, specs: e.specs||(e.specDescribe.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4),
specs: (e.specDescribe.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4),
substanceName: e.substanceName, substanceName: e.substanceName,
} }
}, },
confirm(){ confirm(){
if(!(parseFloat(this.detail.inputQuantity))){ if(!(parseFloat(this.detail.inputTotal))){
this.$refs.toast.show({ this.$refs.toast.show({
type:"error", type:"error",
icon:false, icon:false,
message:"请输入数量!", 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({ this.$refs.toast.show({
type:"error", type:"error",
icon:false, icon:false,
message:"输入数量不能大于剩余数量!", message:"输入数量不能大于剩余数量!",
}) })
}else{ }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() uni.navigateBack()
} }
}, },

9
pages/massif/mana/farmRecord.vue

@ -157,11 +157,11 @@
<text class="organ">{{v.pests}}</text> <text class="organ">{{v.pests}}</text>
</view> </view>
<view class="info"> <view class="info">
<text>负责人{{v.principal}}</text> <text>记录日期{{new Date(v.time).format('yyyy-MM-dd')}}</text> <text>负责人{{v.principal}}</text> <text>记录日期{{new Date(v.farmingTime).format('yyyy-MM-dd')}}</text>
</view> </view>
</template> </template>
<view v-else class="detail"> <view v-else class="detail">
<text>{{v.farmingType}}</text> <text>负责人{{v.principal}}</text> <text>记录日期{{new Date(v.time).format('yyyy-MM-dd')}}</text> <text>{{v.farmingType}}</text> <text>负责人{{v.principal}}</text> <text>记录日期{{new Date(v.farmingTime).format('yyyy-MM-dd')}}</text>
</view> </view>
<view class="footer"> <view class="footer">
<button class="cu-btn txt PA-bianji" @click="toAdd(v)">编辑</button> <button class="cu-btn txt PA-bianji" @click="toAdd(v)">编辑</button>
@ -215,7 +215,10 @@ export default {
}}, }},
success:res=>{ success:res=>{
if(v){ 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)}))
})
} }
} }
}) })

Loading…
Cancel
Save