优化附加费计算规则,调整相关逻辑和注释

This commit is contained in:
wuweihua
2026-11-13 15:25:10 +08:00
parent 880b4751c5
commit 87eab12d51
8 changed files with 89 additions and 41 deletions
@@ -79,7 +79,7 @@
<el-tab-pane :label="feeTabLabel(pane)" name="fee">
<div class="label-edit-bar">
<el-input v-model="pane.feeKeyword" clearable placeholder="筛选附加费用、地区、价格、货币或费用解释" class="label-filter" @input="pane.feePageNo = 1" />
<el-input v-model="pane.feeKeyword" clearable placeholder="筛选附加费用、价格、币种、计费条件或费用解释" class="label-filter" @input="pane.feePageNo = 1" />
<el-button v-if="editable" size="small" type="primary" plain @click="openFeePicker(pane)">添加附加费</el-button>
<el-button
v-if="editable"
@@ -125,12 +125,6 @@
<span v-else>{{ row.feeName || '-' }}</span>
</template>
</el-table-column>
<el-table-column prop="zoneCode" label="分区编码" width="110" show-overflow-tooltip>
<template #default="{ row }"><cell-text v-model="row.zoneCode" :edit="isRowEditing(row)" /></template>
</el-table-column>
<el-table-column prop="zoneName" label="分区名称" min-width="140" show-overflow-tooltip>
<template #default="{ row }"><cell-text v-model="row.zoneName" :edit="isRowEditing(row)" /></template>
</el-table-column>
<el-table-column label="价格" width="110" align="right">
<template #default="{ row }">
<el-input v-if="isRowEditing(row)" v-model="row.amount" size="small" />
@@ -185,24 +179,24 @@
<span v-else>{{ feeUnitOf(row) || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="收费标准" min-width="180" show-overflow-tooltip>
<el-table-column label="计费条件" width="140">
<template #default="{ row }">
<cell-text v-if="isRowEditing(row) && (!row.chargeText || feeNote(row))" v-model="row.chargeText" :edit="true" />
<span v-else>{{ feeNote(row) || '-' }}</span>
<el-select
v-if="isRowEditing(row)"
:model-value="feeChargeModeOf(row)"
size="small"
style="width: 100%"
clearable
@update:model-value="value => setFeeChargeMode(row, value)"
>
<el-option v-for="d in feeChargeModeOptions(row)" :key="d.value" :label="d.label" :value="d.value" />
</el-select>
<span v-else>{{ dictLabel(lbl_charge_mode, feeChargeModeOf(row)) || '-' }}</span>
</template>
</el-table-column>
<el-table-column prop="feeDesc" label="费用解释" min-width="240" show-overflow-tooltip>
<template #default="{ row }"><cell-text v-model="row.feeDesc" :edit="isRowEditing(row)" /></template>
</el-table-column>
<el-table-column prop="calcRule" label="计费条件" width="140">
<template #default="{ row }">
<el-select v-if="isRowEditing(row)" :model-value="feeBillFlag(row)" size="small" @change="value => setFeeBill(row, value)">
<el-option label="需要计费" value="BILL" />
<el-option label="暂不计费" value="MANUAL" />
</el-select>
<span v-else>{{ feeBillFlag(row) === 'BILL' ? '需要计费' : '暂不计费' }}</span>
</template>
</el-table-column>
<el-table-column v-if="editable" label="操作" width="120" align="center" fixed="right">
<template #default="{ row }">
<el-button v-if="!isRowEditing(row)" link type="primary" :disabled="rowBusy" @click="startEdit(row)">修改</el-button>
@@ -464,16 +458,30 @@ const CellText = {
}
}
function feeBillFlag(row) {
return row?.calcRule && row.calcRule !== 'MANUAL' ? 'BILL' : 'MANUAL'
function normalizeFeeChargeMode(rule) {
const v = String(rule || '').trim().toUpperCase()
if (!v || v === 'MANUAL') return ''
if (v === 'ALWAYS' || v === 'FLAT' || v === 'ZONE' || v === 'WEIGHT' || v === 'SIZE' || v === 'RETURN') return 'ITEM'
if (v === 'FIRST_EXTRA') return 'EXTRA_KG'
return v
}
function setFeeBill(row, value) {
if (value === 'MANUAL') {
row.calcRule = 'MANUAL'
return
function feeChargeModeOf(row) {
return normalizeFeeChargeMode(row?.calcRule)
}
function feeChargeModeOptions(row) {
const list = (lbl_charge_mode.value || []).map(d => ({ label: d.label || d.value, value: d.value }))
const cur = feeChargeModeOf(row)
if (cur && !list.some(d => String(d.value) === String(cur))) {
list.unshift({ label: cur, value: cur })
}
if (!row.calcRule || row.calcRule === 'MANUAL') row.calcRule = 'ALWAYS'
return list
}
function setFeeChargeMode(row, value) {
const mode = String(value || '').trim().toUpperCase()
row.calcRule = mode || 'MANUAL'
}
const pageSize = 20
@@ -603,7 +611,7 @@ function invalidateBandView(pane) {
}
function filteredFees(pane) {
return filterRows(pane.item.surcharges || [], pane.feeKeyword, ['feeName', 'zoneCode', 'zoneName', 'chargeText', 'amount', 'currency', 'priceUnit', 'feeDesc', 'calcRule', 'calcParam', 'postcodeParam'])
return filterRows(pane.item.surcharges || [], pane.feeKeyword, ['feeName', 'amount', 'currency', 'priceUnit', 'feeDesc', 'calcRule', 'calcParam'])
}
function feeTabLabel(pane) {
@@ -670,8 +678,9 @@ function openFeePicker(pane) {
function toCalcRule(chargeType) {
const t = String(chargeType || '').trim().toUpperCase()
if (!t || t === 'RATE') return 'MANUAL'
if (t === 'FIXED') return 'ALWAYS'
const allowed = ['ALWAYS', 'POSTCODE', 'ZONE', 'EXTRA_KG', 'WEIGHT', 'SIZE', 'RETURN', 'MANUAL']
if (t === 'FIXED') return 'ITEM'
const allowed = ['ITEM', 'PER_KG', 'ALWAYS', 'POSTCODE', 'ZONE', 'EXTRA_KG', 'WEIGHT', 'SIZE', 'RETURN', 'MANUAL']
if (t === 'ALWAYS') return 'ITEM'
return allowed.includes(t) ? t : 'MANUAL'
}
@@ -54,7 +54,7 @@
<el-drawer
v-model="bindListVisible"
:title="bindListTitle"
size="520px"
size="1020px"
append-to-body
destroy-on-close
@closed="onBindListClosed"
@@ -170,6 +170,9 @@
<template #col-product="{ row }">
{{ row.productName || '-' }} ({{ row.productCode || '-' }})
</template>
<template #col-channel="{ row }">
{{ row.productFloor || '-' }} ({{ row.productFloorCode || '-' }})
</template>
<template #col-country="{ row }">
{{ row.countryName || '-' }} ({{ row.countryCode || '-' }})
</template>
@@ -593,8 +596,8 @@ const columns = [
{ label: '客户', prop: 'customerName', minWidth: 140, showOverflowTooltip: true },
{ label: '客户代码', prop: 'customerCode', width: 120 },
{ label: '产品', prop: 'product', minWidth: 160, slot: 'product' },
{ label: '渠道', prop: 'channel', minWidth: 160, slot: 'channel' },
{ label: '国家', prop: 'country', minWidth: 130, slot: 'country' },
{ label: '件数', prop: 'pieces', align: 'center', width: 70 },
{ label: '计费重', prop: 'weight', align: 'center', width: 90, slot: 'weight' },
{ label: '体积重', prop: 'volumeWeight', align: 'center', width: 90, slot: 'volumeWeight' },
{ label: '实重', prop: 'receiveWeight', align: 'center', width: 90, slot: 'receiveWeight' },