应付配置的附加费调整

This commit is contained in:
liuminghui
2026-11-18 13:34:00 +08:00
parent ccfb05bf50
commit a72417b2c1
30 changed files with 1338 additions and 107 deletions
+17
View File
@@ -60,6 +60,23 @@ export function previewPayTemplate(file, chargeType) {
})
}
/** 这一版价卡已勾选的附加费配置 */
export function listPayConfigSurcharges(termId) {
return request({
url: '/price/pay/term/' + termId + '/config-surcharges',
method: 'get'
})
}
/** 保存这一版勾选的附加费和计费条件 */
export function savePayConfigSurcharges(termId, data) {
return request({
url: '/price/pay/term/' + termId + '/config-surcharges',
method: 'put',
data
})
}
/** 按所选计费模式手工新增一条价卡 */
export function savePayManual(data) {
return request({
@@ -0,0 +1,252 @@
<template>
<el-dialog v-model="visible" :title="title" width="980px" append-to-body destroy-on-close>
<div v-loading="loading" class="board">
<section class="pick">
<div class="pane-title">附加费</div>
<el-select v-model="pickedId" filterable clearable placeholder="选择附加费配置" style="width: 100%">
<el-option v-for="item in available" :key="item.scId" :label="optionLabel(item)" :value="item.scId" />
</el-select>
<el-button type="primary" plain class="add" @click="addPicked">添加</el-button>
<p class="hint">从附加费配置里选择。长宽高、重量和邮编在配置里维护,这里只选用。</p>
</section>
<section class="chosen">
<div class="pane-title">已选附加费</div>
<el-empty v-if="!chosen.length" description="还没有选择附加费" :image-size="64" />
<div v-for="row in chosen" :key="row.scId" class="card">
<div class="card-head">
<strong>{{ row.feeName }}</strong>
<el-tag size="small" effect="plain">{{ chargeLabel(row.calcRule) }}</el-tag>
<span class="meta">{{ valueText(row) }}</span>
<el-button link type="danger" @click="removeRow(row)">移除</el-button>
</div>
<div v-if="row.zoneName" class="scope">分区 {{ row.zoneName }}</div>
<div class="scope">{{ conditionText(row) }}</div>
</div>
</section>
</div>
<template #footer>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { listSurchargeOptions } from '@/api/price/surcharge'
import { listPayConfigSurcharges, savePayConfigSurcharges } from '@/api/price/pay'
const emit = defineEmits(['saved'])
const { proxy } = getCurrentInstance()
const visible = ref(false)
const loading = ref(false)
const saving = ref(false)
const title = ref('附加费')
const termId = ref(null)
const pickedId = ref(null)
const options = ref([])
const chosen = ref([])
const chargeLabelMap = {
MANUAL: '暂不计费',
ALWAYS: '每票都收',
POSTCODE: '命中邮编',
ZONE: '命中分区',
EXTRA_KG: '超重续收',
WEIGHT: '超重',
SIZE: '超尺寸',
RETURN: '退件'
}
const available = computed(() => {
const used = new Set(chosen.value.map(row => String(row.scId)))
return options.value.filter(item => item?.scId != null && !used.has(String(item.scId)))
})
function chargeLabel(rule) {
return chargeLabelMap[rule] || rule || '暂不计费'
}
function toRule(chargeType) {
const code = String(chargeType || '').trim().toUpperCase()
if (code === 'FIXED') return 'ALWAYS'
if (!code || code === 'RATE') return 'MANUAL'
return chargeLabelMap[code] ? code : 'MANUAL'
}
function optionLabel(item) {
const value = item.chargeValue == null ? '' : ` ${item.chargeValue}${item.currency ? ' ' + item.currency : ''}`
return `${item.scName} · ${chargeLabel(toRule(item.chargeType))}${value}`
}
function valueText(row) {
if (row.amount == null || row.amount === '') return ''
return `${row.amount} ${row.currency || ''}`.trim()
}
function rowFromConfig(item) {
return {
scId: item.scId,
feeName: item.scName,
calcRule: toRule(item.chargeType),
amount: item.chargeValue,
currency: item.currency,
zoneName: item.blockTitle || '',
lengthCm: item.lengthCm,
widthCm: item.widthCm,
heightCm: item.heightCm,
overWeightKg: item.overWeightKg,
extraWeightKg: item.extraWeightKg,
postcodeText: item.postcodeText || ''
}
}
function addPicked() {
const item = options.value.find(row => String(row.scId) === String(pickedId.value))
if (!item) {
proxy.$modal.msgWarning('请选择附加费')
return
}
chosen.value.push(rowFromConfig(item))
pickedId.value = null
}
function removeRow(row) {
chosen.value = chosen.value.filter(item => item !== row)
}
function conditionText(row) {
if (row.calcRule === 'SIZE') {
if (Number(row.lengthCm) > 0 && Number(row.widthCm) > 0 && Number(row.heightCm) > 0) {
return `长 ${row.lengthCm} cm,宽 ${row.widthCm} cm,高 ${row.heightCm} cm`
}
return '长宽高还没在附加费配置里填写'
}
if (row.calcRule === 'WEIGHT') {
return row.overWeightKg == null ? '超过重量还没在附加费配置里填写' : `超过 ${row.overWeightKg} kg`
}
if (row.calcRule === 'EXTRA_KG') {
return row.extraWeightKg == null ? '续重起始重量还没在附加费配置里填写' : `超出 ${row.extraWeightKg} kg 后续收`
}
if (row.calcRule === 'POSTCODE') {
return String(row.postcodeText || '').trim() ? `邮编 ${row.postcodeText}` : '邮编还没在附加费配置里填写'
}
return '按附加费配置直接计费'
}
function invalid(row) {
const text = conditionText(row)
return text.includes('还没') ? row.feeName + text : ''
}
async function open(row) {
if (!row?.termId) {
proxy.$modal.msgWarning('请先为这张价卡设置有效期')
return
}
title.value = row.productName || '附加费'
termId.value = row.termId
pickedId.value = null
chosen.value = []
options.value = []
visible.value = true
loading.value = true
try {
const [configs, selected] = await Promise.all([
listSurchargeOptions({ ssCode: 'on' }),
listPayConfigSurcharges(row.termId)
])
options.value = configs.data || []
chosen.value = (selected.data || []).map(item => ({
scId: item.scId,
feeName: item.feeName,
calcRule: item.calcRule,
amount: item.amount,
currency: item.currency,
zoneName: item.zoneName || '',
lengthCm: item.lengthCm,
widthCm: item.widthCm,
heightCm: item.heightCm,
overWeightKg: item.overWeightKg,
extraWeightKg: item.extraWeightKg,
postcodeText: item.postcodeText || ''
}))
} finally {
loading.value = false
}
}
async function save() {
for (const row of chosen.value) {
const message = invalid(row)
if (message) {
proxy.$modal.msgWarning(message)
return
}
}
saving.value = true
try {
await savePayConfigSurcharges(termId.value, chosen.value.map(row => ({ scId: row.scId })))
proxy.$modal.msgSuccess('附加费已保存')
visible.value = false
emit('saved')
} finally {
saving.value = false
}
}
defineExpose({ open })
</script>
<style scoped>
.board {
display: flex;
gap: 16px;
min-height: 420px;
}
.pick {
width: 300px;
flex: none;
}
.chosen {
flex: 1;
min-width: 0;
max-height: 520px;
overflow: auto;
}
.pane-title {
margin-bottom: 10px;
font-weight: 600;
}
.add {
margin-top: 10px;
}
.hint,
.scope {
margin: 10px 0 0;
color: var(--el-text-color-secondary);
font-size: 12px;
line-height: 1.6;
}
.card {
margin-bottom: 10px;
padding: 10px 12px;
border: 1px solid var(--el-border-color);
border-radius: 6px;
}
.card-head {
display: flex;
align-items: center;
gap: 8px;
}
.card-head strong {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.meta {
margin-left: auto;
color: var(--el-text-color-secondary);
}
</style>
@@ -75,7 +75,7 @@
/>
</el-tab-pane>
<el-tab-pane :label="feeTabLabel(pane)" name="fee">
<el-tab-pane v-if="showFees" :label="feeTabLabel(pane)" name="fee">
<div class="pay-edit-bar">
<el-input v-model="pane.feeKeyword" clearable placeholder="筛选附加费用、地区、价格、货币或费用解释" class="pay-filter" @input="pane.feePageNo = 1" />
<el-select v-model="pane.feeBill" clearable placeholder="计费条件" class="pay-bill-filter" @change="pane.feePageNo = 1">
@@ -274,6 +274,8 @@ import PaySurchargePickerDialog from './PaySurchargePickerDialog.vue'
const { order_charge_type } = useDict('order_charge_type')
const showFees = false
function chargeTypeText(value) {
const hit = (order_charge_type.value || []).find(item => item.value === value)
if (hit) return hit.label
@@ -76,7 +76,6 @@
<template #default="{ row }">{{ row.effectiveDate || preview.effectiveDate || '-' }}</template>
</el-table-column>
<el-table-column prop="weightCount" label="重量段" width="80" align="right" />
<el-table-column prop="surchargeCount" label="附加费" width="80" align="right" />
<el-table-column label="识别" width="120">
<template #default="{ row }">
<el-tag :type="statusType(row.parseStatus)" size="small">{{ statusText(row.parseStatus) }}</el-tag>
@@ -64,6 +64,7 @@
<template #col-action="{ row }">
<el-button link type="primary" icon="View" @click="openDetail(row)" v-hasPermi="['price:pay:query']">查看</el-button>
<el-button link type="primary" @click="surchargeRef.open(row)" v-hasPermi="['price:pay:surcharge']">附加费</el-button>
<el-button link type="primary" icon="Calendar" @click="openTermDialog(row)" v-hasPermi="['price:pay:edit']">有效期</el-button>
<el-button link type="primary" icon="Clock" @click="openHistory(row)" v-hasPermi="['price:pay:query']">历史</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(row.productId)" v-hasPermi="['price:pay:remove']">删除</el-button>
@@ -72,6 +73,7 @@
<pay-import-dialog ref="importRef" @saved="tableRef.refresh()" />
<pay-create-dialog ref="createRef" @saved="tableRef.refresh()" />
<pay-card-surcharge-dialog ref="surchargeRef" @saved="tableRef.refresh()" />
<el-dialog v-model="bindVisible" title="绑定渠道" width="640px" append-to-body @closed="resetBind">
<el-form label-width="70px">
<el-form-item label="产品">
@@ -210,6 +212,7 @@ import { listChannelOptions } from '@/api/masterdata/serviceChannel'
import { useDict } from '@/utils/dict'
import PayImportDialog from './components/PayImportDialog.vue'
import PayCreateDialog from './components/PayCreateDialog.vue'
import PayCardSurchargeDialog from './components/PayCardSurchargeDialog.vue'
import PayConfigDetail from './components/PayConfigDetail.vue'
const { proxy } = getCurrentInstance()
@@ -217,6 +220,7 @@ const { order_charge_type } = useDict('order_charge_type')
const tableRef = ref()
const importRef = ref()
const createRef = ref()
const surchargeRef = ref()
const detailVisible = ref(false)
const detailLoading = ref(false)
const savingRowKey = ref('')
@@ -273,7 +277,7 @@ const columns = [
{ label: '识别结果', prop: 'parseStatus', align: 'center', width: 120 },
{ label: '来源文件', prop: 'sourceFile', align: 'center', minWidth: 180, showOverflowTooltip: true },
{ label: '创建时间', prop: 'createTime', align: 'center', width: 160, parseTime: true },
{ label: '操作', prop: 'action', align: 'center', width: 280, fixed: 'right', showInToolbar: false }
{ label: '操作', prop: 'action', align: 'center', width: 340, fixed: 'right', showInToolbar: false }
]
const searchColumns = [
@@ -1,6 +1,6 @@
<template>
<el-dialog :title="title" v-model="visible" width="720px" append-to-body>
<basic-form ref="formRef" v-model="form" :schemas="schemas" label-width="100px" />
<el-dialog :title="title" v-model="visible" width="760px" append-to-body>
<basic-form ref="formRef" v-model="form" class="surcharge-form" :schemas="schemas" label-width="118px" />
<template #footer>
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="visible = false">取 消</el-button>
@@ -15,7 +15,6 @@ import { listRegionOptions } from '@/api/data/region'
const emit = defineEmits(['success'])
const { proxy } = getCurrentInstance()
const { payment_product_type } = useDict('payment_product_type')
const formRef = ref()
const visible = ref(false)
@@ -45,17 +44,12 @@ const countrySelectOptions = computed(() => {
})))
})
const channelProductOptions = computed(() =>
(payment_product_type.value || []).map(item => ({
label: item.label,
value: item.value
}))
)
const blockSelectOptions = computed(() =>
(blockOptions.value || []).map(title => ({ label: title, value: title }))
)
const chargeType = computed(() => String(form.value.chargeType || '').toUpperCase())
const schemas = computed(() => [
{
label: '附加费名称',
@@ -89,14 +83,67 @@ const schemas = computed(() => [
rules: [{ required: true, message: '请选择计费方式', trigger: 'change' }]
},
{
label: '渠道产品',
prop: 'dictValue',
component: 'select',
placeholder: '请选择渠道产品',
options: channelProductOptions.value,
label: '长(cm)',
prop: 'lengthCm',
component: 'inputNumber',
span: 12,
width: '100%',
props: { filterable: true, clearable: true }
show: chargeType.value === 'SIZE',
props: { min: 0, precision: 2, controls: false, align: 'left' },
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写长', trigger: 'blur' }] : undefined
},
{
label: '宽(cm)',
prop: 'widthCm',
component: 'inputNumber',
span: 12,
width: '100%',
show: chargeType.value === 'SIZE',
props: { min: 0, precision: 2, controls: false, align: 'left' },
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写宽', trigger: 'blur' }] : undefined
},
{
label: '高(cm)',
prop: 'heightCm',
component: 'inputNumber',
span: 12,
width: '100%',
show: chargeType.value === 'SIZE',
props: { min: 0, precision: 2, controls: false, align: 'left' },
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写高', trigger: 'blur' }] : undefined
},
{
label: '超过重量(kg)',
prop: 'overWeightKg',
component: 'inputNumber',
placeholder: '超过这个重量才收取',
span: 12,
width: '100%',
show: chargeType.value === 'WEIGHT',
props: { min: 0, precision: 3, controls: false, align: 'left' },
rules: chargeType.value === 'WEIGHT' ? [{ required: true, message: '请填写超过重量', trigger: 'blur' }] : undefined
},
{
label: '续重起始(kg)',
prop: 'extraWeightKg',
component: 'inputNumber',
placeholder: '超过这个重量后按超出公斤计',
span: 12,
width: '100%',
show: chargeType.value === 'EXTRA_KG',
props: { min: 0, precision: 3, controls: false, align: 'left' },
rules: chargeType.value === 'EXTRA_KG' ? [{ required: true, message: '请填写续重起始重量', trigger: 'blur' }] : undefined
},
{
label: '邮编',
prop: 'postcodeText',
component: 'textarea',
placeholder: '多个可用逗号分隔',
span: 24,
width: '100%',
show: chargeType.value === 'POSTCODE',
props: { rows: 2, maxlength: 1000 },
rules: chargeType.value === 'POSTCODE' ? [{ required: true, message: '请填写邮编', trigger: 'blur' }] : undefined
},
{
label: '计费数值',
@@ -104,7 +151,7 @@ const schemas = computed(() => [
component: 'inputNumber',
span: 12,
width: '100%',
props: { min: 0, precision: 6, step: 1, controlsPosition: 'right' },
props: { min: 0, precision: 6, controls: false, align: 'left' },
rules: [{ required: true, message: '计费数值不能为空', trigger: 'blur' }]
},
{
@@ -144,6 +191,7 @@ const schemas = computed(() => [
options: blockSelectOptions.value,
span: 12,
width: '100%',
show: chargeType.value === 'ZONE',
disabled: !form.value.countryCode || loadingBlocks.value,
props: { filterable: true, clearable: true }
},
@@ -163,14 +211,19 @@ function emptyForm() {
scId: undefined,
scName: undefined,
feeType: 'SURCHARGE',
dictValue: undefined,
chargeType: 'MANUAL',
chargeValue: 0,
currency: 'CNY',
roundMode: 'HALF_UP',
countryCode: undefined,
blockTitle: undefined,
scNote: undefined
scNote: undefined,
lengthCm: undefined,
widthCm: undefined,
heightCm: undefined,
overWeightKg: undefined,
extraWeightKg: undefined,
postcodeText: undefined
}
}
@@ -252,7 +305,7 @@ function submitForm() {
if (!valid) return
const payload = { ...form.value }
if (!payload.countryCode) payload.countryCode = undefined
if (!payload.dictValue) payload.dictValue = undefined
delete payload.dictValue
if (!payload.blockTitle) payload.blockTitle = undefined
if (!payload.chargeType) payload.chargeType = 'MANUAL'
if (payload.chargeValue != null) payload.chargeValue = Number(payload.chargeValue)
@@ -273,5 +326,33 @@ watch(() => form.value.countryCode, (code, prev) => {
loadBlockOptions(code, false)
})
watch(() => form.value.chargeType, (type, prev) => {
if (suppressCountryWatch.value || !prev || type === prev) return
form.value.lengthCm = undefined
form.value.widthCm = undefined
form.value.heightCm = undefined
form.value.overWeightKg = undefined
form.value.extraWeightKg = undefined
form.value.postcodeText = undefined
if (String(type || '').toUpperCase() !== 'ZONE') form.value.blockTitle = undefined
nextTick(() => formRef.value?.clearValidate())
})
defineExpose({ open })
</script>
<style scoped>
.surcharge-form :deep(.el-form-item__content) {
flex: 1;
min-width: 0;
}
.surcharge-form :deep(.el-input),
.surcharge-form :deep(.el-select),
.surcharge-form :deep(.el-input-number),
.surcharge-form :deep(.el-textarea) {
width: 100%;
}
.surcharge-form :deep(.el-input-number .el-input__inner) {
text-align: left;
}
</style>
@@ -98,7 +98,6 @@ const columns = [
{ label: '附加费名称', prop: 'scName', align: 'center', minWidth: 140, showOverflowTooltip: true },
{ label: '费用类型', prop: 'feeType', align: 'center', width: 110, dict: 'bms_fee_type' },
{ label: '计费方式', prop: 'chargeType', align: 'center', width: 110 },
{ label: '渠道产品', prop: 'dictValue', align: 'center', minWidth: 130, showOverflowTooltip: true },
{ label: '计费数值', prop: 'chargeValue', align: 'center', width: 140 },
{ label: '取值方式', prop: 'roundMode', align: 'center', width: 110, dict: 'bms_round_mode' },
{ label: '适用国家', prop: 'countryCode', align: 'center', minWidth: 120, showOverflowTooltip: true },
@@ -119,14 +118,6 @@ const searchColumns = [
placeholder: '计费方式',
width: '150px'
},
{
label: '渠道产品',
prop: 'dictValue',
component: 'select',
dict: 'payment_product_type',
placeholder: '渠道产品',
width: '160px'
},
{ label: '取值方式', prop: 'roundMode', component: 'select', dict: 'bms_round_mode', placeholder: '取值方式', width: '150px' },
{
label: '状态',