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

386 lines
12 KiB
Vue
Raw Normal View History

2024-01-30 07:40:49 +00:00
<template>
<view class="shet-cont">
2024-06-02 10:16:18 +00:00
<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;">
2024-01-31 06:45:51 +00:00
<u-row>
<view class="lft1 font-28">计费方式</view>
<view style="flex: 1;">
2024-05-26 15:21:59 +00:00
<u-radio-group v-model="modelInfo.calcFeeType">
2024-04-29 08:13:17 +00:00
<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;`">
2024-01-31 06:45:51 +00:00
</u-radio>
2024-04-29 08:13:17 +00:00
</u-radio-group>
2024-01-30 07:40:49 +00:00
</view>
</u-row>
</view>
2024-04-29 08:13:17 +00:00
2024-04-27 09:59:09 +00:00
<view v-for="(item, index) in modelInfo.feeItems" class="jsfm-item">
2024-06-02 10:16:18 +00:00
<!-- 手动添加的才能删除 -->
<u-row justify="between">
<view >
2024-06-10 17:07:56 +00:00
<text class="font-weight font-30">{{item.feeName}}</text>
2024-06-02 10:16:18 +00:00
</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;">
2024-04-27 09:59:09 +00:00
<u-row custom-style="flex: 1">
2024-06-10 17:07:56 +00:00
<text class="font-26 pr-10">首重费</text>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="item.initialWeightFee" @change="(val)=> { handleIwFeeChange(item, val) }" _digit="4" :isWhite="true"
2024-09-03 17:24:58 +00:00
:disabled="modelInfo.blSpecialQuote != 1" custom-style="width: 120rpx;height: 46rpx;" :suffix="item.currency"></tpx-input>
2024-01-31 06:45:51 +00:00
</u-row>
2024-06-02 10:16:18 +00:00
<u-row custom-style="flex: 1">
2024-06-10 17:07:56 +00:00
<text class="font-26 pr-10">续重单价</text>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="item.addWeightPrice" @change="(val)=> { handleAwPriceChange(item, val) }" _digit="4" :isWhite="true"
2024-09-03 17:24:58 +00:00
:disabled="modelInfo.blSpecialQuote != 1" custom-style="width: 120rpx;height: 46rpx;" :suffix="item.currency"></tpx-input>
2024-04-27 05:55:14 +00:00
</u-row>
2024-04-27 09:59:09 +00:00
</u-row>
2024-06-10 17:07:56 +00:00
<u-row style="margin-top:10rpx;" justify="between">
<view>
2024-09-03 17:24:58 +00:00
<text class="">应收:</text> {{item.fee || 0}} {{item.currency}}
2024-06-10 17:07:56 +00:00
</view>
<u-row custom-style="width:360rpx;">
<text class="font-26 pr-20">实收</text>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="item.realFee" @change="(val)=> { handleRlFeeChange(item, val) }" _digit="4" :isWhite="true" custom-style="width: 120rpx;height: 46rpx;"
2024-09-03 17:53:34 +00:00
:disabled="modelInfo.blSpecialQuote != 1 || (item.initialWeightFee || item.addWeightPrice || false)"
2024-09-03 17:24:58 +00:00
:suffix="item.currency"
></tpx-input>
2024-06-10 17:07:56 +00:00
</u-row>
</u-row>
<!-- <view v-if="item.calcExp" class="mt-10">
2024-06-02 10:16:18 +00:00
<text class="">计算公式:</text> {{item.calcExp}}
2024-06-10 17:07:56 +00:00
</view> -->
<view class="mt-20">
<tpx-input v-model:value="item.remark" :disabled="modelInfo.blSpecialQuote != 1" placeholder="费用描述" isWhite="true"></tpx-input>
2024-06-02 10:16:18 +00:00
</view>
2024-04-27 09:59:09 +00:00
</view>
2024-04-29 08:13:17 +00:00
<tpx-select v-if="feeTypeOptions.length > 0" :list="feeTypeOptions" @onChange="handleAddFee" mode="drop">
2024-04-27 05:55:14 +00:00
<u-row justify="center">
2024-04-29 08:13:17 +00:00
<u-button custom-style="border-radius: 16rpx;height:60rpx;font-size: 30rpx;margin-top: 20rpx;"
:plain="true" type="primary">
2024-04-27 05:55:14 +00:00
<u-icon name="plus" size="30" color="#B12D29"></u-icon>
<text class="pl-10">增加收费项</text>
</u-button>
2024-01-30 07:40:49 +00:00
</u-row>
2024-04-27 09:59:09 +00:00
</tpx-select>
2024-05-06 16:38:24 +00:00
<view class="pt-20">
2024-06-10 17:07:56 +00:00
<u-row custom-style="flex:1;" justify="between">
2024-05-06 16:38:24 +00:00
<text class="font-26 pr-10">总费用</text>
2024-06-10 17:07:56 +00:00
<view style="width: 360rpx;">
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="modelInfo.freight" :isWhite="true" _digit="4"
2024-06-10 17:07:56 +00:00
:disabled="modelInfo.calcFeeType!=3"
inputAlign="right" custom-style="height: 46rpx;" suffix="CNY"></tpx-input>
2024-05-28 04:32:43 +00:00
</view>
2024-05-06 16:38:24 +00:00
</u-row>
</view>
<view class="pt-20">
2024-06-14 15:43:50 +00:00
<u-textarea v-model="modelInfo.feeRemark" border="surround" height="120" placeholder="费用备注"
2024-08-05 10:13:59 +00:00
maxlength="300" count></u-textarea>
2024-05-06 16:38:24 +00:00
</view>
2024-04-29 08:13:17 +00:00
</view>
2024-06-11 03:25:41 +00:00
2024-06-13 08:06:13 +00:00
<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">
2024-09-03 17:24:58 +00:00
<tpx-select v-model:value="tempObject.value.currency" :list="costRateList"
@onChange="handleCurrencyChange" mode="drop"
>
<u-row custom-style="gap: 20rpx;margin-top:10rpx;" justify="between">
<text class="font-26 label-text">币种</text>
<tpx-text-dic :value="tempObject.value.currency" :list="costRateList"></tpx-text-dic>
</u-row>
</tpx-select>
<u-row custom-style="gap: 20rpx;margin-top:30rpx;">
2024-06-11 03:25:41 +00:00
<u-row custom-style="flex: 1">
2024-06-13 08:06:13 +00:00
<text class="font-26 label-text">首重费</text>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="tempObject.value.initialWeightFee" _digit="4" :isWhite="true"
2024-09-03 17:24:58 +00:00
custom-style="width: 120rpx;height: 46rpx;" :suffix="tempObject.value.currency"></tpx-input>
2024-06-11 03:25:41 +00:00
</u-row>
<u-row custom-style="flex: 1">
2024-06-13 08:06:13 +00:00
<text class="font-26 label-text">续重单价</text>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="tempObject.value.addWeightPrice" _digit="4" :isWhite="true"
2024-09-03 17:24:58 +00:00
custom-style="width: 120rpx;height: 46rpx;" :suffix="tempObject.value.currency"></tpx-input>
2024-06-11 03:25:41 +00:00
</u-row>
</u-row>
<u-row style="margin-top:30rpx;" justify="between">
<u-row custom-style="width:300rpx;">
2024-06-13 08:06:13 +00:00
<text class="label-text">应收</text>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="tempObject.value.fee" _digit="4" :isWhite="true" custom-style="width: 120rpx;height: 46rpx;"
2024-09-03 17:24:58 +00:00
:suffix="tempObject.value.currency"></tpx-input>
2024-06-11 03:25:41 +00:00
</u-row>
<u-row custom-style="width:300rpx;">
2024-06-17 09:13:39 +00:00
<text :class="`font-26 label-text label-text-required `">实收</text>
2024-08-27 12:15:54 +00:00
<tpx-input v-model:value="tempObject.value.realFee" _digit="4" :isWhite="true" custom-style="width: 120rpx;height: 46rpx;"
2024-09-03 17:24:58 +00:00
:suffix="tempObject.value.currency"></tpx-input>
2024-06-11 03:25:41 +00:00
</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>
2024-01-30 07:40:49 +00:00
</template>
<script>
2024-04-29 08:13:17 +00:00
import * as apiService from "@/common/api"
2024-09-03 11:12:41 +00:00
import { costRateList, costRateTypeEnum } from "@/common/enum"
2024-01-30 07:40:49 +00:00
export default {
computed: {
2024-04-27 05:55:14 +00:00
modelInfo: {
2024-04-29 08:13:17 +00:00
get() {
2024-01-30 07:40:49 +00:00
return this.value
}
2024-04-27 05:55:14 +00:00
},
2024-04-29 08:13:17 +00:00
feeTypeOptions() {
2024-04-27 09:59:09 +00:00
let list = this.dicData.emis_fee_type || []
2024-05-07 13:44:17 +00:00
let curVals = this.modelInfo?.feeItems?.map?.(t => t.feeCode) || []
2024-04-29 08:13:17 +00:00
list = list.filter(t => curVals.indexOf(t.val) == -1)
2024-04-27 09:59:09 +00:00
return list
},
2024-04-27 05:55:14 +00:00
dicData() {
2024-04-29 08:13:17 +00:00
return this.$store.getters.dicData
2024-05-26 15:21:59 +00:00
},
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,
2024-10-20 03:26:51 +00:00
custNo: info.custNo,
2024-05-26 15:21:59 +00:00
}
return param
}
},
watch: {
searchParam: {
2024-06-19 06:26:41 +00:00
handler(newVal, oldVal){
2024-10-20 03:26:51 +00:00
let notMustKey = ['custNo']
2024-08-06 15:03:25 +00:00
if(JSON.stringify(newVal) == JSON.stringify(oldVal || {})) {
return false
}
2024-10-29 14:56:45 +00:00
let mustObj = Object.assign({}, newVal)
2024-10-20 03:26:51 +00:00
notMustKey.map(key=> { delete mustObj[key] })
let mustVals = Object.values(mustObj)
2024-10-18 15:09:58 +00:00
// 所有关联入参都有值或者为0再 执行自动计算,数据未变化不做计算
2024-10-20 03:26:51 +00:00
if(mustVals.length == mustVals.filter(v => (v==0 || !!v)).length) {
2024-10-29 14:56:45 +00:00
console.log("====watch cost calcWaybillFee===", newVal)
2024-08-06 15:03:25 +00:00
this.calcWaybillFee(newVal);
2024-05-26 15:21:59 +00:00
}
},
deep: true,
2024-01-30 07:40:49 +00:00
}
},
props: {
value: {
default () {
2024-04-29 08:13:17 +00:00
return {}
2024-01-30 07:40:49 +00:00
}
2024-04-29 08:46:07 +00:00
},
2024-01-30 07:40:49 +00:00
},
data() {
2024-06-11 03:25:41 +00:00
return {
2024-06-18 16:16:19 +00:00
costModal: { item: {}, show: false },
2024-09-03 17:24:58 +00:00
daiDianCode: '1002',
costRateList: [].concat(costRateList),
costRateTypeEnum: { ...costRateTypeEnum },
usdToCnyRate: 1
2024-06-11 03:25:41 +00:00
}
2024-01-30 07:40:49 +00:00
},
2024-09-03 17:24:58 +00:00
async created() {
let data = await this.getRateData(costRateTypeEnum.usd)
this.usdToCnyRate = data
2024-01-30 07:40:49 +00:00
},
onHide() {
},
unmounted() {
2024-04-29 08:13:17 +00:00
2024-01-30 07:40:49 +00:00
},
methods: {
2024-06-18 16:16:19 +00:00
getNewCostItem(code, extData = {}){
return {
2024-09-03 17:24:58 +00:00
currency: costRateTypeEnum.cny,
2024-06-18 16:16:19 +00:00
blAutoGen: 0, // 手动添加的费用标识
feeCode: code,
feeName: this.dicData.emis_fee_type.filter(t => t.val == code)[0].title,
...extData
}
},
2024-04-27 09:59:09 +00:00
handleDelFee(index) {
2024-06-18 16:16:19 +00:00
// 同步变量
if(this.modelInfo.feeItems[index].feeCode == this.daiDianCode) {
this.modelInfo.blPrepareInFreight = 0
this.modelInfo.prepareInEstFee = undefined
}
2024-04-27 09:59:09 +00:00
this.modelInfo.feeItems.splice(index, 1)
2024-06-11 05:15:01 +00:00
this.calteFreight()
2024-06-18 16:16:19 +00:00
2024-04-27 09:59:09 +00:00
},
2024-09-03 17:24:58 +00:00
async handleAddFee(code) {
2024-06-11 03:25:41 +00:00
this.costModal.show = {}
2024-06-19 14:54:17 +00:00
this.costModal.item = this.getNewCostItem(code)
2024-04-29 08:13:17 +00:00
},
2024-04-29 08:46:07 +00:00
async calcWaybillFee(params = {}) {
2024-06-12 04:21:56 +00:00
// calcFeeType计算入参特殊处理
params.calcFeeType == 3 && (params.calcFeeType = 1);
2024-10-20 03:26:51 +00:00
let res = await apiService.calcWaybillFee({ ...params })
2024-05-06 16:38:24 +00:00
this.modelInfo.feeItems = res.data.feeList
this.modelInfo.freight = res.data.totalFee
2024-06-02 10:16:18 +00:00
},
2024-09-03 17:24:58 +00:00
async getRateData(from){
// 外币 to 人民币汇率
let toCnyRate = 1
if(from != costRateTypeEnum.cny) {
let res = await apiService.getValidExchangeRate({ from, to: 'CNY' })
res.data && (toCnyRate = res.data)
}
return toCnyRate
},
async handleCurrencyChange(val){
2024-09-03 11:12:41 +00:00
},
2024-06-02 10:16:18 +00:00
handleRlFeeChange(item, val){
setTimeout(()=> {
2024-09-03 17:24:58 +00:00
this.calteShiRealfee(item, false)
2024-06-02 10:16:18 +00:00
}, 500)
2024-06-18 16:16:19 +00:00
// 同步外层变量
if(item.feeCode == this.daiDianCode) {
this.modelInfo.prepareInEstFee = val
}
2024-09-03 17:24:58 +00:00
2024-06-02 10:16:18 +00:00
},
handleAwPriceChange(item) {
setTimeout(()=> {
this.calteShiRealfee(item)
}, 500)
},
handleIwFeeChange(item){
setTimeout(()=> {
this.calteShiRealfee(item)
}, 500)
},
2024-09-03 17:24:58 +00:00
calteShiRealfee(item, execRealFee = true){
let { initialWeightFee, addWeightPrice } = item
let { settlementWeight } = this.modelInfo
let calcExp = item.blAutoGen == 0 ? 's+w*d' : item.calcExp
2024-09-19 10:54:48 +00:00
if(execRealFee && calcExp && (initialWeightFee||initialWeightFee==0) && (addWeightPrice||addWeightPrice==0) && settlementWeight) {
2024-06-02 10:16:18 +00:00
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);
}
2024-09-03 17:24:58 +00:00
// 手动添加的 应收=实收
if(item.blAutoGen == 0) {
item.fee = item.realFee
}
if(item.currency == costRateTypeEnum.usd) {
// 记录realFee转换人民币后的值
item.remark = `汇率:${this.usdToCnyRate},${(item.realFee*this.usdToCnyRate).toFixed(2)}(${costRateTypeEnum.cny})`
}
this.calteFreight()
2024-06-02 10:16:18 +00:00
},
// 更新总费用
calteFreight(){
let total = 0
this.modelInfo.feeItems.map(t=> {
2024-09-03 17:24:58 +00:00
let realFee = (+(t.realFee || 0))
if(t.currency == costRateTypeEnum.usd) {
realFee = (+(realFee * (+this.usdToCnyRate)).toFixed(2))
}
total += realFee
2024-06-02 10:16:18 +00:00
})
2024-09-18 08:05:45 +00:00
this.modelInfo.freight = total.toFixed(2);
2024-06-11 03:25:41 +00:00
},
2024-06-13 08:06:13 +00:00
async handleCostItemSure(data){
2024-06-17 09:13:39 +00:00
if(!data.realFee) {
this.showToast("实收不能为空")
return false
2024-06-13 08:06:13 +00:00
}
2024-09-03 17:24:58 +00:00
this.calteShiRealfee(data)
2024-06-11 03:25:41 +00:00
this.modelInfo.feeItems.push({ ...data })
2024-06-13 08:06:13 +00:00
this.costModal.show = false
2024-06-11 03:25:41 +00:00
setTimeout(()=>{
this.calteFreight()
}, 500)
2024-06-18 16:16:19 +00:00
},
getCostItemByFeeCode(code){
let item, index;
this.modelInfo.feeItems.map((t, i)=> {
if(t.feeCode == code) {
item = t;
index = i
}
})
return { item, index }
},
updateDaiDianFeeData() {
let { item, index } = this.getCostItemByFeeCode(this.daiDianCode)
// 开启 代垫运费开关,需要同步外层录入数据
if(this.modelInfo.blPrepareInFreight == '1'){
if(item) {
item.realFee = this.modelInfo.prepareInEstFee
} else {
item = this.getNewCostItem(this.daiDianCode, { realFee: this.modelInfo.prepareInEstFee })
this.handleCostItemSure(item)
}
} else if(typeof index != 'undefined'){
this.handleDelFee(index)
}
2024-04-27 09:59:09 +00:00
}
2024-01-30 07:40:49 +00:00
}
}
</script>
<style scoped lang="scss">
2024-04-29 08:13:17 +00:00
.shet-cont {}
.jsfm-item {
2024-06-02 10:16:18 +00:00
position: relative;
2024-04-27 09:59:09 +00:00
background-color: #F6F6F6;
padding: 20rpx;
margin-bottom: 20rpx;
2024-01-31 06:45:51 +00:00
border-bottom: 2rpx solid #F6F6F6;
2024-04-29 08:13:17 +00:00
&:last-child {
2024-04-27 09:59:09 +00:00
margin-bottom: 0rpx;
}
2024-04-29 08:13:17 +00:00
.lft1 {
2024-06-02 10:16:18 +00:00
font-weight: 700;
2024-01-31 06:45:51 +00:00
width: 150rpx;
margin-right: 10rpx;
}
2024-04-29 08:13:17 +00:00
.delicon {
2024-01-31 06:45:51 +00:00
padding: 16rpx 0 16rpx 20rpx;
}
2024-01-30 07:40:49 +00:00
}
2024-04-29 08:13:17 +00:00
.nobg {
2024-04-27 09:59:09 +00:00
background-color: transparent;
}
2024-01-30 07:40:49 +00:00
</style>