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-item>
<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 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>
@ -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')
},
}
</script>

91
pages/massif/collectList.vue

@ -91,28 +91,30 @@
</style>
<template>
<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>
<view class="card" v-for="(v,k) in list" :key="k" @click="toSpecs(v)">
<view class="head">
<text class="type">{{v.goodsType}}</text>
<text class="name over">{{v.substanceName}}</text>
<block v-if="!loading">
<view class="card" v-for="(v,k) in comList" :key="k" @click="toSpecs(v)">
<view class="head">
<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 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">剩余{{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"/>
</block>
<u-empty v-else-if="comList.length==0||loading" text="未查询到相关信息" width="70%" icon="/static/noData.png"/>
<view style="border:0.5rpx solid transparent"/>
</scroll-view>
<u-toast ref="toast"/>
<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>
</view>
</template>
@ -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<this.total){
var res=await request("/api/Inventory/queryCollectingList",{
method:"post",
body: this.searchVal
this.loading=true
var res=await request("/api/Inventory/queryCollectingList",{
method:"post",
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){
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()
}
},

9
pages/massif/mana/farmRecord.vue

@ -157,11 +157,11 @@
<text class="organ">{{v.pests}}</text>
</view>
<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>
</template>
<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 class="footer">
<button class="cu-btn txt PA-bianji" @click="toAdd(v)">编辑</button>
@ -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)}))
})
}
}
})

Loading…
Cancel
Save