|
|
@ -61,16 +61,16 @@ |
|
|
|
<template> |
|
|
|
<view class="container" :class="{agr:!isAgr}"> |
|
|
|
<d-navbar text="农资入库" isBack style="--bg:#10C176;--c:#fff;"> |
|
|
|
<button slot="right" class="cu-btn round" @click="submit">提交</button> |
|
|
|
<button slot="right" class="cu-btn round" @click="isAgr && submit()">提交</button> |
|
|
|
</d-navbar> |
|
|
|
|
|
|
|
<view class="agrInfo card" v-if="isAgr"> |
|
|
|
<view class="data"> <text>化肥</text><text class="over">中量元素水溶肥</text><text class="plant-jiantou_zuoyouqiehuan"/> </view> |
|
|
|
<view style="color:#707070;font-size:20rpx;">云南云天化股份有限公司</view> |
|
|
|
<view class="data"> <text>{{agrDetail.detailedParentName}}</text><text class="over">{{agrDetail.goodsName}}</text><text class="plant-jiantou_zuoyouqiehuan" @click="toAddAgr"/> </view> |
|
|
|
<view style="color:#707070;font-size:20rpx;">{{agrDetail.supplier}}</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<u-form class="inline" :class="{card:isAgr}" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto"> |
|
|
|
<view class="addAgr">添加农资<text class="plant-batch-add"/></view> |
|
|
|
<view v-if="!isAgr" class="addAgr" @click="toAddAgr">添加农资<text class="plant-batch-add"/></view> |
|
|
|
<template v-for="(v,k) in fields"> |
|
|
|
<d-form |
|
|
|
v-if="!v.agr ||v.agr&&isAgr" |
|
|
@ -78,40 +78,122 @@ |
|
|
|
v-bind="v" |
|
|
|
:field="k" |
|
|
|
:required="!!rules[k]" |
|
|
|
:value="formData[k]"/> |
|
|
|
:value="/^select$/.test(v.type)?fields[k].value:formData[k]" |
|
|
|
@input="formData[k]=$event" |
|
|
|
@select="formData[k]=$event.value[0].value;fields[k].value=[formData[k]]" |
|
|
|
@imgs="fields[k].value=$event"/> |
|
|
|
</template> |
|
|
|
</u-form> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import request from '@/common/request' |
|
|
|
export default{ |
|
|
|
data(){ |
|
|
|
return{ |
|
|
|
fields:{ |
|
|
|
scpect:{label:"规格", type:"select", columns:[[]],value:[],agr:true}, |
|
|
|
num:{label:"入库数量", type:"number",suffix:"袋", tip:"共计:40kg",agr:true}, |
|
|
|
type:{label:"入库类型"}, |
|
|
|
date:{label:"入库时间"}, |
|
|
|
imgs:{label:"单据、凭证图片",type:"upImg",value:''}, |
|
|
|
remarks:{label:"备注",type:"textarea"}, |
|
|
|
specName:{label:"规格", disabled:true, agr:true}, |
|
|
|
number:{label:"入库数量", type:"digit",suffix:"袋", tip:"",agr:true}, |
|
|
|
inOutBatchNo:{label:"入库批次号",agr:true, btnText:"生成", btnFun:()=>this.formData.inOutBatchNo=`RK${new Date().format('yyyyMMdd')}${new Date().getTime()}`}, |
|
|
|
inOutType:{label:"入库类型",type:"select",columns:[],value:[]}, |
|
|
|
operateTime:{label:"入库时间",type:"calendar"}, |
|
|
|
pic:{label:"单据、凭证图片",type:"upImg",value:''}, |
|
|
|
remark:{label:"备注",type:"textarea"}, |
|
|
|
}, |
|
|
|
formData:{ |
|
|
|
type:"", |
|
|
|
date:"", |
|
|
|
imgs:[], |
|
|
|
remarks:"", |
|
|
|
specName:"", |
|
|
|
specId:"", |
|
|
|
number:"", |
|
|
|
inOutBatchNo:'', |
|
|
|
inOutType:"", |
|
|
|
operateTime:"", |
|
|
|
pic:[], |
|
|
|
remark:"", |
|
|
|
}, |
|
|
|
rules:{ |
|
|
|
type:{required:true}, |
|
|
|
date:{required:true}, |
|
|
|
imgs:{required:true}, |
|
|
|
number:{required:true,type:"number", message:"入库数量必填!"}, |
|
|
|
inOutBatchNo:{required:true, message:"入库批次号必填!"}, |
|
|
|
inOutType:{required:true, message:"入库类型必选!"}, |
|
|
|
operateTime:{required:true, message:"入库时间必选!"}, |
|
|
|
}, |
|
|
|
|
|
|
|
agrDetail:{},//农资详情 |
|
|
|
isAgr: false, |
|
|
|
eventChannel:null, |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(){}, |
|
|
|
computed:{ |
|
|
|
specs(){ |
|
|
|
return{ |
|
|
|
specs:(this.formData.specName.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4), |
|
|
|
num:this.formData.number |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch:{ |
|
|
|
specs(n){ |
|
|
|
this.fields.number.suffix=n.specs[2] |
|
|
|
if(n.num>0 && n.specs[0]){ |
|
|
|
this.fields.number.tip=`共计:${parseFloat(n.num)*parseFloat(n.specs[0])}${n.specs[1]}` |
|
|
|
}else{ |
|
|
|
this.fields.number.tip='' |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(){ |
|
|
|
this.eventChannel=this.getOpenerEventChannel() |
|
|
|
this.init() |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
submit(){}, |
|
|
|
async init(){ |
|
|
|
var res=await request("/common/api/dict/queryDictItemByDictCode",{ |
|
|
|
method:"post", |
|
|
|
params:{dictCode:"in_type"} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.fields.inOutType.columns=[res.data] |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取企业类型选项失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
toAddAgr(){ |
|
|
|
uni.navigateTo({ |
|
|
|
url:"/pages/purchase/agrProdList?mode=stock", |
|
|
|
events:{submit: e=>{ |
|
|
|
this.agrDetail=e |
|
|
|
this.formData.specId=e.specificationId |
|
|
|
this.formData.specName=e.goodsSpecification |
|
|
|
this.isAgr=true |
|
|
|
}} |
|
|
|
}) |
|
|
|
}, |
|
|
|
submit(){ |
|
|
|
this.$refs.form.validate().then(async valid=>{ |
|
|
|
if(valid){ |
|
|
|
var res=await request("/api/InventoryManageApi/addInventory",{ |
|
|
|
method:"post", |
|
|
|
body: { |
|
|
|
...this.formData, |
|
|
|
pic: this.fields.pic.value |
|
|
|
} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
uni.navigateBack() |
|
|
|
this.eventChannel.emit("update") |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"保存失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
</script> |