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 v-for="(item, index) in modelInfo.cargoList" class="yditem">
<view class="ydi-lab">
<text class="font-weight">{{item.goodsName}}</text>
<view class="ydi-lab mb-10">
<text class="font-weight">
<!-- {{item.goodsName}} -->
</text>
<view>
<u-icon @click="handleDelGood(index)" name="trash" size="32"></u-icon>
</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>
<!-- <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">
<view>
<u-icon name="plus" size="30" color="#B12D29"></u-icon>
</view>
<text class="pl-10">增加货物</text>
</u-row>
</u-button> -->
</u-button>
</template>
@ -51,6 +53,25 @@
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: {
value: {
default () {
@ -97,7 +118,8 @@
<style scoped lang="scss">
.yditem{
padding: 20rpx 20rpx;
background-color: #F6F6F6;
// background-color: #F6F6F6;
background-color: #e1e1e1;
border-radius: 10rpx;
margin-bottom: 20rpx;
}

View File

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

View File

@ -7,13 +7,13 @@
<view style="width: 70%;">
<u-row justify="between">
<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 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 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-row>
</view>
@ -38,6 +38,20 @@
get(){
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: {
@ -61,16 +75,19 @@
},
methods: {
calculateVplume() {
calculateVplume(calVal) {
setTimeout(()=> {
let volume = this.modelInfo.volume
const { length, width, height } = this.modelInfo
if(length && width && height){
volume = length/100 * width/100 * height/100
const { length, width, height, cargoQty } = calVal
console.log("cargoQty======v", cargoQty)
if(length && width && height && cargoQty){
volume = length/100 * width/100 * height/100 * cargoQty
}
if(volume && volume.toFixed) {
volume = volume.toFixed(5)
this.modelInfo.volume = volume
} else {
this.modelInfo.volume = 0
}
}, 500);
}

View File

@ -4,7 +4,7 @@
<u-row justify="between">
<text class="font-28 font-weight">总件数</text>
<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>
</u-row>
</view>
@ -80,10 +80,8 @@
handleCargoChange(list){
let parcelQty = 0, totalVolume = 0
list.map(t=> {
parcelQty += (+t.cargoQty) || 0
totalVolume += (+t.volume) || 0
})
this.modelInfo.parcelQty = parcelQty
this.modelInfo.totalVolume = totalVolume.toFixed(5)
},
async calceOther() {

View File

@ -63,6 +63,8 @@
},
_digit:{ // 保留小数位
},
_maxNum:{ // 最大数值
},
customStyle:{
default () {
return ''
@ -98,12 +100,17 @@
this.$emit('update:value', val)
},
formatter(val) {
let newVal = val
if(this._digit) {
let reg = new RegExp(`^\\d*(\\.?\\d{0,${this._digit}})`, 'g')
let newVal = val.match(reg)[0]
return newVal
newVal = val.match(reg)[0]
}
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, // 计费总计
cargoList: [ // 货物列表
{
cargoQty: 1,
}
// {
// goodsCode: 货物代码:eg 123,
// goodsName: 货物名称,