You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

433 lines
14 KiB

2 years ago
<style lang="scss">
2 years ago
.container{
2 years ago
min-height: 100%;
background:#F6F6F6;
padding:30rpx 0;
.card{
margin-top:0;
2 years ago
&>.title{
display:flex;
align-items: center;
justify-content: space-between;
text:nth-child(2){
color:#777;
}
}
.d-form /deep/{
&>.u-form-item{
position:relative;
.u-form-item__body__right__message{
position:absolute;
bottom:-10rpx;
}
}
}
2 years ago
}
&>.fertilizer{
&>.name{
display:flex;
align-items: center;
margin-bottom:14rpx;
text{
&:first-child{
font-size:20rpx;
color:#fff;
background:#10C176;
2 years ago
border-radius: 7rpx;
min-width:80rpx;
padding:0 6rpx;
2 years ago
text-align: center;
height:40rpx;
line-height: 40rpx;
margin-right:16rpx;
2 years ago
box-sizing: border-box;
2 years ago
}
&:nth-child(3){
border-radius: 50%;
background:#10C176;
color:#fff;
margin-left:auto;
width:35rpx;
height:35rpx;
text-align: center;
line-height: 35rpx;
}
}
}
&>.company{
display:flex;
align-items: center;
text{
&.type{
2 years ago
flex-shrink: 0;
font-size:20rpx;
2 years ago
color:#FBA83C;
2 years ago
}
&.name{
2 years ago
margin-left:20rpx;
2 years ago
font-size:20rpx;
2 years ago
color:#707070;
2 years ago
}
&.specs{
margin-left:auto;
}
2 years ago
}
}
}
&>.specs{
.select{
flex-grow: 1;
height:80rpx;
line-height: 80rpx;
background:#F7F7F7;
border-radius: 24rpx;
padding:0 28rpx;
display:flex;
text{
color:#999;
&:first-child{
flex-grow: 1;
}
&:nth-child(2){
flex-shrink: 0;
transform: rotate(90deg);
}
}
}
.plant-xinjian{
color:#10C176;
border-radius: 24rpx;
margin-left:24rpx;
background:#E7FCF3;
height:80rpx;
line-height: 80rpx;
width:120rpx;
text-align: center;
box-shadow: 6rpx 6rpx 8rpx rgba(16,193,118,0.1);
}
.tip{
color:#FBA83C;
font-size:24rpx;
margin-top:12rpx;
}
}
&>.purchase{
.input{
display:flex;
background:#F7F7F7;
border-radius: 24rpx;
padding:20rpx;
input{
flex-grow: 1;
}
text{
color:#999;
line-height: 40rpx;
margin-left:20rpx;
}
}
}
}
</style>
<template>
2 years ago
<view class="container">
2 years ago
<view class="card fertilizer">
<view class="name">
2 years ago
<text>{{detail.agriculturalGoods}}</text>
<text>{{detail.substanceName}}</text>
2 years ago
<!-- <text class="plant-jiantou_zuoyouqiehuan" @click="$refs.dPicker.show=true"/> -->
2 years ago
</view>
<view class="company">
<text class="type">{{detail.detailType}}</text>
<text v-if="formData.substanceType==1" class="name">{{detail.supplierName}}</text>
<text v-else-if="recoveryBatch.list.length<=0" class="specs">{{detail.equivalentInventory}}{{detail.unit}}</text>
2 years ago
</view>
</view>
<view class="card specs" v-if="formData.substanceType==1">
2 years ago
<view class="title">
<text>规格</text> <text>{{detail.specDescribe}}</text>
2 years ago
</view>
<view class="tip">库存{{detail.equivalentInventory}}{{detail.packgeUnit}}({{detail.equivalentInventory*detail.unitNum}}{{detail.unit}})</view>
2 years ago
</view>
2 years ago
2 years ago
<view class="card">
<u-form class="inline" :model="formData" ref="form" :rules="rules" labelWidth="auto">
<d-form
v-if="recoveryBatch.list.length>0" label="采收批次" field="inInventoryBatch" required type="select" :columns="recoveryBatch.list" custom
:tip="recoveryBatch.surplus>0?`剩余:${recoveryBatch.surplus}kg`:''"
:value="recoveryBatch.value"
@select="recoveryBatch.value=[$event[0].value];formData.inOutBatchNo=$event[0].batchNo;recoveryBatch.number=$event[0].surplus;recoveryBatch.surplus=$event[0].surplus;formData.inInventoryBatch=recoveryBatch.value.slice(-1)[0]">
<view slot-scope="{row}" style="display:flex;">
<text style="margin-left:10rpx;font-weight:bold;">{{row.batchNo}}</text>
<text style="font-size:24rpx;color:#999;margin-left:10rpx;">{{row.substanceName}}</text>
<text style="margin-left:auto;color:#999;">剩余:{{row.surplus}}</text>
</view>
</d-form>
<d-form :label="`${({in:'入',out:'出'})[mode]}库类型`" field="inOutType" required type="select" :columns="inOutType.list" :value="inOutType.value" @select="inOutType.value=$event.map(v=>v.value);formData.inOutType=inOutType.value.slice(-1)[0]"/>
<!-- 农资出库出库类型为损坏出库 -->
<block v-if="formData.substanceType==1&&formData.inOutType=='out02'">
<d-form label="采购单价" type='digit' v-model="formData.price" required field="price"/>
<d-form label="处理方式" type="select" :columns="[processMode]" :value="[formData.processMode]" @select="formData.processMode=$event[0].value" required field="processMode"/>
</block>
<!-- 农产品出库 出库类型为损坏出库-->
<block v-else-if="formData.substanceType==2&&formData.inOutType=='out03'">
<d-form label="损坏原因" type="select" :columns="[damageReason]" :value="formData.damageReason" @select="formData.damageReason=$event[0].value" required field="damageReason"/>
<d-form label="折价率" type="digit" v-model="formData.rateDiscount" required field="rateDiscount"/>
<d-form label="金额" type="digit" v-model="formData.amount" required field="amount"/>
</block>
<d-form :label="`${({in:'入',out:'出'})[mode]}库批次号`" field="inOutBatchNo" required :disabled="formData.substanceType==2" :value="formData.inOutBatchNo" @input="formData.inOutBatchNo=$event" :btnText="formData.substanceType==1?'生成':''" :btnFun="()=>this.formData.inOutBatchNo=`${({in:'RK',out:'CK'})[this.mode]}${new Date().format('yyyyMMdd')}${new Date().getTime()}`"/>
<d-form :label="({1:`${({in:'入',out:'出'})[mode]}库数量`,2:'重量'})[formData.substanceType]" field="number" required :suffix="number.suffix" :value="formData.number" @input="formData.number=$event" type="digit"/>
<d-form label="操作日期" field="operationTime" required type="calendar" v-model="formData.operateTime"/>
<template v-if="formData.substanceType==2&&formData.inOutType=='out01'&&recoveryBatch.list.length>0">
<view style="display:flex;margin:-20rpx 0;">
<d-form label="规格" required field="specification" type="digit" suffix="kg" :value="formData.specification" @input="formData.specification=$event"/>
<text style="margin:90rpx 20rpx 0 20rpx;">/</text>
<d-form style="width:max-content;margin-top:62rpx;" type="select" placeholder=" " @select="formData.packUnit=$event[0].value" :columns="[packWeightList]" :value="[formData.packUnit]"/>
</view>
<d-form label="交易数量" disabled type="digit" :suffix="formData.packUnit" :value="tradeNum"/>
<d-form label="买方名称" required field="buyerName" btnIcon="plant-sousuo" :btnFun="searchBuy" :value="formData.buyerName" @input="formData.buyerName=$event"/>
<d-form label="买方类型" required field="buyerType" type="select" :columns="[buyerType.list]" :value="buyerType.value" @select="buyerType.value=$event.map(v=>v.value);formData.buyerType=buyerType.value[1]"/>
<d-form label="收货地址" required field="buyerAddress" type="textarea" :value="formData.buyerAddress" @input="formData.buyerAddress=$event"/>
</template>
<d-form :label="`${({in:'入',out:'出'})[mode]}库凭证`" type="upImg" :num="3" :value="formData.pic" @imgs="pic=$event"/>
2 years ago
</u-form>
2 years ago
</view>
2 years ago
<button class="cu-btn round bg-green shadow submit" @click="submit">确定</button>
2 years ago
</view>
</template>
<script>
import request from '@/common/request'
2 years ago
export default{
2 years ago
data(){
return{
mode:"",
2 years ago
detail:{},
2 years ago
recoveryBatch:{list:[],value:[],number:0,surplus:0},
inOutType:{list:[],value:[]},
pic:"",
number:{suffix:""},
buyerType:{list:[],value:[]},
packWeightList:[],
processMode:[],//处理方式
damageReason:[],//损坏原因
2 years ago
formData:{
inInventoryBatch:"",
2 years ago
inOutType:"",
goodsId:"",
inOutBatchNo:"",
pic:[],
2 years ago
number:"",
substanceType:"",
operateTime:"",
tradeWeight:"",
specification:"",
packUnit:"",
tradeNum:"",
buyerType:"",
buyerAddress:"",
price:"",
processMode:"",
damageReason:"",
rateDiscount:"",
amount:"",
2 years ago
},
rules:{
inInventoryBatch:{required:true,message:"请选择采收批次!",trigger:['blur','change']},
inOutType:{required:true,validator:(rule,val,call)=>{
if(!val)call(new Error(`${({in:'入',out:'出'})[this.mode]}库类型必填!`));
else call()
},trigger:['blur','change']},
inOutBatchNo:{required:true,validator:(rule,val,call)=>{
if(!val)call(new Error(`${({in:'入',out:'出'})[this.mode]}库批次号必填!`));
else call()
},trigger:['blur','change']},
operateTime:{required:true,message:"请选择操作日期!",trigger:['blur','change']},
number:{required:true,validator:(rule,val,call)=>{
var title=({1:({in:'入',out:'出'})[this.mode],2:'交易重量'})[this.formData.substanceType]
if(!(val>0))call(new Error(`请输入${title}`));
else if(this.mode=='out' &&this.recoveryBatch.list<=0&& val>this.detail.equivalentInventory)call(new Error(`${title}不能大于剩余数量${this.detail.equivalentInventory}`));
else if(this.mode=='out' &&this.recoveryBatch.list>0&& val>this.recoveryBatch.number)call(new Error(`${title}不能大于剩余数量${this.recoveryBatch.number}`));
2 years ago
else call()
},type:"number",trigger:['blur','change']},
specification:{required:true,message:"规格必填!",type:"number",trigger:['blur','change']},
tradeNum:{required:true,message:"交易数量必填!",type:"number",trigger:['blur','change']},
buyerName:{required:true,message:"买方名称必填!",trigger:['blur','change']},
buyerType:{required:true,message:"交易类型必选!",trigger:['blur','change']},
buyerAddress:{required:true,message:"收货地址必填!",trigger:['blur','change']},
price:{required:true, type:"number", message:"请输入采购单价!",tigger:['blur','change']},
processMode:{required:true, message:"请输入处理方式!",tigger:['blur','change']},
damageReason:{required:true, message:"请选择损坏原因!",tigger:['blur','change']},
rateDiscount:{required:true, type:"number", message:"请输入折价率!",tigger:['blur','change']},
amount:{required:true, type:"number", message:"请输入金额!",tigger:['blur','change']},
2 years ago
},
mode:"",
eventChannel:null,
2 years ago
}
},
computed:{
tradeNum(){
return Math.round((parseFloat(this.formData.number)/parseFloat(this.formData.specification)||0)*100)/100
},
},
2 years ago
onLoad(options){
2 years ago
this.formData.substanceType = ({nz:1, ncp:2})[options.type],
2 years ago
this.mode=options.mode
uni.setNavigationBarTitle({
title:({out:"出库",in:"入库"})[this.mode]
2 years ago
})
this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("detail", e=>{
this.detail=e
if(this.formData.substanceType==1){
this.number.suffix=(e.specDescribe.match(/\/(.+)/)||['',''])[1]
}else{
this.number.suffix="kg"
this.searchStock(e.inventoryId)
}
this.formData.goodsId=e.goodsId
})
2 years ago
this.init()
},
methods:{
async searchStock(inventoryId){
var res=await request("/api/Inventory/queryInInventoryBatchRecord",{
params:{inventoryId}
})
if(res.statu){
this.recoveryBatch.list=res.data.length>0?[res.data.map(v=>({...v,label:v.substanceName,value:v.batchNo}))]:[]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取库存失败!",
showCancel:false,
})
}
},
2 years ago
async init(){
//出库类型
2 years ago
var res=await request("/common/api/dict/queryDictItemByDictCode",{
method:"post",
//农产品前面加上product_
params: {dictCode: (this.formData.substanceType=="2"?"product_":"")+({out:"out_type",in:"in_type"})[this.mode]}
})
if(res.statu){
this.inOutType.list=[res.data]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取出库类型选项失败!",
showCancel:false,
})
}
//规格
var res = await request("/common/api/dict/queryDictItemByDictCode",{
method:"post",
params:{dictCode:"dressing_unit"}
})
if(res.statu){
this.packWeightList=res.data
this.formData.packUnit=res.data[0].value
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取规格选项失败!",
showCancel:false,
})
}
//买方类型
var res = await request("/common/api/dict/categoryValue",{
method:"post",
body:{code:"B08"}
})
if(res.statu){
this.buyerType.list=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取买方类型选项失败!",
showCancel:false,
})
}
//处理方式
var res = await request("/common/api/dict/queryDictItemByDictCode",{
method:"post",
params:{dictCode:"process_mode"}
})
if(res.statu){
this.processMode=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取买方类型选项失败!",
showCancel:false,
})
}
//损坏原因
var res = await request("/common/api/dict/queryDictItemByDictCode",{
method:"post",
params:{dictCode:"damage_reason"}
})
if(res.statu){
this.damageReason=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取买方类型选项失败!",
showCancel:false,
})
}
},
2 years ago
submit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
var res=await request("/api/Inventory/inventoryOperate",{
2 years ago
method:"post",
body:{
...this.formData,
inventoryId: this.detail.inventoryId,
2 years ago
equivalentAmount: this.detail.equivalentInventory,
2 years ago
supplier: this.detail.supplierName,
pic:this.pic,
2 years ago
type: ({in:2, out:1})[this.mode],
tradeNum:this.tradeNum,
2 years ago
}
})
if(res.statu){
uni.navigateBack()
this.eventChannel.emit("update")
2 years ago
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败!",
showCancel:false,
})
}
}
})
},
searchBuy(){
uni.navigateTo({
url:`/pages/massif/search?data=${this.formData.buyerName||''}`,
events:{update:e=>{
this.formData.buyerName=e.buyerName
this.formData.buyerAddress=e.address
this.formData.buyerType=e.buyerType[1]
this.buyerType.value=e.buyerType
}}
})
},
2 years ago
},
2 years ago
}
</script>