Browse Source

出库 修改采收批次表单显示剩余数量

master
邓宏 2 years ago
parent
commit
c06c2afbf4
  1. 18
      pages/stock/list.vue

18
pages/stock/list.vue

@ -140,7 +140,7 @@
<view class="company">
<text class="type">{{detail.detailType}}</text>
<text v-if="formData.substanceType==1" class="name">{{detail.supplierName}}</text>
<text v-else-if="inInventoryBatch.list.length<=0" class="specs">{{detail.equivalentInventory}}{{detail.unit}}</text>
<text v-else-if="recoveryBatch.list.length<=0" class="specs">{{detail.equivalentInventory}}{{detail.unit}}</text>
</view>
</view>
@ -153,7 +153,11 @@
<view class="card">
<u-form class="inline" :model="formData" ref="form" :rules="rules" labelWidth="auto">
<d-form v-if="inInventoryBatch.list.length>0" label="采收批次" field="inInventoryBatch" required type="select" :columns="inInventoryBatch.list" custom :value="inInventoryBatch.value" @select="inInventoryBatch.value=[$event[0].value];inInventoryBatch.number=$event[0].surplus;formData.inInventoryBatch=inInventoryBatch.value.at(-1)">
<d-form
v-if="recoveryBatch.list.length>0" label="采收批次" field="inInventoryBatch" required type="select" :columns="recoveryBatch.list" custom
:tip="recoveryBatch.surplus>0?`剩余:${recoveryBatch.surplus}kg`:''"
:value="recoveryBatch.value"
@select="recoveryBatch.value=[$event[0].value];recoveryBatch.number=$event[0].surplus;recoveryBatch.surplus=$event[0].surplus;formData.inInventoryBatch=recoveryBatch.value.at(-1)">
<view slot-scope="{row}" style="display:flex;">
<text style="margin-left:10rpx;font-weight:bold;">{{row.batchNo}}</text>
<text style="font-size:24rpx;color:#999;margin-left:10rpx;">{{row.substanceName}}</text>
@ -163,7 +167,7 @@
<d-form :label="`${({in:'入',out:'出'})[mode]}库类型`" field="inOutType" required type="select" :columns="inOutType.list" :value="inOutType.value" @select="inOutType.value=$event.map(v=>v.value);formData.inOutType=inOutType.value.at(-1)"/>
<d-form :label="`${({in:'入',out:'出'})[mode]}库批次号`" field="inOutBatchNo" required :value="formData.inOutBatchNo" @input="formData.inOutBatchNo=$event" btnText="生成" :btnFun="()=>this.formData.inOutBatchNo=`${({in:'RK',out:'CK'})[this.mode]}${new Date().format('yyyyMMdd')}${new Date().getTime()}`"/>
<d-form :label="({1:`${({in:'入',out:'出'})[mode]}库数量`,2:'交易重量'})[formData.substanceType]" field="number" required :suffix="number.suffix" :value="formData.number" @input="formData.number=$event" type="digit"/>
<template v-if="formData.substanceType==2&&formData.inOutType=='out01'&&inInventoryBatch.list.length>0">
<template v-if="formData.substanceType==2&&formData.inOutType=='out01'&&recoveryBatch.list.length>0">
<view style="display:flex;align-items: center;">
<d-form label="规格" required field="specification" type="digit" suffix="kg" :value="formData.specification" @input="formData.specification=$event"/>
<text style="margin:45rpx 20rpx 0 20rpx;">/</text>
@ -190,7 +194,7 @@ export default{
mode:"",
detail:{},
inInventoryBatch:{list:[],value:[],number:0},
recoveryBatch:{list:[],value:[],number:0,surplus:0},
inOutType:{list:[],value:[]},
pic:"",
number:{suffix:""},
@ -225,8 +229,8 @@ export default{
number:{required:true,validator:(rule,val,call)=>{
var title=({1:({in:'入',out:'出'})[this.mode],2:'交易重量'})[this.formData.substanceType]
if(!(val>0))call(new Error(`请输入${title}`));
else if(this.mode=='out' &&this.inInventoryBatch.list<=0&& val>this.detail.equivalentInventory)call(new Error(`${title}不能大于剩余数量${this.detail.equivalentInventory}`));
else if(this.mode=='out' &&this.inInventoryBatch.list>0&& val>this.inInventoryBatch.number)call(new Error(`${title}不能大于剩余数量${this.inInventoryBatch.number}`));
else if(this.mode=='out' &&this.recoveryBatch.list<=0&& val>this.detail.equivalentInventory)call(new Error(`${title}不能大于剩余数量${this.detail.equivalentInventory}`));
else if(this.mode=='out' &&this.recoveryBatch.list>0&& val>this.recoveryBatch.number)call(new Error(`${title}不能大于剩余数量${this.recoveryBatch.number}`));
else call()
},type:"number",trigger:['blur','change']},
@ -271,7 +275,7 @@ export default{
params:{inventoryId}
})
if(res.statu){
this.inInventoryBatch.list=res.data.length>0?[res.data.map(v=>({...v,label:v.substanceName,value:v.batchNo}))]:[]
this.recoveryBatch.list=res.data.length>0?[res.data.map(v=>({...v,label:v.substanceName,value:v.batchNo}))]:[]
}else{
uni.showModal({
title:"提示",

Loading…
Cancel
Save