diff --git a/src/modules/finance/api/finance.ts b/src/modules/finance/api/finance.ts index 6bdada3e..28e466b4 100644 --- a/src/modules/finance/api/finance.ts +++ b/src/modules/finance/api/finance.ts @@ -66,7 +66,7 @@ function jsonRecords(value: unknown): RawResource[] { function normalizeBill(item: RawResource, customerId = stringValue(item.tenant_id ?? item.customerId)): FinanceBillResource { return { id: stringValue(item.id), billNo: stringValue(item.bill_no ?? item.billNo), customerId, - customerName: stringValue(item.customer_name_snapshot ?? item.customerName) || `客户 ${customerId}`, + customerName: stringValue(item.customer_name_snapshot ?? item.customerName), billDate: stringValue(item.bill_date ?? item.billDate), dueDate: stringValue(item.due_date ?? item.dueDate), currency: 'CNY', totalAmount: numberValue(item.total_amount ?? item.totalAmount), paidAmount: numberValue(item.received_amount ?? item.receivedAmount ?? item.paidAmount), outstandingAmount: numberValue(item.outstanding_amount ?? item.outstandingAmount), status: stringValue(item.status) as FinanceBillResource['status'], diff --git a/src/modules/finance/pages/FinanceReceivableStatisticsView.test.ts b/src/modules/finance/pages/FinanceReceivableStatisticsView.test.ts index 373fe106..d6f1dde1 100644 --- a/src/modules/finance/pages/FinanceReceivableStatisticsView.test.ts +++ b/src/modules/finance/pages/FinanceReceivableStatisticsView.test.ts @@ -9,6 +9,9 @@ describe('receivable statistics page', () => { for (const label of ['统计月份', '应收单位', '应收总额', '已收合计', '余额未收', '打印', '导出Excel']) expect(page).toContain(label) expect(page).toContain("exportType: 'FINANCE_RECEIVABLE_STATISTICS'") expect(page).toContain('window.print()') + expect(page).toContain('displayCustomerName(row)') + expect(page).toContain('/^客户\\s*\\d+$/.test(snapshot)') + expect(page).toContain("return masterName || '—'") for (const excluded of ['FBA直发', 'FBA专线', '零头减免', 'USD', '>编辑<']) expect(page).not.toContain(excluded) }) diff --git a/src/modules/finance/pages/FinanceReceivableStatisticsView.vue b/src/modules/finance/pages/FinanceReceivableStatisticsView.vue index 911d7761..cf2af4c1 100644 --- a/src/modules/finance/pages/FinanceReceivableStatisticsView.vue +++ b/src/modules/finance/pages/FinanceReceivableStatisticsView.vue @@ -32,8 +32,9 @@ const result = ref(null) const canView = computed(() => access.can('platform:finance:receivable-statistics:list')) const canExport = computed(() => access.can('platform:finance:receivable-statistics:export') && access.can('platform:download:list')) const rows = computed(() => result.value?.records ?? []) +const customerNameById = computed(() => new Map(customers.value.map((item) => [String(item.id), item.tenantName]))) const columns: DataTableColumn[] = [ - { key: 'customerName', label: '应收单位', minWidth: 240 }, + { key: 'customerName', label: '应收单位', minWidth: 240, slotName: 'customerName' }, { key: 'currency', label: '币种', width: 100 }, { key: 'totalReceivable', label: '应收总额(CNY)', width: 180, slotName: 'totalReceivable' }, { key: 'totalReceived', label: '已收合计(CNY)', width: 180, slotName: 'totalReceived' }, @@ -63,6 +64,13 @@ function search() { page.value = 1; void load() } function reset() { month.value = defaultMonth; customerId.value = ''; page.value = 1; void load() } function printCurrent() { window.print() } function statisticsRowKey(row: ReceivableStatisticsRow) { return `${row.customerId}:${row.customerName}` } +function displayCustomerName(value: unknown) { + const row = value as ReceivableStatisticsRow + const masterName = customerNameById.value.get(String(row.customerId))?.trim() + const snapshot = row.customerName?.trim() + if (!snapshot || /^客户\s*\d+$/.test(snapshot) || snapshot === String(row.customerId)) return masterName || '—' + return snapshot +} async function exportCurrent() { exporting.value = true try { @@ -98,7 +106,7 @@ onMounted(() => { void loadCustomers(); void load() })

应收款明细

共 {{ result?.totalCustomers ?? 0 }} 个应收单位 · 仅统计CNY正式应收结算单
- +