|
@ -2,8 +2,10 @@ |
|
|
.container{ |
|
|
.container{ |
|
|
min-height:100%; |
|
|
min-height:100%; |
|
|
background:#f6f6f6; |
|
|
background:#f6f6f6; |
|
|
|
|
|
padding:30rpx 0; |
|
|
|
|
|
|
|
|
.info{ |
|
|
.info{ |
|
|
|
|
|
margin-top:0; |
|
|
.name{ |
|
|
.name{ |
|
|
display:flex; |
|
|
display:flex; |
|
|
align-items: center; |
|
|
align-items: center; |
|
@ -43,47 +45,122 @@ |
|
|
<view class="container"> |
|
|
<view class="container"> |
|
|
<view class="card info"> |
|
|
<view class="card info"> |
|
|
<view class="name"> |
|
|
<view class="name"> |
|
|
<text>蔬菜</text> <text>精品小黄瓜</text> |
|
|
<text>{{detail.plantTypeName}}</text> <text>{{detail.plantName}}</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="tip"> |
|
|
<view class="tip"> |
|
|
<text>提示:当前可交易数量150kg</text> <text>采收日期:2022-12-26</text> |
|
|
<text>提示:当前可交易重量{{detail.harvestNum||0}}kg</text> <text>采收日期:{{detail.harvestTime}}</text> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="card"> |
|
|
<view class="card"> |
|
|
<u-form class="inline" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto"> |
|
|
<u-form class="inline" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto"> |
|
|
<d-form label="交易重量" type="digit" suffix="kg"/> |
|
|
<d-form label="交易重量" required field="tradeWeight" type="digit" suffix="kg" :value="formData.tradeWeight" @input="formData.tradeWeight=$event"/> |
|
|
<d-form label="规格" type="digit" suffix="kg"/> |
|
|
|
|
|
<view style="display:flex;align-items: center;"> |
|
|
<view style="display:flex;align-items: center;"> |
|
|
<d-form label="交易数量" type="digit" suffix="袋"/> |
|
|
<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> |
|
|
<text style="margin:45rpx 20rpx 0 20rpx;">/</text> |
|
|
<d-form style="width:max-content;margin-top:40rpx;" type="select" placeholder=" " :columns="[]" :value="[]"/> |
|
|
<d-form style="width:max-content;margin-top:40rpx;" type="select" placeholder=" " @select="formData.packUnit=$event.value[0].value" :columns="[packWeightList]" :value="[formData.packUnit]"/> |
|
|
</view> |
|
|
</view> |
|
|
<d-form label="买方名称"/> |
|
|
<d-form label="交易数量" type="digit" suffix="袋" required field="tradeNum" :value="formData.tradeNum" @input="formData.tradeNum=$event"/> |
|
|
<d-form label="买方类型" type="select" :columns="[]" :value="[]"/> |
|
|
<d-form label="买方名称" required field="buyerName" :value="formData.buyerName" @input="formData.buyerName=$event"/> |
|
|
<d-form label="收货地址" type="textarea"/> |
|
|
<d-form label="买方类型" required field="buyerType" type="select" :columns="[buyerType.list]" :value="buyerType.value" @select="buyerType.value=$event.value.map(v=>v.value);formData.buyerType=buyerType.value[1]"/> |
|
|
|
|
|
<d-form label="收货地址" required field="buyerAddress" type="textarea" :value="formData.buyerAddress" @input="formData.buyerAddress=$event"/> |
|
|
</u-form> |
|
|
</u-form> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import request from '@/common/request' |
|
|
export default { |
|
|
export default { |
|
|
data(){ |
|
|
data(){ |
|
|
return{ |
|
|
return{ |
|
|
fields:{ |
|
|
buyerType:{list:[],value:[]}, |
|
|
weidth:{label:"交易重量",type:"digit",suffix:"kg"}, |
|
|
packWeightList:[], |
|
|
spcs:{label:"规格",type:"digit",suffix:"kg"}, |
|
|
detail:{}, |
|
|
num:{label:"交易数量",type:"digit",suffix:"袋", selectField:"sdf", columns:[]}, |
|
|
|
|
|
name:{label:"买方名称"}, |
|
|
|
|
|
type:{label:"买方类型",type:'select',columns:[],value:[]}, |
|
|
|
|
|
adder:{label:"收货地址",type:"textarea"} |
|
|
|
|
|
}, |
|
|
|
|
|
formData:{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formData:{ |
|
|
|
|
|
harvestId:"", |
|
|
|
|
|
tradeWeight:"", |
|
|
|
|
|
specification:"", |
|
|
|
|
|
packUnit:"", |
|
|
|
|
|
tradeNum:"", |
|
|
|
|
|
buyerName:"", |
|
|
|
|
|
buyerType:"", |
|
|
|
|
|
buyerAddress:"", |
|
|
}, |
|
|
}, |
|
|
rules:{ |
|
|
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() |
|
|
|
|
|
}}, |
|
|
|
|
|
specification:{required:true,message:"规格必填!"}, |
|
|
|
|
|
tradeNum:{required:true,message:"交易数量必填!",type:"number"}, |
|
|
|
|
|
buyerName:{required:true,message:"买方名称必填!"}, |
|
|
|
|
|
buyerType:{required:true,message:"交易类型必选!"}, |
|
|
|
|
|
buyerAddress:{required:true,message:"收货地址必填!"}, |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
onLoad(options){ |
|
|
|
|
|
var eventChannel=this.getOpenerEventChannel() |
|
|
|
|
|
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 |
|
|
|
|
|
}) |
|
|
|
|
|
if(res.statu){ |
|
|
|
|
|
uni.navigateBack() |
|
|
|
|
|
}else{ |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title:"提示", |
|
|
|
|
|
content:res.msg||"保存失败!", |
|
|
|
|
|
showCancel:false, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |