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.
271 lines
7.6 KiB
271 lines
7.6 KiB
<style lang="scss">
|
|
.container{
|
|
min-height:100%;
|
|
background:#f6f6f6;
|
|
padding:30rpx 0;
|
|
|
|
.info{
|
|
margin-top:0;
|
|
.name{
|
|
display:flex;
|
|
align-items: center;
|
|
text{
|
|
&:first-child{
|
|
color:#fff;
|
|
background:#10C176;
|
|
border-radius: 0 20rpx 0 20rpx;
|
|
padding:0 6rpx;
|
|
font-size:20rpx;
|
|
height:40rpx;
|
|
line-height: 40rpx;
|
|
margin-right: 20rpx;
|
|
}
|
|
}
|
|
}
|
|
.tip{
|
|
display:flex;
|
|
align-items: center;
|
|
margin-top:6rpx;
|
|
text{
|
|
&:first-child{
|
|
color:#FBA83C;
|
|
font-size:24rpx;
|
|
margin-right:auto;
|
|
}
|
|
&:nth-child(2){
|
|
color:#999;
|
|
font-size:20rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.card{
|
|
.d-form /deep/{
|
|
&>.u-form-item{
|
|
position:relative;
|
|
.u-form-item__body__right__message{
|
|
position:absolute;
|
|
bottom:-10rpx;
|
|
}
|
|
}
|
|
}
|
|
&.prod{
|
|
.plant-dikuaimianji{
|
|
display:flex;
|
|
align-items: center;
|
|
font-weight: bold;
|
|
margin-bottom:20rpx;
|
|
&:before{
|
|
color:#10C176;
|
|
font-weight: normal;
|
|
margin-right:10rpx;
|
|
}
|
|
}
|
|
.item{
|
|
display:flex;
|
|
align-items: center;
|
|
background:#EEFBF5;
|
|
padding:30rpx;
|
|
border-radius: 24rpx;
|
|
.tab{
|
|
font-size:20rpx;
|
|
background:#10C176;
|
|
color:#fff;
|
|
border-radius: 4rpx 40rpx 4rpx 40rpx;
|
|
padding:4rpx 20rpx;
|
|
margin-right:20rpx;
|
|
}
|
|
.name{
|
|
font-weight: bold;
|
|
margin-right:20rpx;
|
|
}
|
|
.weight{
|
|
color:#10C176;
|
|
font-weight: bold;
|
|
margin-left:auto;
|
|
}
|
|
}
|
|
&>button{
|
|
display:flex;
|
|
background:#10C176;
|
|
width:80%;
|
|
margin:60rpx auto 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
<template>
|
|
<view class="container">
|
|
<d-navbar style="--bg:#10C176;--c:#fff;" isBack text="交易信息">
|
|
<button slot="right" class="cu-btn round" @click="submit">提交</button>
|
|
</d-navbar>
|
|
|
|
<view class="card info">
|
|
<view class="name">
|
|
<text>{{detail.plantTypeName}}</text> <text>{{detail.plantName}}</text>
|
|
</view>
|
|
<view class="tip">
|
|
<text>提示:当前可交易重量{{detail.harvestNum||0}}kg</text> <text>采收日期:{{detail.harvestTime}}</text>
|
|
</view>
|
|
</view>
|
|
<view class="card">
|
|
<u-form class="inline" :model="formData" ref="form" :rules="rules" labelWidth="auto">
|
|
<!-- <d-form label="交易重量" required field="tradeWeight" type="digit" suffix="kg" :value="formData.tradeWeight" @input="formData.tradeWeight=$event"/>
|
|
|
|
<view style="display:flex;align-items: center;">
|
|
<d-form label="规格" required field="specification" type="digit" suffix="kg" :value="formData.specification" @input="formData.specification=$event"/>
|
|
<text style="margin:45rpx 20rpx 0 20rpx;">/</text>
|
|
<d-form style="width:max-content;margin-top:40rpx;" 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"/> -->
|
|
<d-form
|
|
v-for="(v,k) in fields" :key="k"
|
|
:field="k"
|
|
v-bind="v"
|
|
:required="!!rules[k]"
|
|
:value="/^select$/.test(v.type)?fields[k].value:formData[k]"
|
|
@input="formData[k]=$event"
|
|
@select="fields[k].value=$event.map(v=>v.value);formData[k]=fields[k].value.slice(-1)[0]"/>
|
|
</u-form>
|
|
</view>
|
|
<view style="color:#FBA83C;margin:40rpx auto;width:max-content;">+添加采收详情</view>
|
|
<view class="card prod">
|
|
<view class="plant-dikuaimianji">林下三七1号基地</view>
|
|
<view class="item">
|
|
<text class="tab">外采</text>
|
|
<text class="name over">三七(A12263664)</text>
|
|
<text class="weight">23kg</text>
|
|
</view>
|
|
<button class="cu-btn round bg-green shadow" @click="sumbit">+继续添加</button>
|
|
</view>
|
|
|
|
<!-- <button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button> -->
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import request from '@/common/request'
|
|
export default {
|
|
data(){
|
|
return{
|
|
buyerType:{list:[],value:[]},
|
|
packWeightList:[],
|
|
detail:{},
|
|
|
|
fields:{
|
|
weight:{label:"交易重量",type:'digit',suffix:"kg"},
|
|
date:{label:"交易日期",type:"calendar"},
|
|
buyerName:{label:"买方名称"},
|
|
buyerType:{label:"买方类型",type:"select",columns:[],value:[]},
|
|
buyerAddress:{label:"收货地址",type:"textarea"},
|
|
},
|
|
formData:{
|
|
harvestId:"",
|
|
tradeWeight:"",
|
|
specification:"",
|
|
packUnit:"",
|
|
tradeNum:"",
|
|
buyerName:"",
|
|
buyerType:"",
|
|
buyerAddress:"",
|
|
},
|
|
rules:{
|
|
tradeWeight:{required:true,validator:(rule,val,call)=>{
|
|
if(!(val>0))call(new Error('交易重量必填!'));
|
|
else if(val>this.detail.harvestNum)call(new Error(`交易重量不能大于可交易重量${this.detail.harvestNum}!`));
|
|
else call()
|
|
},trigger:["blur","change"]},
|
|
specification:{required:true,type:'number',message:"规格必填!",trigger:["blur","change"]},
|
|
// tradeNum:{required:true,message:"交易数量必填!",type:"number"},
|
|
buyerName:{required:true,message:"买方名称必填!",trigger:["blur","change"]},
|
|
buyerType:{required:true,message:"交易类型必选!",trigger:["blur","change"]},
|
|
buyerAddress:{required:true,message:"收货地址必填!",trigger:["blur","change"]},
|
|
},
|
|
eventChannel:null,
|
|
}
|
|
},
|
|
computed:{
|
|
tradeNum(){
|
|
return Math.round((parseFloat(this.formData.tradeWeight)/parseFloat(this.formData.specification)||0)*100)/100
|
|
},
|
|
},
|
|
onLoad(options){
|
|
this.eventChannel=this.getOpenerEventChannel()
|
|
this.eventChannel.on("detail", e=>{
|
|
this.detail=e
|
|
this.formData.harvestId=e.id
|
|
})
|
|
this.init()
|
|
},
|
|
methods:{
|
|
async init(){
|
|
//规格
|
|
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",
|
|
params:{code:"B08"}
|
|
})
|
|
if(res.statu){
|
|
this.buyerType.list=res.data
|
|
}else{
|
|
uni.showModal({
|
|
title:"提示",
|
|
content:res.msg||"获取买方类型选项失败!",
|
|
showCancel:false,
|
|
})
|
|
}
|
|
},
|
|
sumbit(){
|
|
this.$refs.form.validate().then(async valid=>{
|
|
if(valid){
|
|
var res=await request("/api/plantTrade/add",{
|
|
method:"post",
|
|
body: {
|
|
...this.formData,
|
|
tradeNum: this.tradeNum
|
|
}
|
|
})
|
|
if(res.statu){
|
|
uni.navigateBack()
|
|
this.eventChannel.emit("update")
|
|
}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.buyerType.value=e.buyerType
|
|
this.formData.buyerType=e.buyerType[1]
|
|
}}
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|