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>
</template>
<script>
import request from '@/common/request.js'
import request from '@/common/request'
export default {
data(){
return{

6
pages/purchase/agrProdList.vue

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

10
pages/purchase/specs.vue

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

122
pages/stock/agrWarehouse.vue

@ -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>

11
pages/stock/mana.vue

@ -149,7 +149,7 @@
</view>
<u-empty v-if="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/>
</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>
</template>
<script>
@ -208,6 +208,15 @@ export default {
}
})
},
toAgrIn(){
uni.navigateTo({
url:"/pages/stock/agrWarehouse",
events:{update: ()=>{
this.clean()
this.search()
}}
})
},
}
}
</script>
Loading…
Cancel
Save