emis-app/components/buns-post-edit-templates/bpe-cost-tmp.vue
2024-05-28 12:32:43 +08:00

178 lines
4.7 KiB
Vue

<template>
<view class="shet-cont">
<view class="jsfm-item nobg" style="padding-top: 0;margin-bottom: 0;">
<u-row>
<view class="lft1 font-28">计费方式</view>
<view style="flex: 1;">
<u-radio-group v-model="modelInfo.calcFeeType">
<u-radio v-for="(item, index) in dicData.emis_calc_fee_type" :label="item.title"
:name="item.val" activeColor="#B12D29" size="30" labelSize="26"
:custom-style="`margin-right: ${index+1<dicData.emis_calc_fee_type.length?30:0}rpx;`">
</u-radio>
</u-radio-group>
</view>
</u-row>
</view>
<view v-for="(item, index) in modelInfo.feeItems" class="jsfm-item">
<u-row custom-style="gap: 20rpx;">
<u-row custom-style="flex: 1">
<text class="font-26 pr-10">{{item.feeName}}</text>
<tpx-input v-model:value="item.fee" :isWhite="true" custom-style="width: 120rpx;height: 46rpx;"
suffix="CNY"></tpx-input>
</u-row>
<!-- 干线运输费才显示 续重 -->
<u-row v-if="item.feeCode == '1001'" custom-style="flex: 1">
<text class="font-26 pr-10">续重</text>
<tpx-input v-model:value="item.addWeight" :isWhite="true"
custom-style="width: 120rpx;height: 46rpx;" suffix="KG"></tpx-input>
</u-row>
<view v-if="item.__add" @click="handleDelFee(index)" class="delicon">
<u-icon name="minus-circle" size="30"></u-icon>
</view>
</u-row>
<view v-if="item.calcExp" class="mt-10 clr-sub">计算公式: {{item.calcExp}}</view>
</view>
<tpx-select v-if="feeTypeOptions.length > 0" :list="feeTypeOptions" @onChange="handleAddFee" mode="drop">
<u-row justify="center">
<u-button custom-style="border-radius: 16rpx;height:60rpx;font-size: 30rpx;margin-top: 20rpx;"
:plain="true" type="primary">
<u-icon name="plus" size="30" color="#B12D29"></u-icon>
<text class="pl-10">增加收费项</text>
</u-button>
</u-row>
</tpx-select>
<view class="pt-20">
<u-row custom-style="flex: 1" justify="between">
<text class="font-26 pr-10">总费用</text>
<view v-if="modelInfo.calcFeeType==3">
<tpx-input v-model:value="modelInfo.freight" :isWhite="true" _digit="5"
inputAlign="right" custom-style="width: 460rpx;height: 46rpx;" suffix="CNY"></tpx-input>
</view>
<view v-else>
{{modelInfo.freight || 0}}<text class="clr-sub pl-10">CNY</text>
</view>
</u-row>
</view>
<view class="pt-20">
<u-textarea v-model="modelInfo.feeRemaker" border="surround" height="120" placeholder="费用备注"
maxlength="50" count></u-textarea>
</view>
</view>
</template>
<script>
import * as apiService from "@/common/api"
export default {
computed: {
modelInfo: {
get() {
return this.value
}
},
feeTypeOptions() {
let list = this.dicData.emis_fee_type || []
let curVals = this.modelInfo?.feeItems?.map?.(t => t.feeCode) || []
list = list.filter(t => curVals.indexOf(t.val) == -1)
return list
},
dicData() {
return this.$store.getters.dicData
},
searchParam() {
let info = this.modelInfo
let param = {
productType: info.productType,
// customerCode: info.customerCode,
customsClear: info.customsClear,
customsEclaration: info.customsEclaration,
calcFeeType: info.calcFeeType,
settlementWeight: info.settlementWeight,
totalVolume: info.totalVolume,
sendSiteCode: this.$store.getters.userInfo.ownerSiteCode,
dispatchUnderlingSiteCode: info.dispatchUnderlingSiteCode,
}
return param
}
},
watch: {
searchParam: {
handler(newVal){
let vals = Object.values(newVal)
// 所有关联入参都有值再 执行自动计算
if(vals.length == vals.filter(v => !!v).length) {
this.calcWaybillFee(newVal);
}
},
deep: true,
}
},
props: {
value: {
default () {
return {}
}
},
},
data() {
return {}
},
created() {
},
onHide() {
},
unmounted() {
},
methods: {
handleDelFee(index) {
this.modelInfo.feeItems.splice(index, 1)
},
handleAddFee(val) {
this.modelInfo.feeItems.push({
__add: true,
feeCode: val,
feeName: this.dicData.emis_fee_type.filter(t => t.val == val)[0].title
})
},
async calcWaybillFee(params = {}) {
let res = await apiService.calcWaybillFee({ custNo: this.modelInfo.custNo, ...params })
this.modelInfo.feeItems = res.data.feeList
this.modelInfo.freight = res.data.totalFee
}
}
}
</script>
<style scoped lang="scss">
.shet-cont {}
.jsfm-item {
background-color: #F6F6F6;
padding: 20rpx;
margin-bottom: 20rpx;
border-bottom: 2rpx solid #F6F6F6;
&:last-child {
margin-bottom: 0rpx;
}
.lft1 {
width: 150rpx;
margin-right: 10rpx;
}
.delicon {
padding: 16rpx 0 16rpx 20rpx;
}
}
.nobg {
background-color: transparent;
}
</style>