emis-app/components/buns-post-edit-templates/bpe-cost-tmp.vue
2024-06-14 23:43:50 +08:00

296 lines
9.2 KiB
Vue

<template>
<view class="shet-cont">
<view class="">
<tpx-text-item label="特殊报价">
<template v-slot:right>
<u-switch v-model="modelInfo.blSpecialQuote" activeValue="1" inactiveValue="0" active-color="#B12D29" size="34"></u-switch>
</template>
</tpx-text-item>
</view>
<view class="pt-20">
<tpx-text-item label="敏感物">
<template v-slot:right>
<u-switch v-model="modelInfo.blSpecialGoods" activeValue="1" inactiveValue="0" active-color="#B12D29" size="34"></u-switch>
</template>
</tpx-text-item>
</view>
<view class="jsfm-item nobg" style=";margin-bottom: 0;padding-left: 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 justify="between">
<view >
<text class="font-weight font-30">{{item.feeName}}</text>
</view>
<view v-if="item.blAutoGen == 0" @click="handleDelFee(index)" class="delicon">
<u-icon name="trash" size="32"></u-icon>
</view>
</u-row>
<u-row custom-style="gap: 20rpx;margin-top:10rpx;">
<u-row custom-style="flex: 1">
<text class="font-26 pr-10">首重费</text>
<tpx-input v-model:value="item.initialWeightFee" @change="(val)=> { handleIwFeeChange(item, val) }" _digit="5" :isWhite="true"
:disabled="modelInfo.blSpecialQuote != 1" custom-style="width: 120rpx;height: 46rpx;" suffix="CNY"></tpx-input>
</u-row>
<u-row custom-style="flex: 1">
<text class="font-26 pr-10">续重单价</text>
<tpx-input v-model:value="item.addWeightPrice" @change="(val)=> { handleAwPriceChange(item, val) }" _digit="5" :isWhite="true"
:disabled="modelInfo.blSpecialQuote != 1" custom-style="width: 120rpx;height: 46rpx;" suffix="CNY"></tpx-input>
</u-row>
</u-row>
<u-row style="margin-top:10rpx;" justify="between">
<view>
<text class="">应收:</text> {{item.fee || 0}}
</view>
<u-row custom-style="width:360rpx;">
<text class="font-26 pr-20">实收</text>
<tpx-input v-model:value="item.realFee" @change="(val)=> { handleRlFeeChange(item, val) }" _digit="5" :isWhite="true" custom-style="width: 120rpx;height: 46rpx;"
:disabled="modelInfo.blSpecialQuote != 1" suffix="CNY"></tpx-input>
</u-row>
</u-row>
<!-- <view v-if="item.calcExp" class="mt-10">
<text class="">计算公式:</text> {{item.calcExp}}
</view> -->
<view class="mt-20">
<tpx-input v-model:value="item.remark" :disabled="modelInfo.blSpecialQuote != 1" placeholder="费用描述" isWhite="true"></tpx-input>
</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 style="width: 360rpx;">
<tpx-input v-model:value="modelInfo.freight" :isWhite="true" _digit="5"
:disabled="modelInfo.calcFeeType!=3"
inputAlign="right" custom-style="height: 46rpx;" suffix="CNY"></tpx-input>
</view>
</u-row>
</view>
<view class="pt-20">
<u-textarea v-model="modelInfo.feeRemark" border="surround" height="120" placeholder="费用备注"
maxlength="50" count></u-textarea>
</view>
</view>
<buns-edit-sheet percentHeight="40" :title="costModal.item.feeName" v-model:show="costModal.show" v-model:value="costModal.item" v-slot="tempObject" @onSure="handleCostItemSure" :okCloseModal="false">
<u-row custom-style="gap: 20rpx;margin-top:10rpx;">
<u-row custom-style="flex: 1">
<text class="font-26 label-text">首重费</text>
<tpx-input v-model:value="tempObject.value.initialWeightFee" _digit="5" :isWhite="true"
custom-style="width: 120rpx;height: 46rpx;" suffix="CNY"></tpx-input>
</u-row>
<u-row custom-style="flex: 1">
<text class="font-26 label-text">续重单价</text>
<tpx-input v-model:value="tempObject.value.addWeightPrice" _digit="5" :isWhite="true"
custom-style="width: 120rpx;height: 46rpx;" suffix="CNY"></tpx-input>
</u-row>
</u-row>
<u-row style="margin-top:30rpx;" justify="between">
<u-row custom-style="width:300rpx;">
<text class="label-text">应收</text>
<tpx-input v-model:value="tempObject.value.fee" _digit="5" :isWhite="true" custom-style="width: 120rpx;height: 46rpx;"
suffix="CNY"></tpx-input>
</u-row>
<u-row custom-style="width:300rpx;">
<text :class="`font-26 label-text ${tempObject.value.feeCode == '9999'?'label-text-required':''} `">实收</text>
<tpx-input v-model:value="tempObject.value.realFee" _digit="5" :isWhite="true" custom-style="width: 120rpx;height: 46rpx;"
suffix="CNY"></tpx-input>
</u-row>
</u-row>
<view class="mt-30">
<tpx-input v-model:value="tempObject.value.remark" placeholder="费用描述" isWhite="true"></tpx-input>
</view>
</buns-edit-sheet>
</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 {
costModal: { item: {}, show: false }
}
},
created() {
},
onHide() {
},
unmounted() {
},
methods: {
handleDelFee(index) {
this.modelInfo.feeItems.splice(index, 1)
this.calteFreight()
},
handleAddFee(val) {
this.costModal.show = {}
this.costModal.item = {
blAutoGen: 0, // 手动添加的费用标识
feeCode: val,
feeName: this.dicData.emis_fee_type.filter(t => t.val == val)[0].title
}
},
async calcWaybillFee(params = {}) {
// calcFeeType计算入参特殊处理
params.calcFeeType == 3 && (params.calcFeeType = 1);
let res = await apiService.calcWaybillFee({ custNo: this.modelInfo.custNo, ...params })
this.modelInfo.feeItems = res.data.feeList
this.modelInfo.freight = res.data.totalFee
},
handleRlFeeChange(item, val){
setTimeout(()=> {
this.calteFreight()
}, 500)
},
handleAwPriceChange(item) {
setTimeout(()=> {
this.calteShiRealfee(item)
}, 500)
},
handleIwFeeChange(item){
setTimeout(()=> {
this.calteShiRealfee(item)
}, 500)
},
calteShiRealfee(item){
if(item.blAutoGen == 1 && item.calcExp) {
let { settlementWeight } = this.modelInfo
let { initialWeightFee, addWeightPrice, calcExp } = item
let expr = calcExp;
expr = expr.replace("s", initialWeightFee);
expr = expr.replace("d", addWeightPrice);
expr = expr.replace("w", settlementWeight);
item.realFee = parseFloat(eval(expr)).toFixed(2);
this.calteFreight()
}
},
// 更新总费用
calteFreight(){
let total = 0
this.modelInfo.feeItems.map(t=> {
total += (+(t.realFee || 0))
})
this.modelInfo.freight = total
},
async handleCostItemSure(data){
if(data.feeCode == '9999') {
if(!data.realFee) {
this.showToast("实收不能为空")
return false
}
}
this.modelInfo.feeItems.push({ ...data })
this.costModal.show = false
setTimeout(()=>{
this.calteFreight()
}, 500)
}
}
}
</script>
<style scoped lang="scss">
.shet-cont {}
.jsfm-item {
position: relative;
background-color: #F6F6F6;
padding: 20rpx;
margin-bottom: 20rpx;
border-bottom: 2rpx solid #F6F6F6;
&:last-child {
margin-bottom: 0rpx;
}
.lft1 {
font-weight: 700;
width: 150rpx;
margin-right: 10rpx;
}
.delicon {
padding: 16rpx 0 16rpx 20rpx;
}
}
.nobg {
background-color: transparent;
}
</style>