应付邮编调整和订单应付计费的附加费调整

This commit is contained in:
liuminghui
2026-11-19 11:09:44 +08:00
parent a0b9b58291
commit ad7cf3c18c
23 changed files with 752 additions and 70 deletions
@@ -54,12 +54,18 @@
<span v-else>{{ money(row.price) }}</span>
</template>
</el-table-column>
<el-table-column label="续重价" width="110" align="right">
<template #default="{ row }">
<el-input v-if="isRowEditing(row)" v-model="row._extraPrice" size="small" />
<span v-else>{{ money(extraPrice(pane, row)) }}</span>
</template>
</el-table-column>
<el-table-column prop="priceUnit" label="单位" width="110" show-overflow-tooltip>
<template #default="{ row }"><cell-text v-model="row.priceUnit" :edit="isRowEditing(row)" /></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>
<el-button v-if="!isRowEditing(row)" link type="primary" :disabled="rowBusy" @click="startBandEdit(pane, row)">修改</el-button>
<el-button v-else link type="primary" :disabled="rowBusy" @click="saveBandRow(pane, row)">保存</el-button>
<el-button link type="danger" :disabled="rowBusy" @click="removeRow(pane.item.weightBands, row)">删除</el-button>
</template>
@@ -367,7 +373,14 @@ function runSave(kind, pane, row) {
}, 8000)
}
function startBandEdit(pane, row) {
const current = extraPrice(pane, row)
row._extraPrice = current == null ? '' : String(current)
startEdit(row)
}
function saveBandRow(pane, row) {
if (!applyExtraPrice(pane, row)) return
runSave('band', pane, row)
}
@@ -710,6 +723,69 @@ function pageOf(rows, pageNo) {
return rows.slice(start, start + pageSize)
}
function zoneKey(value) {
return String(value || '').toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]/g, '')
}
function sameZone(left, right) {
const a = zoneKey(left)
const b = zoneKey(right)
return !!a && (a === b || a.includes(b) || b.includes(a))
}
function findExtraFee(pane, row) {
const section = String(row?.sectionName || '').trim()
const rowZone = String(row?.zoneName || '').trim()
const matched = (pane?.item?.surcharges || []).filter(fee => {
if (!fee || String(fee.calcRule || '').toUpperCase() !== 'EXTRA_KG') return false
if (fee.sectionName === '附加费配置') return false
if (String(fee.postcodeParam || '').trim() || String(fee.postcodeText || '').trim()) return false
const feeSection = String(fee.sectionName || '').trim()
if (section && feeSection && section !== feeSection) return false
const feeZone = String(fee.zoneName || '').trim()
if (!feeZone && !rowZone) return true
return sameZone(feeZone, rowZone)
})
return matched.find(fee => fee.amount != null && fee.amount !== '') || matched[0] || null
}
function extraPrice(pane, row) {
const matched = findExtraFee(pane, row)
if (!matched || matched.amount == null || matched.amount === '') return null
return matched.amount
}
function applyExtraPrice(pane, row) {
const text = String(row?._extraPrice ?? '').trim()
if (text && !Number.isFinite(Number(text))) {
proxy.$modal.msgWarning('续重价要填数字')
return false
}
const fee = findExtraFee(pane, row)
if (!text) {
if (fee) fee.amount = null
return true
}
if (fee) {
fee.amount = text
return true
}
if (!pane.item.surcharges) pane.item.surcharges = []
const currency = String(pane.item.currency || 'CNY').trim().toUpperCase() || 'CNY'
pane.item.surcharges.push({
feeName: '每公斤续重',
sectionName: row.sectionName || '派送费',
zoneName: row.zoneName || '',
calcRule: 'EXTRA_KG',
amount: text,
currency,
priceUnit: currency + '/KG',
calcParam: row.weightMax == null || row.weightMax === '' ? '' : String(row.weightMax),
chargeTiming: '产生时收取'
})
return true
}
function money(value) {
if (value === null || value === undefined || value === '') return '-'
const num = Number(value)