|
|
@ -52,66 +52,44 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.u-form{ |
|
|
|
&>.u-form-item{ |
|
|
|
&/deep/ { |
|
|
|
.u-form-item__body__left{ |
|
|
|
.u-form-item__body__left__content{ |
|
|
|
.u-form-item__body__left__content__required{ |
|
|
|
position:initial; |
|
|
|
margin-right:4rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.u-form-item__body__right__message{ |
|
|
|
margin-left:0!important; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.plant-youbian{ |
|
|
|
padding:18rpx 18rpx; |
|
|
|
border-radius: 24rpx; |
|
|
|
width:100%; |
|
|
|
display:flex; |
|
|
|
align-items: center; |
|
|
|
flex-direction: row-reverse; |
|
|
|
justify-content: space-between; |
|
|
|
background:#F7F7F7; |
|
|
|
margin-top:14rpx; |
|
|
|
color:rgb(48,49,51); |
|
|
|
&.noData{ |
|
|
|
color:rgb(192, 196, 204); |
|
|
|
} |
|
|
|
&:before{ |
|
|
|
transform: rotate(90deg); |
|
|
|
color:rgb(48,49,51); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// .u-popup{ |
|
|
|
// .u-popup__content{ |
|
|
|
// &>.btns{ |
|
|
|
// display:flex; |
|
|
|
// justify-content: space-between; |
|
|
|
// padding:10rpx; |
|
|
|
// } |
|
|
|
|
|
|
|
// picker-view{ |
|
|
|
// height:500rpx; |
|
|
|
// picker-view-column{ |
|
|
|
// view.item{ |
|
|
|
// padding:0 30rpx; |
|
|
|
// display:flex; |
|
|
|
// flex-direction: column; |
|
|
|
// justify-content: space-evenly; |
|
|
|
// .name{ |
|
|
|
// display:flex; |
|
|
|
// align-items: center; |
|
|
|
// text{ |
|
|
|
// font-size:16rpx; |
|
|
|
// &:first-child{ |
|
|
|
// color:#fff; |
|
|
|
// background:#10C176; |
|
|
|
// border-radius:0 20rpx 0 20rpx; |
|
|
|
// width:80rpx; |
|
|
|
// height:34rpx; |
|
|
|
// text-align: center; |
|
|
|
// line-height: 34rpx; |
|
|
|
// margin-right:16rpx; |
|
|
|
// } |
|
|
|
// &:nth-child(2){ |
|
|
|
// font-weight: bold; |
|
|
|
// font-size:20rpx; |
|
|
|
// } |
|
|
|
// &:nth-child(3){ |
|
|
|
// color:#999; |
|
|
|
// margin-left:6rpx; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// .company{ |
|
|
|
// font-size:16rpx; |
|
|
|
// &:before{ |
|
|
|
// content:attr(data-name); |
|
|
|
// color:#FBA83C; |
|
|
|
// margin-right:20rpx; |
|
|
|
// } |
|
|
|
// &:after{ |
|
|
|
// content:attr(data-company); |
|
|
|
// color:#999999; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
.agr-picker{ |
|
|
|
padding:0 30rpx; |
|
|
|
display:flex; |
|
|
@ -173,17 +151,15 @@ |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="card"> |
|
|
|
<u-form class="inline" labelWidth="auto" ref="form" errorType="toast" :model="formData" :rules="rules"> |
|
|
|
<d-form |
|
|
|
v-for="(v,k) in fields" |
|
|
|
:key="k" |
|
|
|
v-bind="v" |
|
|
|
:field="k" |
|
|
|
:required="!!rules[k]" |
|
|
|
@input="formData[k]=$event" |
|
|
|
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value[0].value"/> |
|
|
|
<u-form class="inline" labelWidth="auto"> |
|
|
|
<u-form-item label="规格" prop="specificationId" :required="true"> |
|
|
|
<view class="plant-youbian" :class="{noData: !formData.specDescribe}" @click="$refs.Dpicker.show=true">{{formData.specDescribe||"请选择规格"}}</view> |
|
|
|
</u-form-item> |
|
|
|
<d-form v-bind="inputQuantity" :value="formData.inputQuantity" @input="formData.inputQuantity=$event"/> |
|
|
|
</u-form> |
|
|
|
</view> |
|
|
|
|
|
|
|
<d-picker ref="Dpicker" :list="specs.list" @select="select"/> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
<script> |
|
|
@ -191,39 +167,46 @@ import request from '@/common/request.js' |
|
|
|
export default { |
|
|
|
data(){ |
|
|
|
return{ |
|
|
|
fields:{ |
|
|
|
specificationId:{label:"规格",tip:"",type:"select",columns:[[]],value:[]}, |
|
|
|
inputQuantity:{label:"投入数量",type:"digit",suffix:""}, |
|
|
|
specs:{ |
|
|
|
tip:"", |
|
|
|
list:[] |
|
|
|
}, |
|
|
|
inputQuantity:{ |
|
|
|
label:"投入数量", |
|
|
|
required:true, |
|
|
|
type:"digit", |
|
|
|
field:"inputQuantity", |
|
|
|
suffix:"", |
|
|
|
tip:"", |
|
|
|
}, |
|
|
|
|
|
|
|
formData:{ |
|
|
|
specificationId:"", |
|
|
|
number:'',//规格数量 |
|
|
|
specDescribe:"",//规格名称 |
|
|
|
|
|
|
|
inputQuantity:"", |
|
|
|
inventoryId:"", |
|
|
|
}, |
|
|
|
rules:{ |
|
|
|
specificationId:{required:true,message:"规格必选!"}, |
|
|
|
inputQuantity:{required:true,type:"number",message:"投入数量必填!"}, |
|
|
|
}, |
|
|
|
agrDetail:{}, |
|
|
|
eventChannel:null, |
|
|
|
} |
|
|
|
}, |
|
|
|
computed:{ |
|
|
|
specsVal(){ |
|
|
|
var specs=(this.fields.specificationId.columns[0]?.find?.(v=>v.value==this.formData.specificationId)||{}).label||"" |
|
|
|
return{ |
|
|
|
specs:(specs.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4), |
|
|
|
specs:(this.formData.specDescribe.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4), |
|
|
|
num:this.formData.inputQuantity |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch:{ |
|
|
|
specsVal(n){ |
|
|
|
this.fields.inputQuantity.suffix=n.specs[2] |
|
|
|
this.inputQuantity.suffix=n.specs[2] |
|
|
|
if(n.num>0 && n.specs[0]>0){ |
|
|
|
this.$set(this.fields.inputQuantity, "tip", `共${parseFloat(n.num)*parseFloat(n.specs[0])}${n.specs[1]}`) |
|
|
|
this.$set(this.inputQuantity, "tip", `共${parseFloat(n.num)*parseFloat(n.specs[0])}${n.specs[1]}`) |
|
|
|
}else{ |
|
|
|
this.$set(this.fields.inputQuantity, "tip", "") |
|
|
|
this.$set(this.inputQuantity, "tip", "") |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
@ -233,16 +216,23 @@ export default { |
|
|
|
this.agrDetail=e |
|
|
|
this.init() |
|
|
|
}) |
|
|
|
this.formData.inventoryId=options.id |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
async init(){ |
|
|
|
var res=await request("/api/plantFarming/getSpecification",{ |
|
|
|
params:{goodsId: this.agrDetail.goodsId} |
|
|
|
params:{ |
|
|
|
goodsId: this.agrDetail.goodsId, |
|
|
|
baseId: this.$store.state.plantBaseInfoId, |
|
|
|
} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.fields.specificationId.columns=[res.data.listSpec.map(v=>({label:v.goodsSpecification,value:v.id}))] |
|
|
|
this.fields.specificationId.tip=res.data.inventory |
|
|
|
this.$provise.emit("forming_agr", list=>{ |
|
|
|
this.specs.list=res.data.listSpec.map(v=>{ |
|
|
|
v.number-=list.reduce((a,b)=>a+(b.inventoryId==v.id?b.inputQuantity:0),0) |
|
|
|
return v |
|
|
|
}).filter(v=>v.number>0) |
|
|
|
}) |
|
|
|
this.specs.tip=res.data.inventory |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
@ -251,18 +241,36 @@ export default { |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
select(e){ |
|
|
|
this.formData.specificationId=e.specId |
|
|
|
this.formData.inventoryId=e.id |
|
|
|
|
|
|
|
this.formData.number=e.number |
|
|
|
this.formData.specDescribe=e.specDescribe |
|
|
|
}, |
|
|
|
check(){ |
|
|
|
if(!this.formData.specificationId){ |
|
|
|
uni.showToast({title:"规格必选!",icon:"none"}) |
|
|
|
return false |
|
|
|
}else if(!(this.formData.inputQuantity>0)){ |
|
|
|
uni.showToast({title:"投入数量必填!",icon:"none"}) |
|
|
|
return false |
|
|
|
}else if(this.formData.inputQuantity>this.formData.number){ |
|
|
|
uni.showToast({title:`投入数量不能大于剩余数量${this.formData.number}!`,icon:"none"}) |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
submit(){ |
|
|
|
this.$refs.form.validate().then(async valid=>{ |
|
|
|
if(valid){ |
|
|
|
this.eventChannel.emit("update", { |
|
|
|
...this.formData, |
|
|
|
total: `${parseFloat(this.specsVal.num)*parseFloat(this.specsVal.specs[0])}${this.specsVal.specs[1]}`, |
|
|
|
goodsType: this.agrDetail.goodsType, |
|
|
|
substanceName: this.agrDetail.substanceName, |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} |
|
|
|
}) |
|
|
|
if(this.check()){ |
|
|
|
this.eventChannel.emit("update", { |
|
|
|
...this.formData, |
|
|
|
total: `${parseFloat(this.specsVal.num)*parseFloat(this.specsVal.specs[0])}${this.specsVal.specs[1]}`, |
|
|
|
goodsType: this.agrDetail.goodsType, |
|
|
|
substanceName: this.agrDetail.substanceName, |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|