emis-app/components/buns-post-edit-templates/bpe-gooditem-edit-tmp.vue

217 lines
5.7 KiB
Vue
Raw Normal View History

2024-01-31 09:17:34 +00:00
<template>
2024-09-01 02:16:40 +00:00
<view v-if="showGoodSummary">
<view class="edm-input-item">
<tpx-select v-model:value="modelInfo.goodsType" v-model:resObject="goodsRes" :getListFun="getGoodsList" :transKeyVal="{valKey: 'goodsName',titleKey: 'goodsName'}"
mode="drop" @onChange="handleChooseGood" type="multiple"
>
<tpx-text-item label="货物大类" :value="modelInfo.goodsType"></tpx-text-item>
</tpx-select>
</view>
<view class="edm-input-item ">
<u-row align="top">
<text class="font-weight pr-30">货物名称</text>
<u-textarea v-model="modelInfo.goodsInfo" border="surround" height="100" placeholder=""
count></u-textarea>
</u-row>
</view>
2024-06-01 16:21:36 +00:00
</view>
2024-09-01 02:16:40 +00:00
2024-06-11 04:55:37 +00:00
<view class="edm-input-item mb-10">
<u-row justify="between">
<text class="font-28 font-weight">总件数</text>
<view>
<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>
2024-06-01 16:21:36 +00:00
2024-04-27 15:19:55 +00:00
<view v-for="(item, index) in modelInfo.cargoList" class="yditem">
2024-06-02 08:37:54 +00:00
<view class="ydi-lab mb-10">
<text class="font-weight">
<!-- {{item.goodsName}} -->
</text>
2024-01-31 09:17:34 +00:00
<view>
<u-icon @click="handleDelGood(index)" name="trash" size="32"></u-icon>
</view>
</view>
2024-06-02 08:37:54 +00:00
<bpe-gooditem-filed-edit-tmp :value="item" :showMode="showMode" :submitVal="modelInfo"></bpe-gooditem-filed-edit-tmp>
2024-01-31 09:17:34 +00:00
</view>
2024-06-02 08:37:54 +00:00
<u-button @click="handleAddGood" custom-style="border-radius: 16rpx;height: 66rpx;" type="primary" plain="true">
2024-01-31 09:17:34 +00:00
<u-row justify="center">
<view>
<u-icon name="plus" size="30" color="#B12D29"></u-icon>
</view>
<text class="pl-10">增加货物</text>
</u-row>
2024-06-02 08:37:54 +00:00
</u-button>
2024-01-31 09:17:34 +00:00
2024-06-11 04:55:37 +00:00
<view class="edm-input-item mt-20">
<u-row justify="between">
<text class="font-28 font-weight">包裹重量</text>
<view>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="modelInfo.billWeight" placeholder="" inputAlign="right" suffix="kg" _digit="4"></tpx-input>
2024-06-11 04:55:37 +00:00
</view>
</u-row>
</view>
<view class="edm-input-item">
<u-row justify="between" align="top">
<text class="font-28 pt-20 font-weight">总体积</text>
<view v-if="totalVolume || true">
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="modelInfo.totalVolume" placeholder="" inputAlign="right" suffix="m³" _digit="4"></tpx-input>
2024-07-06 05:20:15 +00:00
</view>
</u-row>
</view>
<view class="edm-input-item">
<u-row justify="between" align="top">
<text class="font-28 pt-20 font-weight">货值</text>
<view>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="modelInfo.realValue" placeholder="" inputAlign="right" suffix="美元" _digit="4"></tpx-input>
2024-06-11 04:55:37 +00:00
</view>
</u-row>
</view>
2024-01-31 09:17:34 +00:00
</template>
<script>
2024-06-01 16:21:36 +00:00
import BpeGooditemFiledEditTmp from "@/components/buns-post-edit-templates/bpe-gooditem-filed-edit-tmp"
import * as apiService from "@/common/api"
2024-01-31 09:17:34 +00:00
export default {
2024-06-01 16:21:36 +00:00
components: { BpeGooditemFiledEditTmp },
2024-01-31 09:17:34 +00:00
computed: {
2024-04-27 15:19:55 +00:00
modelInfo: {
2024-01-31 09:17:34 +00:00
get(){
return this.value
}
2024-04-27 15:19:55 +00:00
},
dicData() {
return this.$store.getters.dicData
2024-06-11 04:55:37 +00:00
},
totalVolume() {
let totalVolume = this.modelInfo.totalVolume
return totalVolume
},
isCargoListOnchange() {
return this.modelInfo.cargoList
2024-01-31 09:17:34 +00:00
}
},
2024-06-02 08:37:54 +00:00
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)
}
}
2024-06-11 04:55:37 +00:00
},
isCargoListOnchange: {
handler(newVal){
console.log("===bpe-goodsize-tmp isCargoListOnchange===")
this.handleCargoChange(newVal)
},
deep: true,
2024-06-02 08:37:54 +00:00
}
},
2024-01-31 09:17:34 +00:00
props: {
value: {
default () {
return { }
}
2024-05-25 16:20:09 +00:00
},
showMode: {
default () {
return '1' // 1 只显示商品名称、体积; 2:显示全部商品信息
}
2024-09-01 02:16:40 +00:00
},
showGoodSummary: {
default () {
return true // 显示商品汇总信息
}
},
2024-01-31 09:17:34 +00:00
},
data() {
return {
2024-06-01 16:21:36 +00:00
goodsRes: { list: [] },
2024-01-31 09:17:34 +00:00
}
},
created() {
},
onHide() {
},
unmounted() {
},
methods: {
2024-06-01 16:21:36 +00:00
getGoodsList: apiService.getGoodsList,
2024-04-27 15:19:55 +00:00
handleDelGood(index) {
this.modelInfo.cargoList.splice(index, 1)
},
2024-12-05 04:53:50 +00:00
handleAddGood(item = { }) {
this.modelInfo.cargoList = this.modelInfo.cargoList || []
2024-06-01 16:21:36 +00:00
this.modelInfo.cargoList.push({
...item
})
2024-01-31 09:17:34 +00:00
},
2024-06-01 16:21:36 +00:00
handleChooseGood(val, name){
this.modelInfo.goodsInfo = name
2024-06-11 04:55:37 +00:00
},
handleCargoChange(list){
let parcelQty = 0, totalVolume = 0
list.map(t=> {
totalVolume += (+t.volume) || 0
})
2024-09-03 06:12:12 +00:00
this.modelInfo.totalVolume = totalVolume.toFixed(4)
2024-06-11 04:55:37 +00:00
},
async calceOther() {
let { totalVolume, productType, billWeight } = this.modelInfo
let voRes = await apiService.calcVolumeWeight({ productType, totalVolume })
let { volumeWeight } = voRes.data
let stRes = await apiService.calcSetteldWeight({ volumeWeight, productType, billWeight })
const { settlementWeight } = stRes.data
this.modelInfo.volumeWeight = volumeWeight
this.modelInfo.settlementWeight = this.modelInfo.totalWeight = settlementWeight
//
},
async validData() {
await this.calceOther()
2024-04-27 15:19:55 +00:00
}
2024-01-31 09:17:34 +00:00
}
}
</script>
<style scoped lang="scss">
.yditem{
padding: 20rpx 20rpx;
2024-06-02 08:37:54 +00:00
// background-color: #F6F6F6;
2024-06-10 17:07:56 +00:00
background-color: #F6F6F6;
2024-01-31 09:17:34 +00:00
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.ydi-lab{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
2024-06-01 16:21:36 +00:00
.edm-input-item{
padding: 8rpx 0;
border-bottom: 2rpx solid #F6F6F6;
}
2024-01-31 09:17:34 +00:00
</style>