This commit is contained in:
aihe 2024-06-02 16:37:54 +08:00
parent 668ec23924
commit 6aa83f599b
6 changed files with 93 additions and 47 deletions

View File

@ -15,23 +15,25 @@
</view> </view>
<view v-for="(item, index) in modelInfo.cargoList" class="yditem"> <view v-for="(item, index) in modelInfo.cargoList" class="yditem">
<view class="ydi-lab"> <view class="ydi-lab mb-10">
<text class="font-weight">{{item.goodsName}}</text> <text class="font-weight">
<!-- {{item.goodsName}} -->
</text>
<view> <view>
<u-icon @click="handleDelGood(index)" name="trash" size="32"></u-icon> <u-icon @click="handleDelGood(index)" name="trash" size="32"></u-icon>
</view> </view>
</view> </view>
<bpe-gooditem-filed-edit-tmp :value="item"></bpe-gooditem-filed-edit-tmp> <bpe-gooditem-filed-edit-tmp :value="item" :showMode="showMode" :submitVal="modelInfo"></bpe-gooditem-filed-edit-tmp>
</view> </view>
<!-- <u-button @click="handleAddGood" custom-style="border-radius: 16rpx;height: 66rpx;" type="primary" plain="true"> <u-button @click="handleAddGood" custom-style="border-radius: 16rpx;height: 66rpx;" type="primary" plain="true">
<u-row justify="center"> <u-row justify="center">
<view> <view>
<u-icon name="plus" size="30" color="#B12D29"></u-icon> <u-icon name="plus" size="30" color="#B12D29"></u-icon>
</view> </view>
<text class="pl-10">增加货物</text> <text class="pl-10">增加货物</text>
</u-row> </u-row>
</u-button> --> </u-button>
</template> </template>
@ -51,6 +53,25 @@
return this.$store.getters.dicData return this.$store.getters.dicData
} }
}, },
watch: {
'modelInfo.parcelQty': {
handler: function(newVal) {
let listQt = 0
let maxCaIndex
this.modelInfo.cargoList.map((t, i)=> {
listQt += (+t.cargoQty)
if(typeof maxCaIndex == 'undefined' && newVal < listQt) {
maxCaIndex = i
t.cargoQty = newVal - (listQt - t.cargoQty)
}
})
// 超出总数的 item,截取掉
if(typeof maxCaIndex != 'undefined') {
this.modelInfo.cargoList.splice(maxCaIndex + 1, this.modelInfo.cargoList.length -1 - maxCaIndex)
}
}
}
},
props: { props: {
value: { value: {
default () { default () {
@ -97,7 +118,8 @@
<style scoped lang="scss"> <style scoped lang="scss">
.yditem{ .yditem{
padding: 20rpx 20rpx; padding: 20rpx 20rpx;
background-color: #F6F6F6; // background-color: #F6F6F6;
background-color: #e1e1e1;
border-radius: 10rpx; border-radius: 10rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<view class="dt-block"> <view v-if="showMode!=1" class="dt-block" style="margin-bottom: 50rpx;">
<view class="dt-tle"> <view class="dt-tle">
<view class="com-section">热门物品</view> <view class="com-section">热门物品</view>
</view> </view>
@ -10,36 +10,31 @@
</view> </view>
</view> </view>
<view class="dt-block" style="margin-top: 50rpx;"> <view class="dt-block" >
<view class="dt-tle"> <view v-if="showMode!=1" class="dt-tle">
<view class="com-section">物品信息</view> <view class="com-section">物品信息</view>
<view> <view>
<!-- <u-button custom-style="font-size: 28rpx;height: 56rpx;border-radius: 16rpx;" plain="true" type="primary">选择历史</u-button> --> <!-- <u-button custom-style="font-size: 28rpx;height: 56rpx;border-radius: 16rpx;" plain="true" type="primary">选择历史</u-button> -->
</view> </view>
</view> </view>
<view class="dt-cont"> <view class="dt-cont">
<view class="edm-input-item"> <view v-if="showMode!=1" class="edm-input-item">
<tpx-select v-model:value="checkedGoodId" v-model:resObject="goodsRes" :getListFun="getGoodsList" :transKeyVal="{valKey: 'goodsName',titleKey: 'goodsName'}" <tpx-select v-model:value="checkedGoodId" v-model:resObject="goodsRes" :getListFun="getGoodsList" :transKeyVal="{valKey: 'goodsName',titleKey: 'goodsName'}"
mode="drop" @onChange="handleChooseGood" mode="drop" @onChange="handleChooseGood"
> >
<u-input placeholder="物品名称" v-model="modelInfo.goodsName" font-size="26" <tpx-input v-model:value="modelInfo.goodsName" placeholder="物品名称"></tpx-input>
custom-style="border-radius: 30rpx;padding: 10rpx 20rpx;"
placeholder-style="color: #999; "
></u-input>
</tpx-select> </tpx-select>
</view> </view>
<view class="edm-input-item"> <view class="edm-input-item">
<tpx-text-item label="物品数量"> <tpx-text-item label="物品数量">
<template v-slot:right> <template v-slot:right>
<tpx-input placeholder="请填写" v-model:value="modelInfo.cargoQty" inputAlign="right" type="number" suffix="件"></tpx-input> <tpx-input placeholder="请填写" v-model:value="modelInfo.cargoQty" inputAlign="right" type="number" suffix="件" :_maxNum="cargoQtyMaxNum"></tpx-input>
</template> </template>
</tpx-text-item> </tpx-text-item>
</view> </view>
<view>
</view>
<bpe-gooditemsize-tmp v-model:value="modelInfo"></bpe-gooditemsize-tmp> <bpe-gooditemsize-tmp v-model:value="modelInfo"></bpe-gooditemsize-tmp>
<view v-if="showMode!=1"> <view v-if="showMode!=1">
@ -136,24 +131,31 @@
return this.value return this.value
} }
}, },
cargoQtyMaxNum(){
// 限制数量的最大值
let { cargoList, parcelQty } = this.submitVal
let curQty = (+this.modelInfo.cargoQty) || 0
let qtMaxNum = parcelQty + curQty
cargoList.map(t=> {
if(t.cargoQty) {
qtMaxNum = qtMaxNum - t.cargoQty
}
})
if(qtMaxNum < 0) {
qtMaxNum = 0
}
return qtMaxNum
}
}, },
watch: { watch: {
show: {
handler: function(cval, oval) {
if(cval) {
this.modelInfo = JSON.parse(JSON.stringify(this.value || {}))
this.initData()
}
}
}
}, },
props: { props: {
show: { value: {
default () { default () {
return false return {}
} }
}, },
value: { submitVal: {
default () { default () {
return {} return {}
} }
@ -201,10 +203,7 @@
}, },
handleChooseGood(val) { handleChooseGood(val) {
const item = this.goodsRes.list.concat(this.hotGoods).filter(t=> t.val == val)[0] const item = this.goodsRes.list.concat(this.hotGoods).filter(t=> t.val == val)[0]
this.modelInfo = { Object.assign(this.modelInfo, item)
...this.modelInfo,
...item
}
} }
} }
} }
@ -215,7 +214,7 @@
padding: 10rpx 0 30rpx 0; padding: 10rpx 0 30rpx 0;
} }
.dt-block { .dt-block {
background-color: #FFF; // background-color: #FFF;
position: relative; position: relative;
} }
.dt-tle { .dt-tle {
@ -254,6 +253,6 @@
} }
.edm-input-item{ .edm-input-item{
padding: 8rpx 0; padding: 8rpx 0;
border-bottom: 2rpx solid #F6F6F6; // border-bottom: 2rpx solid #F6F6F6;
} }
</style> </style>

View File

@ -7,13 +7,13 @@
<view style="width: 70%;"> <view style="width: 70%;">
<u-row justify="between"> <u-row justify="between">
<u-col span="3.7"> <u-col span="3.7">
<tpx-input v-model:value="modelInfo.length" @change="calculateVplume" placeholder="长" inputAlign="right" suffix="cm" _digit="5"></tpx-input> <tpx-input v-model:value="modelInfo.length" placeholder="长" inputAlign="right" suffix="cm" _digit="5"></tpx-input>
</u-col> </u-col>
<u-col span="3.7"> <u-col span="3.7">
<tpx-input v-model:value="modelInfo.width" @change="calculateVplume" placeholder="宽" inputAlign="right" suffix="cm" _digit="5"></tpx-input> <tpx-input v-model:value="modelInfo.width" placeholder="宽" inputAlign="right" suffix="cm" _digit="5"></tpx-input>
</u-col> </u-col>
<u-col span="3.7"> <u-col span="3.7">
<tpx-input v-model:value="modelInfo.height" @change="calculateVplume" placeholder="高" inputAlign="right" suffix="cm" _digit="5"></tpx-input> <tpx-input v-model:value="modelInfo.height" placeholder="高" inputAlign="right" suffix="cm" _digit="5"></tpx-input>
</u-col> </u-col>
</u-row> </u-row>
</view> </view>
@ -38,6 +38,20 @@
get(){ get(){
return this.value return this.value
} }
},
calChangeVal(){
const { length, width, height, cargoQty } = this.modelInfo
return {
length, width, height, cargoQty
}
}
},
watch: {
calChangeVal: {
handler: function(newVal){
this.calculateVplume(newVal)
},
deep: true
} }
}, },
props: { props: {
@ -61,16 +75,19 @@
}, },
methods: { methods: {
calculateVplume() { calculateVplume(calVal) {
setTimeout(()=> { setTimeout(()=> {
let volume = this.modelInfo.volume let volume = this.modelInfo.volume
const { length, width, height } = this.modelInfo const { length, width, height, cargoQty } = calVal
if(length && width && height){ console.log("cargoQty======v", cargoQty)
volume = length/100 * width/100 * height/100 if(length && width && height && cargoQty){
volume = length/100 * width/100 * height/100 * cargoQty
} }
if(volume && volume.toFixed) { if(volume && volume.toFixed) {
volume = volume.toFixed(5) volume = volume.toFixed(5)
this.modelInfo.volume = volume this.modelInfo.volume = volume
} else {
this.modelInfo.volume = 0
} }
}, 500); }, 500);
} }

View File

@ -4,7 +4,7 @@
<u-row justify="between"> <u-row justify="between">
<text class="font-28 font-weight">总件数</text> <text class="font-28 font-weight">总件数</text>
<view> <view>
<uni-number-box v-model="modelInfo.parcelQty" :min="1" :max="10000"></uni-number-box> <u-number-box v-model="modelInfo.parcelQty" :min="1" :max="100000" buttonSize="50" inputWidth="100" iconStyle="font-size: 18rpx;"></u-number-box>
</view> </view>
</u-row> </u-row>
</view> </view>
@ -80,10 +80,8 @@
handleCargoChange(list){ handleCargoChange(list){
let parcelQty = 0, totalVolume = 0 let parcelQty = 0, totalVolume = 0
list.map(t=> { list.map(t=> {
parcelQty += (+t.cargoQty) || 0
totalVolume += (+t.volume) || 0 totalVolume += (+t.volume) || 0
}) })
this.modelInfo.parcelQty = parcelQty
this.modelInfo.totalVolume = totalVolume.toFixed(5) this.modelInfo.totalVolume = totalVolume.toFixed(5)
}, },
async calceOther() { async calceOther() {

View File

@ -63,6 +63,8 @@
}, },
_digit:{ // 保留小数位 _digit:{ // 保留小数位
}, },
_maxNum:{ // 最大数值
},
customStyle:{ customStyle:{
default () { default () {
return '' return ''
@ -98,12 +100,17 @@
this.$emit('update:value', val) this.$emit('update:value', val)
}, },
formatter(val) { formatter(val) {
let newVal = val
if(this._digit) { if(this._digit) {
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g') let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
let newVal = val.match(reg)[0] newVal = val.match(reg)[0]
return newVal
} }
return val if(typeof this._maxNum != 'undefined') {
if(val > this._maxNum) {
newVal = this._maxNum
}
}
return newVal
} }
} }
} }

View File

@ -102,6 +102,9 @@ export const getOrderModels = () => {
], ],
freight: undefined, // 计费总计 freight: undefined, // 计费总计
cargoList: [ // 货物列表 cargoList: [ // 货物列表
{
cargoQty: 1,
}
// { // {
// goodsCode: 货物代码:eg 123, // goodsCode: 货物代码:eg 123,
// goodsName: 货物名称, // goodsName: 货物名称,