优化计费逻辑

This commit is contained in:
wuweihua
2026-10-17 01:37:33 +08:00
parent 52f714c760
commit db6f5e882a
29 changed files with 1460 additions and 145 deletions
+63 -39
View File
@@ -5,21 +5,21 @@
:columns="columns"
:search-columns="searchColumns"
:query="queryList"
search-action-align="center"
:search-per-row="4"
row-key="billId"
selection
:page-sizes="[100, 200, 300, 400]"
:page-size="100"
:height="tableHeight"
virtual
>
<template #search-orderNos="{ model }">
<multi-value-input v-model="model.orderNos" placeholder="订单号" width="100%" :search-method="searchOrderNoOptions" />
</template>
<template #search-trackingNos="{ model }">
<multi-value-input v-model="model.trackingNos" placeholder="运单号" width="100%" :search-method="searchTrackingNoOptions" />
</template>
<template #search-transferNos="{ model }">
<multi-value-input v-model="model.transferNos" placeholder="转单号" width="100%" :search-method="searchTransferNoOptions" />
<template #search-orderIdentifiers="{ model }">
<multi-value-input
v-model="model.orderIdentifiers"
placeholder="订单号/运单号/转单号"
width="100%"
:search-method="searchOrderIdentifiers"
/>
</template>
<template #search-customerCodes="{ model }">
<customer-select
@@ -28,8 +28,9 @@
value-key="customerCode"
label-key="customerName"
code-key="customerCode"
placeholder="请输入"
placeholder="客户名称/客户代码/对外代码"
multiple
remote-search
/>
</template>
<template #search-productCodes="{ model }">
@@ -232,19 +233,13 @@ import EditChargeWeightDialog from './components/EditChargeWeightDialog.vue'
import ExcelImportDialog from '@/components/ExcelImportDialog'
import ChargeWeightImportAttachDrawer from './components/ChargeWeightImportAttachDrawer.vue'
// 订单号下拉远程搜索:返回匹配的订单号列表(最多 20 条)
function searchOrderNoOptions(keyword) {
return listOrderNoOptions(keyword).then(res => res.data || [])
}
// 运单号下拉远程搜索
function searchTrackingNoOptions(keyword) {
return listTrackingNoOptions(keyword).then(res => res.data || [])
}
// 转单号下拉远程搜索
function searchTransferNoOptions(keyword) {
return listTransferNoOptions(keyword).then(res => res.data || [])
// 单号下拉:订单号、运单号、转单号合并候选
function searchOrderIdentifiers(keyword) {
return Promise.all([
listOrderNoOptions(keyword).then(res => res.data || []),
listTrackingNoOptions(keyword).then(res => res.data || []),
listTransferNoOptions(keyword).then(res => res.data || [])
]).then(groups => [...new Set(groups.flat().map(v => String(v)))])
}
// 产品下拉选项:复用 ProductSelect 的模块级产品缓存(全应用只拉一次)
@@ -257,6 +252,37 @@ const productOptions = computed(() =>
)
const tableRef = ref()
const tableHeight = ref(480)
let tableResizeObserver = null
function updateTableHeight() {
const tableEl = document.querySelector('.billing-bill > .basic-table .el-table, .billing-bill > .basic-table .basic-table-virtual')
if (!tableEl) return
const top = tableEl.getBoundingClientRect().top
const paginationReserve = 58
const bottomGap = 12
tableHeight.value = Math.max(240, Math.floor(window.innerHeight - top - paginationReserve - bottomGap))
}
onMounted(() => {
nextTick(() => {
updateTableHeight()
const form = document.querySelector('.billing-bill > .basic-table .basic-form')
if (form && typeof ResizeObserver !== 'undefined') {
tableResizeObserver = new ResizeObserver(() => updateTableHeight())
tableResizeObserver.observe(form)
}
})
window.addEventListener('resize', updateTableHeight)
})
onBeforeUnmount(() => {
window.removeEventListener('resize', updateTableHeight)
if (tableResizeObserver) {
tableResizeObserver.disconnect()
tableResizeObserver = null
}
})
const open = ref(false)
const title = ref('计费详情')
const loading = ref(false)
@@ -286,7 +312,7 @@ const recalcDialogOpen = ref(false)
const recalcMode = ref('PRODUCT')
const columns = [
{ label: '订单号', prop: 'orderNo', minWidth: 140, showOverflowTooltip: true },
{ label: '订单号', prop: 'orderNo', width: 160, fixed: 'left', showOverflowTooltip: true },
{ label: '运单号', prop: 'trackingNo', minWidth: 140, showOverflowTooltip: true },
{ label: '转单号', prop: 'transferNo', minWidth: 140, showOverflowTooltip: true },
{ label: '客户', prop: 'customerName', minWidth: 140, showOverflowTooltip: true },
@@ -320,19 +346,16 @@ const refundStatusOptions = [
{ label: '未退费', value: 'NONE' },
{ label: '已退费', value: 'REFUNDED' }
]
/** billing_fail_status: 0 success / 1 product / 2 country / 3 weight */
const billingFailStatusOptions = [
{ label: '\u8ba1\u8d39\u6210\u529f', value: 0 },
{ label: '\u672a\u5339\u914d\u4ea7\u54c1', value: 1 },
{ label: '\u672a\u5339\u914d\u56fd\u5bb6', value: 2 },
{ label: '\u672a\u5339\u914d\u91cd\u91cf\u6bb5', value: 3 }
{ label: '计费成功', value: 0 },
{ label: '未匹配产品', value: 1 },
{ label: '未匹配国家', value: 2 },
{ label: '未匹配重量段', value: 3 },
]
const searchColumns = [
{ label: '订单号', prop: 'orderNos', placeholder: '订单号' },
{ label: '运单号', prop: 'trackingNos', placeholder: '运单号' },
{ label: '转单号', prop: 'transferNos', placeholder: '转单号' },
{ label: '客户', prop: 'customerCodes', placeholder: '客户代码' },
{ label: '单号', prop: 'orderIdentifiers', placeholder: '订单号/运单号/转单号' },
{ label: '客户', prop: 'customerCodes', placeholder: '客户名称/客户代码/对外代码' },
{ label: '产品代码', prop: 'productCodes', placeholder: '产品代码' },
{
label: '额度欠费',
@@ -443,7 +466,8 @@ function onDetailUpdated(data) {
function hasBatchFeeQuery(q) {
const hasArr = (arr) => Array.isArray(arr) && arr.some(v => v != null && String(v).trim() !== '')
return hasArr(q.orderNos)
return hasArr(q.orderIdentifiers)
|| hasArr(q.orderNos)
|| hasArr(q.trackingNos)
|| hasArr(q.transferNos)
|| hasArr(q.customerCodes)
@@ -488,6 +512,7 @@ function buildRecalcPayload() {
orderNos: rest.orderNos || [],
trackingNos: rest.trackingNos || [],
transferNos: rest.transferNos || [],
orderIdentifiers: rest.orderIdentifiers || [],
customerCodes: rest.customerCodes || [],
productCodes: rest.productCodes || [],
creditArrearsStatus: rest.creditArrearsStatus || undefined
@@ -578,6 +603,7 @@ function buildChargeWeightTemplateQuery() {
orderNos: rest.orderNos || [],
trackingNos: rest.trackingNos || [],
transferNos: rest.transferNos || [],
orderIdentifiers: rest.orderIdentifiers || [],
customerCodes: rest.customerCodes || [],
productCodes: rest.productCodes || [],
creditArrearsStatus: rest.creditArrearsStatus || undefined
@@ -691,15 +717,13 @@ function formatWeight(val) {
function billingFailLabel(status) {
const code = status == null ? 0 : Number(status)
if (code === 1) return '未匹配产品'
if (code === 2) return '未匹配国家'
if (code === 3) return '未匹配重量段'
return '计费成功'
const hit = billingFailStatusOptions.find(item => item.value === code)
return hit ? hit.label : '未知失败'
}
function billingFailTagType(status) {
const code = status == null ? 0 : Number(status)
if (code === 1 || code === 2 || code === 3) return 'danger'
if (code > 0) return 'danger'
return 'success'
}