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

205 lines
5.3 KiB
Vue
Raw Normal View History

2024-01-31 09:18:28 +00:00
<template>
2024-06-02 15:02:19 +00:00
<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>
2024-06-11 09:35:55 +00:00
<view class="edm-input-item ">
2024-08-02 09:41:30 +00:00
<u-row align="top" justify="between">
2024-07-31 15:37:10 +00:00
<text class="font-weight pr-30 lbRequiredDot">货物名称</text>
2024-08-02 09:41:30 +00:00
<view>
<u-textarea v-model="modelInfo.goodsInfo" border="surround" height="100" placeholder=""
:customStyle="`${comInSty}`" count></u-textarea>
</view>
2024-06-11 09:35:55 +00:00
</u-row>
</view>
<view class="edm-input-item mb-10">
<u-row justify="between">
2024-07-31 15:37:10 +00:00
<text class="font-28 font-weight lbRequiredDot">总件数</text>
2024-06-11 09:35:55 +00:00
<view>
2024-08-02 09:41:30 +00:00
<tpx-input v-model:value="modelInfo.parcelQty" placeholder="" :customStyle="`${comInSty}`" type="number" inputAlign="right"></tpx-input>
2024-06-11 09:35:55 +00:00
</view>
</u-row>
2024-06-02 15:02:19 +00:00
</view>
2024-06-11 09:35:55 +00:00
<view class="edm-input-item mt-20">
2024-07-31 15:37:10 +00:00
<tpx-text-item :required="true" label="包裹重量" >
<template #right>
2024-08-02 09:41:30 +00:00
<tpx-input v-model:value="modelInfo.billWeight" placeholder="" :customStyle="`${comInSty}`" inputAlign="right" suffix="kg" _digit="5"></tpx-input>
2024-07-31 15:37:10 +00:00
</template>
</tpx-text-item>
2024-06-11 09:35:55 +00:00
</view>
<view class="edm-input-item">
<u-row justify="between" align="top">
<text class="font-28 pt-20 font-weight">总体积</text>
2024-07-31 16:54:49 +00:00
<view>
2024-08-02 09:41:30 +00:00
<tpx-input v-model:value="modelInfo.totalVolume" placeholder="" :customStyle="`${comInSty}`" inputAlign="right" suffix="m³" _digit="5"></tpx-input>
2024-07-10 05:33:52 +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-02 09:41:30 +00:00
<tpx-input v-model:value="modelInfo.realValue" placeholder="" :customStyle="`${comInSty}`" inputAlign="right" suffix="美元" _digit="5"></tpx-input>
2024-06-11 09:35:55 +00:00
</view>
</u-row>
</view>
2024-07-29 16:28:21 +00:00
<view v-for="(item, index) in modelInfo.cargoList" class="yditem">
<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>
2024-08-02 09:41:30 +00:00
<bpe-gooditem-filed-edit-tmp :value="item" :showMode="showMode" :submitVal="modelInfo" :comInSty="comInSty"></bpe-gooditem-filed-edit-tmp>
2024-07-29 16:28:21 +00:00
</view>
<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>
2024-01-31 09:18:28 +00:00
</template>
<script>
2024-06-02 15:02:19 +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:18:28 +00:00
export default {
2024-06-02 15:02:19 +00:00
components: { BpeGooditemFiledEditTmp },
2024-01-31 09:18:28 +00:00
computed: {
2024-05-31 10:42:15 +00:00
modelInfo: {
2024-01-31 09:18:28 +00:00
get(){
return this.value
}
2024-05-31 10:42:15 +00:00
},
dicData() {
return this.$store.getters.dicData
2024-06-11 09:35:55 +00:00
},
totalVolume() {
let totalVolume = this.modelInfo.totalVolume
return totalVolume
},
isCargoListOnchange() {
return this.modelInfo.cargoList
2024-08-02 09:41:30 +00:00
},
comInSty(){
return `;width: 450rpx;`
},
2024-01-31 09:18:28 +00:00
},
2024-06-02 15:02:19 +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 09:35:55 +00:00
},
isCargoListOnchange: {
handler(newVal){
console.log("===bpe-goodsize-tmp isCargoListOnchange===")
this.handleCargoChange(newVal)
},
deep: true,
2024-06-02 15:02:19 +00:00
}
},
2024-01-31 09:18:28 +00:00
props: {
value: {
default () {
return { }
}
2024-05-31 10:42:15 +00:00
},
showMode: {
default () {
2024-07-14 08:10:52 +00:00
return '2' // 1 只显示商品名称、体积; 2:显示全部商品信息
2024-05-31 10:42:15 +00:00
}
2024-01-31 09:18:28 +00:00
}
},
data() {
return {
2024-06-02 15:02:19 +00:00
goodsRes: { list: [] },
2024-01-31 09:18:28 +00:00
}
},
created() {
},
onHide() {
},
unmounted() {
},
methods: {
2024-06-02 15:02:19 +00:00
getGoodsList: apiService.getGoodsList,
2024-05-31 10:42:15 +00:00
handleDelGood(index) {
this.modelInfo.cargoList.splice(index, 1)
},
2024-06-02 15:02:19 +00:00
handleAddGood(item = { }) {
this.modelInfo.cargoList.push({
...item
})
2024-01-31 09:18:28 +00:00
},
2024-06-02 15:02:19 +00:00
handleChooseGood(val, name){
this.modelInfo.goodsInfo = name
2024-06-11 09:35:55 +00:00
},
handleCargoChange(list){
let parcelQty = 0, totalVolume = 0
list.map(t=> {
totalVolume += (+t.volume) || 0
})
2024-07-29 16:28:21 +00:00
// 去除体积自动计算
// this.modelInfo.totalVolume = totalVolume.toFixed(5)
2024-06-11 09:35:55 +00:00
},
async calceOther() {
},
async validData() {
await this.calceOther()
2024-05-31 10:42:15 +00:00
}
2024-01-31 09:18:28 +00:00
}
}
</script>
<style scoped lang="scss">
.yditem{
padding: 20rpx 20rpx;
2024-06-02 15:02:19 +00:00
// background-color: #F6F6F6;
2024-06-11 09:35:55 +00:00
background-color: #F6F6F6;
2024-01-31 09:18:28 +00:00
border-radius: 10rpx;
margin-bottom: 20rpx;
}
.ydi-lab{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
2024-06-02 15:02:19 +00:00
.edm-input-item{
padding: 8rpx 0;
border-bottom: 2rpx solid #F6F6F6;
}
2024-01-31 09:18:28 +00:00
</style>