Browse Source

联调 库存新增入库

master
邓宏 2 years ago
parent
commit
2a3b122cc9
  1. 2
      pages/home/register.vue
  2. 6
      pages/purchase/agrProdList.vue
  3. 10
      pages/purchase/specs.vue
  4. 122
      pages/stock/agrWarehouse.vue
  5. 11
      pages/stock/mana.vue

2
pages/home/register.vue

@ -36,7 +36,7 @@
</view> </view>
</template> </template>
<script> <script>
import request from '@/common/request.js' import request from '@/common/request'
export default { export default {
data(){ data(){
return{ return{

6
pages/purchase/agrProdList.vue

@ -84,9 +84,11 @@ export default {
list:[], list:[],
total:0, total:0,
eventChannel:null, eventChannel:null,
mode:"",
} }
}, },
onLoad(){ onLoad(options){
this.mode=options.mode||'purchase'
this.eventChannel=this.getOpenerEventChannel() this.eventChannel=this.getOpenerEventChannel()
this.search() this.search()
}, },
@ -123,7 +125,7 @@ export default {
}, },
toAddSepc(e){ toAddSepc(e){
uni.navigateTo({ uni.navigateTo({
url:`/pages/purchase/specs?goodsId=${e.id}`, url:`/pages/purchase/specs?goodsId=${e.id}&mode=${this.mode}`,
events:{submit: e=>{ events:{submit: e=>{
uni.navigateBack() uni.navigateBack()
this.eventChannel.emit("submit",e) this.eventChannel.emit("submit",e)

10
pages/purchase/specs.vue

@ -182,7 +182,7 @@
<view class="tip" v-if="specStr">库存{{specStr}}</view> <view class="tip" v-if="specStr">库存{{specStr}}</view>
</view> </view>
<view class="card purchase"> <view class="card purchase" v-if="mode=='purchase'">
<view class="title_mast">采购数量</view> <view class="title_mast">采购数量</view>
<view class="input"> <view class="input">
<input placeholder="请输入采购数量" type="digit" v-model="formData.num"/> <input placeholder="请输入采购数量" type="digit" v-model="formData.num"/>
@ -226,9 +226,11 @@ export default{
goodsDetail:{}, goodsDetail:{},
eventChannel:null, eventChannel:null,
mode:"",
} }
}, },
async onLoad(options){ async onLoad(options){
this.mode=options.mode
this.eventChannel=this.getOpenerEventChannel() this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("detail", detail=>{ this.eventChannel.on("detail", detail=>{
this.formData.goodsName=detail.goodsName this.formData.goodsName=detail.goodsName
@ -237,7 +239,8 @@ export default{
this.formData.supplier=detail.supplier this.formData.supplier=detail.supplier
}) })
this.formData.goodsId=options.goodsId this.formData.goodsId=options.goodsId
this.setGoodsVal() //
if(this.mode=='purchase')this.setGoodsVal()
}, },
methods:{ methods:{
async setGoodsVal(val){ async setGoodsVal(val){
@ -279,6 +282,7 @@ export default{
this.specList[0].push({label:e.goodsSpecification,value:e.goodsSpecification,id:e.goodsSpecificationId}) this.specList[0].push({label:e.goodsSpecification,value:e.goodsSpecification,id:e.goodsSpecificationId})
this.searchStock(e.goodsSpecificationId) this.searchStock(e.goodsSpecificationId)
this.formData.goodsSpecification=e.goodsSpecification this.formData.goodsSpecification=e.goodsSpecification
this.formData.specificationId=e.goodsSpecificationId
}} }}
}) })
}, },
@ -286,7 +290,7 @@ export default{
if(!this.formData.goodsSpecification){ if(!this.formData.goodsSpecification){
uni.showToast({title:"规格必选!",icon:"none"}) uni.showToast({title:"规格必选!",icon:"none"})
return false return false
}else if(!this.formData.num>0){ }else if(!this.formData.num>0 && this.mode=="purchase"){
uni.showToast({title:"采购数量必填!",icon:"none"}) uni.showToast({title:"采购数量必填!",icon:"none"})
return false return false
} }

122
pages/stock/agrWarehouse.vue

@ -61,16 +61,16 @@
<template> <template>
<view class="container" :class="{agr:!isAgr}"> <view class="container" :class="{agr:!isAgr}">
<d-navbar text="农资入库" isBack style="--bg:#10C176;--c:#fff;"> <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> </d-navbar>
<view class="agrInfo card" v-if="isAgr"> <view class="agrInfo card" v-if="isAgr">
<view class="data"> <text>化肥</text><text class="over">中量元素水溶肥</text><text class="plant-jiantou_zuoyouqiehuan"/> </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;">云南云天化股份有限公司</view> <view style="color:#707070;font-size:20rpx;">{{agrDetail.supplier}}</view>
</view> </view>
<u-form class="inline" :class="{card:isAgr}" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto"> <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"> <template v-for="(v,k) in fields">
<d-form <d-form
v-if="!v.agr ||v.agr&&isAgr" v-if="!v.agr ||v.agr&&isAgr"
@ -78,40 +78,122 @@
v-bind="v" v-bind="v"
:field="k" :field="k"
:required="!!rules[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> </template>
</u-form> </u-form>
</view> </view>
</template> </template>
<script> <script>
import request from '@/common/request'
export default{ export default{
data(){ data(){
return{ return{
fields:{ fields:{
scpect:{label:"规格", type:"select", columns:[[]],value:[],agr:true}, specName:{label:"规格", disabled:true, agr:true},
num:{label:"入库数量", type:"number",suffix:"袋", tip:"共计:40kg",agr:true}, number:{label:"入库数量", type:"digit",suffix:"袋", tip:"",agr:true},
type:{label:"入库类型"}, inOutBatchNo:{label:"入库批次号",agr:true, btnText:"生成", btnFun:()=>this.formData.inOutBatchNo=`RK${new Date().format('yyyyMMdd')}${new Date().getTime()}`},
date:{label:"入库时间"}, inOutType:{label:"入库类型",type:"select",columns:[],value:[]},
imgs:{label:"单据、凭证图片",type:"upImg",value:''}, operateTime:{label:"入库时间",type:"calendar"},
remarks:{label:"备注",type:"textarea"}, pic:{label:"单据、凭证图片",type:"upImg",value:''},
remark:{label:"备注",type:"textarea"},
}, },
formData:{ formData:{
type:"", specName:"",
date:"", specId:"",
imgs:[], number:"",
remarks:"", inOutBatchNo:'',
inOutType:"",
operateTime:"",
pic:[],
remark:"",
}, },
rules:{ rules:{
type:{required:true}, number:{required:true,type:"number", message:"入库数量必填!"},
date:{required:true}, inOutBatchNo:{required:true, message:"入库批次号必填!"},
imgs:{required:true}, inOutType:{required:true, message:"入库类型必选!"},
operateTime:{required:true, message:"入库时间必选!"},
}, },
agrDetail:{},//
isAgr: false, 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:{ 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> </script>

11
pages/stock/mana.vue

@ -149,7 +149,7 @@
</view> </view>
<u-empty v-if="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/> <u-empty v-if="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/>
</scroll-view> </scroll-view>
<button class="cu-btn round bg-green shadow submit" @click="$u.route({url:'/pages/stock/agrWarehouse'})">+农资入库</button> <button class="cu-btn round bg-green shadow submit" @click="toAgrIn">+农资入库</button>
</view> </view>
</template> </template>
<script> <script>
@ -208,6 +208,15 @@ export default {
} }
}) })
}, },
toAgrIn(){
uni.navigateTo({
url:"/pages/stock/agrWarehouse",
events:{update: ()=>{
this.clean()
this.search()
}}
})
},
} }
} }
</script> </script>
Loading…
Cancel
Save