邓宏
2 years ago
2 changed files with 142 additions and 1 deletions
@ -0,0 +1,138 @@ |
|||||
|
<style lang="scss"> |
||||
|
.container{ |
||||
|
min-height: 100%; |
||||
|
padding:30rpx; |
||||
|
} |
||||
|
</style> |
||||
|
<template> |
||||
|
<view class="container"> |
||||
|
<d-navbar text="农产品入库" isBack style="--bg:#10C176;--c:#fff;"> |
||||
|
<button slot="right" class="cu-btn round" @click="submit">提交</button> |
||||
|
</d-navbar> |
||||
|
|
||||
|
<u-form class="inline" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto"> |
||||
|
<d-form |
||||
|
v-for="(v,k) in fields" :key="k" |
||||
|
v-bind="v" |
||||
|
:field="k" |
||||
|
:required="!!rules[k]" |
||||
|
:value="/^select$/.test(v.type)?fields[k].value:formData[k]" |
||||
|
@input="formData[k]=$event" |
||||
|
@select="formData[k]=$event.value.at(-1).value;fields[k].value=$event.value.map(v=>v.value)" |
||||
|
@imgs="fields[k].value=$event"/> |
||||
|
</u-form> |
||||
|
</view> |
||||
|
</template> |
||||
|
<script> |
||||
|
import request from '@/common/request' |
||||
|
export default { |
||||
|
data(){ |
||||
|
return{ |
||||
|
fields:{ |
||||
|
inOutType:{label:"入库类型",type:"select",columns:[],value:[]}, |
||||
|
varietyName:{label:"名称"}, |
||||
|
number:{label:"入库数量"}, |
||||
|
detailType:{label:"作物类型",type:"select",columns:[[]],value:[]}, |
||||
|
operateTime:{label:"入库时间",type:"calendar"}, |
||||
|
pic:{label:"单据、凭证图片",type:"upImg",value:""}, |
||||
|
warehouseId:{label:"仓库",type:"select",columns:[],value:[]}, |
||||
|
remark:{label:"备注"}, |
||||
|
}, |
||||
|
formData:{ |
||||
|
enterpriseId: this.$store.getters['userInfo'].companyId, |
||||
|
varietyName:"", |
||||
|
inOutType:"", |
||||
|
number:"", |
||||
|
detailType:"", |
||||
|
operateTime:"", |
||||
|
pic:[], |
||||
|
warehouseId:"", |
||||
|
remark:"", |
||||
|
|
||||
|
substanceType:2, |
||||
|
}, |
||||
|
rules:{ |
||||
|
inOutType:{required:true,message:"入库类型必选!"}, |
||||
|
varietyName:{required:true,message:"名称必填!"}, |
||||
|
number:{required:true,message:"入库数量必填!"}, |
||||
|
detailType:{required:true,message:"作物类型必选!"}, |
||||
|
operateTime:{required:true,message:"入库时间必选"}, |
||||
|
warehouseId:{required:true,message:"仓库必选!"}, |
||||
|
}, |
||||
|
eventChannel:null, |
||||
|
} |
||||
|
}, |
||||
|
onLoad(){ |
||||
|
this.eventChannel=this.getOpenerEventChannel() |
||||
|
this.init() |
||||
|
}, |
||||
|
methods:{ |
||||
|
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, |
||||
|
}) |
||||
|
} |
||||
|
//仓库下拉选项 |
||||
|
var res=await request("/api/WarehouseManageApi/queryWarehouseByBaseId",{ |
||||
|
params:{baseId: this.$store.state.plantBaseInfoId} |
||||
|
}) |
||||
|
if(res.statu){ |
||||
|
this.fields.warehouseId.columns=[res.data] |
||||
|
}else{ |
||||
|
uni.showModal({ |
||||
|
title:"提示", |
||||
|
content:res.msg||"获取仓库选项失败!", |
||||
|
showCancel:false, |
||||
|
}) |
||||
|
} |
||||
|
//植物类型 |
||||
|
var res=await request("/common/api/dict/categoryValue",{ |
||||
|
method:"post", |
||||
|
params:{code:"B06"} |
||||
|
}) |
||||
|
if(res.statu){ |
||||
|
this.fields.detailType.columns=[res.data] |
||||
|
}else{ |
||||
|
uni.showModal({ |
||||
|
title:"提示", |
||||
|
content:res.msg||"获取作物类型下拉选项失败!", |
||||
|
showCancel:false, |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
submit(){ |
||||
|
this.$refs.form.validate().then(async valid=>{ |
||||
|
if(valid){ |
||||
|
var res=await request("/api/Inventory/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> |
Loading…
Reference in new issue