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

136 lines
3.2 KiB
Vue
Raw Normal View History

2024-01-31 09:17:34 +00:00
<template>
2024-06-01 16:21:36 +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-03 06:49:14 +00:00
<view class="edm-input-item mb-10">
2024-06-01 16:21:36 +00:00
<tpx-text-item label="货物名称">
<template v-slot:right>
<tpx-input v-model:value="modelInfo.goodsInfo" inputAlign="right"></tpx-input>
</template>
</tpx-text-item>
</view>
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
</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-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-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-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-06-01 16:21:36 +00:00
handleAddGood(item = { }) {
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-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>