新增按国家去重区块标题接口,优化计费列表请求方式

This commit is contained in:
wuweihua
2026-11-12 13:45:09 +08:00
parent d2c75e0c51
commit cf336f7a67
22 changed files with 436 additions and 99 deletions
+12 -4
View File
@@ -50,18 +50,26 @@ export function billOrder(data) {
/** Receivable bill list */
export function listBill(query) {
const { pageNum, pageSize, ...filters } = query || {}
return request({
url: '/price/billing/bill/list',
method: 'get',
params: query
method: 'post',
// 分页参数走 URL(PageHelper);筛选(大批单号)走 body,避免 HTTP 431
params: { pageNum, pageSize },
data: filters,
timeout: 120000
})
}
export function listOrderBill(query) {
const { pageNum, pageSize, ...filters } = query || {}
return request({
url: '/price/billing/orderBill/list',
method: 'get',
params: query
method: 'post',
// 分页参数走 URL(PageHelper);筛选(大批单号)走 body,避免 HTTP 431
params: { pageNum, pageSize },
data: filters,
timeout: 120000
})
}
+9
View File
@@ -37,6 +37,15 @@ export function listSurchargeOptions(query) {
})
}
/** 按国家拉取应付邮编区块(分区下拉) */
export function listSurchargeBlockOptions(query) {
return request({
url: '/price/surcharge/blockOptions',
method: 'get',
params: query
})
}
/** 绑定附加费到产品/明细(scId + productCode + detailId) */
export function addSurchargeRel(data) {
return request({
@@ -55,7 +55,7 @@ import SurchargeRelDialog from './SurchargeRelDialog.vue'
const emit = defineEmits(['success'])
const { proxy } = getCurrentInstance()
const { bms_round_mode, bms_charge_type } = useDict('bms_round_mode', 'bms_charge_type')
const { bms_round_mode } = useDict('bms_round_mode')
const relRef = ref()
const visible = ref(false)
@@ -107,9 +107,22 @@ function priceTypeLabel(val) {
return '产品价'
}
const chargeTypeLabelMap = {
MANUAL: '暂不计费',
ALWAYS: '每票都收',
POSTCODE: '命中邮编',
ZONE: '命中分区',
EXTRA_KG: '超重续收',
WEIGHT: '超重',
SIZE: '超尺寸',
RETURN: '退件',
FIXED: '每票都收',
RATE: '暂不计费'
}
function chargeTypeLabel(val) {
const found = bms_charge_type.value.find(c => c.value === val)
return found ? found.label : (val || '-')
if (!val) return chargeTypeLabelMap.MANUAL
return chargeTypeLabelMap[val] || chargeTypeLabelMap[String(val).toUpperCase()] || val
}
function roundModeLabel(val) {
@@ -120,7 +133,6 @@ function roundModeLabel(val) {
function formatChargeValue(row) {
if (row.chargeValue == null) return '-'
const v = Number(row.chargeValue)
if (row.chargeType === 'RATE') return (v * 100).toFixed(2) + '%'
return v + ' ' + (row.currency || 'CNY')
}
@@ -55,7 +55,7 @@ import RedlineSurchargeRelDialog from './RedlineSurchargeRelDialog.vue'
const emit = defineEmits(['success'])
const { proxy } = getCurrentInstance()
const { bms_round_mode, bms_charge_type } = useDict('bms_round_mode', 'bms_charge_type')
const { bms_round_mode } = useDict('bms_round_mode')
const relRef = ref()
const visible = ref(false)
@@ -110,9 +110,22 @@ function priceTypeLabel(val) {
return '产品价'
}
const chargeTypeLabelMap = {
MANUAL: '暂不计费',
ALWAYS: '每票都收',
POSTCODE: '命中邮编',
ZONE: '命中分区',
EXTRA_KG: '超重续收',
WEIGHT: '超重',
SIZE: '超尺寸',
RETURN: '退件',
FIXED: '每票都收',
RATE: '暂不计费'
}
function chargeTypeLabel(val) {
const found = bms_charge_type.value.find(c => c.value === val)
return found ? found.label : (val || '-')
if (!val) return chargeTypeLabelMap.MANUAL
return chargeTypeLabelMap[val] || chargeTypeLabelMap[String(val).toUpperCase()] || val
}
function roundModeLabel(val) {
@@ -123,7 +136,6 @@ function roundModeLabel(val) {
function formatChargeValue(row) {
if (row.chargeValue == null) return '-'
const v = Number(row.chargeValue)
if (row.chargeType === 'RATE') return (v * 100).toFixed(2) + '%'
return v + ' ' + (row.currency || 'CNY')
}
@@ -1,5 +1,5 @@
<template>
<el-dialog :title="title" v-model="visible" width="640px" append-to-body>
<el-dialog :title="title" v-model="visible" width="720px" append-to-body>
<basic-form ref="formRef" v-model="form" :schemas="schemas" label-width="100px" />
<template #footer>
<el-button type="primary" @click="submitForm">确 定</el-button>
@@ -10,101 +10,148 @@
<script setup>
import BasicForm from '@/components/BasicForm'
import { getSurcharge, addSurcharge, updateSurcharge } from '@/api/price/surcharge'
import { getSurcharge, addSurcharge, updateSurcharge, listSurchargeBlockOptions } from '@/api/price/surcharge'
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)
const title = ref('')
const form = ref(emptyForm())
const regionOptions = ref([])
const blockOptions = ref([])
const loadingBlocks = ref(false)
const suppressCountryWatch = ref(false)
const calcModeOptions = [
{ value: 'MANUAL', label: '暂不计费' },
{ value: 'ALWAYS', label: '每票都收' },
{ value: 'POSTCODE', label: '命中邮编' },
{ value: 'ZONE', label: '命中分区' },
{ value: 'EXTRA_KG', label: '超重续收' },
{ value: 'WEIGHT', label: '超重' },
{ value: 'SIZE', label: '超尺寸' },
{ value: 'RETURN', label: '退件' }
]
const countrySelectOptions = computed(() => {
const all = [{ label: "全部国家", value: '' }]
const all = [{ label: '全部国家', value: '' }]
return all.concat((regionOptions.value || []).map(r => ({
label: regionLabel(r),
value: r.countryCode2
})))
})
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 schemas = computed(() => [
{
label: "附加费名称",
label: '附加费名称',
prop: 'scName',
component: 'input',
placeholder: "如 燃油附加费",
placeholder: '如 燃油附加费',
span: 12,
width: '100%',
props: { maxlength: 100 },
rules: [{ required: true, message: "附加费名称不能为空", trigger: 'blur' }]
rules: [{ required: true, message: '附加费名称不能为空', trigger: 'blur' }]
},
{
label: "费用类型",
label: '费用类型',
prop: 'feeType',
component: 'select',
placeholder: "请选择",
placeholder: '请选择',
dict: 'bms_fee_type',
span: 12,
width: '100%',
disabled: true,
rules: [{ required: true, message: "请选择费用类型", trigger: 'change' }]
rules: [{ required: true, message: '请选择费用类型', trigger: 'change' }]
},
{
label: "计费方式",
label: '计费方式',
prop: 'chargeType',
component: 'select',
placeholder: "请选择",
dict: 'bms_charge_type',
placeholder: '请选择',
options: calcModeOptions,
span: 12,
width: '100%',
rules: [{ required: true, message: "请选择计费方式", trigger: 'change' }]
rules: [{ required: true, message: '请选择计费方式', trigger: 'change' }]
},
{
label: "计费数值",
label: '渠道产品',
prop: 'dictValue',
component: 'select',
placeholder: '请选择渠道产品',
options: channelProductOptions.value,
span: 12,
width: '100%',
props: { filterable: true, clearable: true }
},
{
label: '计费数值',
prop: 'chargeValue',
component: 'inputNumber',
span: 12,
width: '100%',
props: { min: 0, precision: 6, step: 1, controlsPosition: 'right' },
rules: [{ required: true, message: "计费数值不能为空", trigger: 'blur' }]
rules: [{ required: true, message: '计费数值不能为空', trigger: 'blur' }]
},
{
label: "币种",
label: '币种',
prop: 'currency',
component: 'select',
placeholder: "请选择",
placeholder: '请选择',
dict: 'bms_currency',
span: 12,
width: '100%'
},
{
label: "取值方式",
label: '取值方式',
prop: 'roundMode',
component: 'select',
placeholder: "请选择",
placeholder: '请选择',
dict: 'bms_round_mode',
span: 12,
width: '100%',
rules: [{ required: true, message: "请选择取值方式", trigger: 'change' }]
rules: [{ required: true, message: '请选择取值方式', trigger: 'change' }]
},
{
label: "适用国家",
label: '适用国家',
prop: 'countryCode',
component: 'select',
placeholder: "全部国家",
placeholder: '全部国家',
options: countrySelectOptions.value,
span: 12,
width: '100%',
props: { filterable: true, clearable: true }
},
{
label: "备注",
label: '分区',
prop: 'blockTitle',
component: 'select',
placeholder: form.value.countryCode ? (loadingBlocks.value ? '加载中...' : '请选择分区/区块') : '请先选择国家',
options: blockSelectOptions.value,
span: 12,
width: '100%',
disabled: !form.value.countryCode || loadingBlocks.value,
props: { filterable: true, clearable: true }
},
{
label: '备注',
prop: 'scNote',
component: 'textarea',
placeholder: "请输入备注",
placeholder: '请输入备注',
span: 24,
width: '100%',
props: { rows: 2, maxlength: 500 }
@@ -116,11 +163,13 @@ function emptyForm() {
scId: undefined,
scName: undefined,
feeType: 'SURCHARGE',
chargeType: 'FIXED',
dictValue: undefined,
chargeType: 'MANUAL',
chargeValue: 0,
currency: 'CNY',
roundMode: 'HALF_UP',
countryCode: undefined,
blockTitle: undefined,
scNote: undefined
}
}
@@ -137,25 +186,64 @@ function ensureRegions() {
})
}
function resolveCountryName(code) {
if (!code) return ''
const region = (regionOptions.value || []).find(item => item.countryCode2 === code)
return region?.countryNameCn || region?.countryNameEn || ''
}
function loadBlockOptions(code, keepCurrent) {
if (!code) {
blockOptions.value = []
if (!keepCurrent) form.value.blockTitle = undefined
return Promise.resolve()
}
loadingBlocks.value = true
const countryName = resolveCountryName(code)
return listSurchargeBlockOptions({ countryCode: code, countryName: countryName || undefined })
.then(res => {
const list = (res.data || []).filter(Boolean)
blockOptions.value = list
if (!keepCurrent) {
form.value.blockTitle = undefined
} else if (form.value.blockTitle && !list.includes(form.value.blockTitle)) {
// keep current title even if not in options (legacy)
blockOptions.value = [form.value.blockTitle].concat(list)
}
})
.catch(() => {
blockOptions.value = []
})
.finally(() => {
loadingBlocks.value = false
})
}
function reset() {
form.value = emptyForm()
blockOptions.value = []
nextTick(() => formRef.value?.clearValidate())
}
function open(row) {
reset()
ensureRegions()
if (!row) {
title.value = "新建附加费"
visible.value = true
return
}
getSurcharge(row.scId).then(res => {
const data = res.data || {}
form.value = { ...emptyForm(), ...data }
title.value = "修改附加费"
visible.value = true
nextTick(() => formRef.value?.clearValidate())
ensureRegions().then(() => {
if (!row) {
title.value = '新建附加费'
visible.value = true
return
}
getSurcharge(row.scId).then(res => {
const data = res.data || {}
suppressCountryWatch.value = true
form.value = { ...emptyForm(), ...data }
title.value = '修改附加费'
visible.value = true
loadBlockOptions(form.value.countryCode, true).finally(() => {
suppressCountryWatch.value = false
nextTick(() => formRef.value?.clearValidate())
})
})
})
}
@@ -164,17 +252,26 @@ function submitForm() {
if (!valid) return
const payload = { ...form.value }
if (!payload.countryCode) payload.countryCode = undefined
if (!payload.dictValue) payload.dictValue = undefined
if (!payload.blockTitle) payload.blockTitle = undefined
if (!payload.chargeType) payload.chargeType = 'MANUAL'
if (payload.chargeValue != null) payload.chargeValue = Number(payload.chargeValue)
const req = payload.scId != null ? updateSurcharge(payload) : addSurcharge(payload)
req.then(() => {
proxy.$modal.msgSuccess(payload.scId != null ? "修改成功" : "新增成功")
proxy.$modal.msgSuccess(payload.scId != null ? '修改成功' : '新增成功')
visible.value = false
emit('success')
}).catch(() => {
// 后端返回 warn(601「未做任何修改」) 时由全局拦截器弹提示,此处吞掉 reject
// backend warn(601) handled globally
})
})
}
watch(() => form.value.countryCode, (code, prev) => {
if (suppressCountryWatch.value) return
if (code === prev) return
loadBlockOptions(code, false)
})
defineExpose({ open })
</script>
@@ -66,7 +66,7 @@ import { listRegionOptions } from '@/api/data/region'
// 只读抽屉:查看已被版本化编辑淘汰的作废记录(ss_code = vd)
const { proxy } = getCurrentInstance()
const { bms_charge_type, bms_round_mode, bms_fee_type } = useDict('bms_charge_type', 'bms_round_mode', 'bms_fee_type')
const { bms_round_mode, bms_fee_type } = useDict('bms_round_mode', 'bms_fee_type')
const visible = ref(false)
const loading = ref(false)
@@ -105,9 +105,22 @@ function feeTypeLabel(val) {
return found ? found.label : (val || '-')
}
const chargeTypeLabelMap = {
MANUAL: '暂不计费',
ALWAYS: '每票都收',
POSTCODE: '命中邮编',
ZONE: '命中分区',
EXTRA_KG: '超重续收',
WEIGHT: '超重',
SIZE: '超尺寸',
RETURN: '退件',
FIXED: '每票都收',
RATE: '暂不计费'
}
function chargeTypeLabel(val) {
const found = bms_charge_type.value.find(d => d.value === val)
return found ? found.label : (val || '-')
if (!val) return chargeTypeLabelMap.MANUAL
return chargeTypeLabelMap[val] || chargeTypeLabelMap[String(val).toUpperCase()] || val
}
function roundModeLabel(val) {
@@ -118,7 +131,6 @@ function roundModeLabel(val) {
function formatChargeValue(row) {
if (row.chargeValue == null) return '-'
const v = Number(row.chargeValue)
if (row.chargeType === 'RATE') return (v * 100).toFixed(2) + '%'
return v + ' ' + (row.currency || 'CNY')
}
@@ -77,20 +77,32 @@ import { listRegionOptions } from '@/api/data/region'
import { onMounted } from 'vue'
const { proxy } = getCurrentInstance()
const { bms_charge_type } = useDict('bms_charge_type')
const tableRef = ref()
const formDialogRef = ref()
const voidDrawerRef = ref()
const regionOptions = ref([])
const calcModeLabelMap = {
MANUAL: '暂不计费',
ALWAYS: '每票都收',
POSTCODE: '命中邮编',
ZONE: '命中分区',
EXTRA_KG: '超重续收',
WEIGHT: '超重',
SIZE: '超尺寸',
RETURN: '退件'
}
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: 130 },
{ 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 },
{ label: '分区', prop: 'blockTitle', align: 'center', minWidth: 140, showOverflowTooltip: true },
{ label: '状态', prop: 'ssCode', align: 'center', width: 80 },
{ label: '备注', prop: 'scNote', align: 'center', minWidth: 140, showOverflowTooltip: true },
{ label: '创建时间', prop: 'createTime', align: 'center', width: 160, parseTime: true },
@@ -103,10 +115,18 @@ const searchColumns = [
label: '计费方式',
prop: 'chargeType',
component: 'select',
dict: 'bms_charge_type',
options: Object.keys(calcModeLabelMap).map(value => ({ value, label: calcModeLabelMap[value] })),
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: '状态',
@@ -127,8 +147,8 @@ function queryList(params) {
}
function chargeTypeLabel(val) {
const found = bms_charge_type.value.find(c => c.value === val)
return found ? found.label : (val || '-')
if (!val) return calcModeLabelMap.MANUAL
return calcModeLabelMap[val] || val
}
function countryLabel(code) {
@@ -150,9 +170,6 @@ onMounted(() => {
function formatChargeValue(row) {
if (row.chargeValue == null) return '-'
const v = Number(row.chargeValue)
if (row.chargeType === 'RATE') {
return (v * 100).toFixed(2) + '%'
}
return v + ' ' + (row.currency || 'CNY')
}
@@ -68,11 +68,22 @@ defineProps({
}
})
const { bms_charge_type } = useDict('bms_charge_type')
const chargeTypeLabelMap = {
MANUAL: '暂不计费',
ALWAYS: '每票都收',
POSTCODE: '命中邮编',
ZONE: '命中分区',
EXTRA_KG: '超重续收',
WEIGHT: '超重',
SIZE: '超尺寸',
RETURN: '退件',
FIXED: '每票都收',
RATE: '暂不计费'
}
function chargeTypeLabel(val) {
const found = (bms_charge_type.value || []).find(c => c.value === val)
return found ? found.label : (val || '-')
if (!val) return chargeTypeLabelMap.MANUAL
return chargeTypeLabelMap[val] || chargeTypeLabelMap[String(val).toUpperCase()] || val
}
</script>
@@ -62,8 +62,6 @@ const props = defineProps({
})
const emit = defineEmits(['update:modelValue', 'confirm'])
const { bms_charge_type } = useDict('bms_charge_type')
const tableRef = ref()
const picked = ref([])
@@ -91,9 +89,22 @@ const rows = computed(() => {
}))
})
const chargeTypeLabelMap = {
MANUAL: '暂不计费',
ALWAYS: '每票都收',
POSTCODE: '命中邮编',
ZONE: '命中分区',
EXTRA_KG: '超重续收',
WEIGHT: '超重',
SIZE: '超尺寸',
RETURN: '退件',
FIXED: '每票都收',
RATE: '暂不计费'
}
function chargeTypeLabel(val) {
const found = (bms_charge_type.value || []).find(c => c.value === val)
return found ? found.label : (val || '-')
if (!val) return chargeTypeLabelMap.MANUAL
return chargeTypeLabelMap[val] || chargeTypeLabelMap[String(val).toUpperCase()] || val
}
function onSelectionChange(selection) {