Browse Source

联调 新增交易接口

master
邓宏 2 years ago
parent
commit
44b03453df
  1. 115
      pages/massif/add_transaction.vue
  2. 10
      pages/massif/mana/recovery.vue

115
pages/massif/add_transaction.vue

@ -2,8 +2,10 @@
.container{
min-height:100%;
background:#f6f6f6;
padding:30rpx 0;
.info{
margin-top:0;
.name{
display:flex;
align-items: center;
@ -43,47 +45,122 @@
<view class="container">
<view class="card info">
<view class="name">
<text>蔬菜</text> <text>精品小黄瓜</text>
<text>{{detail.plantTypeName}}</text> <text>{{detail.plantName}}</text>
</view>
<view class="tip">
<text>提示当前可交易数量150kg</text> <text>采收日期2022-12-26</text>
<text>提示当前可交易重量{{detail.harvestNum||0}}kg</text> <text>采收日期{{detail.harvestTime}}</text>
</view>
</view>
<view class="card">
<u-form class="inline" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto">
<d-form label="交易重量" type="digit" suffix="kg"/>
<d-form label="规格" type="digit" suffix="kg"/>
<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="交易数量" 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>
<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>
<d-form label="买方名称"/>
<d-form label="买方类型" type="select" :columns="[]" :value="[]"/>
<d-form label="收货地址" type="textarea"/>
<d-form label="交易数量" type="digit" suffix="袋" required field="tradeNum" :value="formData.tradeNum" @input="formData.tradeNum=$event"/>
<d-form label="买方名称" required field="buyerName" :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.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>
</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{
fields:{
weidth:{label:"交易重量",type:"digit",suffix:"kg"},
spcs:{label:"规格",type:"digit",suffix:"kg"},
num:{label:"交易数量",type:"digit",suffix:"袋", selectField:"sdf", columns:[]},
name:{label:"买方名称"},
type:{label:"买方类型",type:'select',columns:[],value:[]},
adder:{label:"收货地址",type:"textarea"}
},
formData:{
buyerType:{list:[],value:[]},
packWeightList:[],
detail:{},
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()
}},
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>

10
pages/massif/mana/recovery.vue

@ -118,7 +118,7 @@
<view class="info">
<text class="people">负责人:{{v.principal}}</text>
<text class="date">采收日期:{{v.harvestTime}}</text>
<text class="plant-jinrongjiaoyi" @click="$u.route({url:'/pages/massif/add_transaction'})">交易</text>
<text class="plant-jinrongjiaoyi" @click="toAddTransaction(v)">交易</text>
</view>
</view>
</view>
@ -202,6 +202,14 @@ export default {
}
}
},
toAddTransaction(e){
uni.navigateTo({
url:"/pages/massif/add_transaction",
success(res){
res.eventChannel.emit('detail',e)
}
})
},
}
}
</script>
Loading…
Cancel
Save