From 72cf0d9c3decabeb2d2daff1d1be0309804fbfe0 Mon Sep 17 00:00:00 2001 From: wuzilong <704541015@qq.com> Date: Sun, 1 Nov 2026 22:08:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(pl):=20=E4=BF=AE=E6=AD=A3=E5=90=88=E5=90=8C?= =?UTF-8?q?=E9=A2=9D=E5=BA=A6=E7=BB=9F=E8=AE=A1=E4=B8=AD=E7=9A=84=E9=94=80?= =?UTF-8?q?=E5=94=AE=E5=8F=8A=E6=A1=86=E6=9E=B6=E5=90=88=E5=90=8C=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=96=87=E6=A1=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-admin/scripts/quota-statistics.test.ts | 28 +++++++++++++++++++ .../pl/quota-statistics/StatisticsPanel.vue | 8 ++---- .../src/views/pl/quota-statistics/labels.ts | 11 ++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/web-admin/scripts/quota-statistics.test.ts b/web-admin/scripts/quota-statistics.test.ts index eacb6020e..6d62e958c 100644 --- a/web-admin/scripts/quota-statistics.test.ts +++ b/web-admin/scripts/quota-statistics.test.ts @@ -261,3 +261,31 @@ test('statistics API maps each view to the server endpoint and preserves respons ) assert.deepEqual(calls[1].options.params, { certType: 'transport', pageSize: 20 }) }) + +import * as statisticsLabels from '../src/views/pl/quota-statistics/labels' +test('contract type tags translate all server values and legacy framework', () => { + const template = parse( + readFileSync( + new URL('../src/views/pl/quota-statistics/StatisticsPanel.vue', import.meta.url), + 'utf8' + ) + ).descriptor.template!.content + const expression = template.match( + /v-else-if="column.prop === 'contractType'"[^>]*>\s*\{\{([\s\S]*?)\}\}/ + )![1] + const renderLabel = new Function( + 'row', + ...Object.keys(statisticsLabels), + `return (${expression})` + ) + for (const [contractType, label] of Object.entries({ + sale: '销售合同', + purchase: '采购合同', + framework_sale: '框架销售合同', + framework_purchase: '框架采购合同', + framework: '框架合同', + '': '—' + })) { + assert.equal(renderLabel({ contractType }, ...Object.values(statisticsLabels)), label) + } +}) diff --git a/web-admin/src/views/pl/quota-statistics/StatisticsPanel.vue b/web-admin/src/views/pl/quota-statistics/StatisticsPanel.vue index dcfb0902d..b8d6491f5 100644 --- a/web-admin/src/views/pl/quota-statistics/StatisticsPanel.vue +++ b/web-admin/src/views/pl/quota-statistics/StatisticsPanel.vue @@ -113,11 +113,7 @@ :type="row.status === 'active' ? 'success' : 'info'" >{{ statusLabel(row.status) }}{{ - row.contractType === 'purchase' - ? '采购合同' - : row.contractType === 'sales' - ? '销售合同' - : row.contractType || '—' + contractTypeLabel(row.contractType) }}{{ row[column.prop] ?? '—' }} @@ -161,7 +157,7 @@ import ContractScopeDialog from '../quota-cert/ContractScopeDialog.vue' import StatisticsDetail from './StatisticsDetail.vue' import { createStatisticsLoader } from './loader' - import { statusLabel } from './labels' + import { statusLabel, contractTypeLabel } from './labels' const props = withDefaults( defineProps<{ mode: 'contract' | 'certificate' diff --git a/web-admin/src/views/pl/quota-statistics/labels.ts b/web-admin/src/views/pl/quota-statistics/labels.ts index 192baf5ba..0566013f7 100644 --- a/web-admin/src/views/pl/quota-statistics/labels.ts +++ b/web-admin/src/views/pl/quota-statistics/labels.ts @@ -12,3 +12,14 @@ export const statusLabel = (value: string) => consumed: '已核销', cancelled: '已取消' })[value] || value + +export const contractTypeLabel = (value?: string | null) => + ({ + sale: '销售合同', + purchase: '采购合同', + framework_sale: '框架销售合同', + framework_purchase: '框架采购合同', + framework: '框架合同' + })[value || ''] || + value || + '—'