fix(pl): 用合同与来源主体信息替代用量追踪表中的技术标识。

This commit is contained in:
wuzilong committed 2026-11-01 22:10:59 +08:00
1 parent 72cf0d9c3d
commit da56a1e319
5 files changed
+118 -6

No files matched your search

@@ -289,3 +289,74 @@ test('contract type tags translate all server values and legacy framework', () =
assert.equal(renderLabel({ contractType }, ...Object.values(statisticsLabels)), label)
}
})
test('usage trace renders business columns and resolves contract/product by their exact identity', () => {
const sfc = parse(
readFileSync(
new URL('../src/views/pl/quota-statistics/StatisticsDetail.vue', import.meta.url),
'utf8'
)
).descriptor
const source = ts.createSourceFile(
'detail.ts',
sfc.scriptSetup!.content,
ts.ScriptTarget.Latest,
true
)
const code = ts.transpile(
source.statements
.filter((s) => !ts.isImportDeclaration(s))
.map((s) => s.getText(source))
.join('\n'),
{ target: ts.ScriptTarget.ESNext }
)
const detail = {
contracts: [
{
id: 'other-contract',
contractNo: '不匹配合同',
products: [{ contractProductId: 'product-id', model: '不匹配规格' }]
},
{
id: 'contract-id',
contractNo: 'HT-2026-01',
products: [{ contractProductId: 'product-id', model: '98%' }]
}
],
usageItems: [
{
id: 'usage-id',
contractId: 'contract-id',
contractProductId: 'product-id',
stopId: 'stop-id',
stopProductId: 'stop-product-id',
planNo: 'PL-001',
stopType: 'delivery',
productName: '硫酸',
partyName: '本段客户',
address: '本段地址'
},
{ id: 'missing', contractId: 'missing', contractProductId: 'product-id', stopType: 'load' }
]
}
const rows = new Function(
'defineProps',
'computed',
`${code}; return typeof usageRows === 'undefined' ? undefined : usageRows.value`
)(() => ({ mode: 'certificate', detail }), vue.computed)
assert.ok(rows, '追踪表应提供可读的业务列')
assert.deepEqual(
rows.map((r: any) => [r.contractNo, r.productModel, r.partyName, r.address]),
[
['HT-2026-01', '98%', '本段客户', '本段地址'],
['—', '—', '—', '—']
]
)
const table = sfc.template!.content.match(/<el-table :data="usageRows"[\s\S]*?<\/el-table>/)![0]
const props = [...table.matchAll(/<el-table-column prop="([^"]+)"/g)].map((m) => m[1])
assert.ok(['contractNo', 'productModel', 'partyName', 'address'].every((p) => props.includes(p)))
assert.ok(!props.some((p) => /Id$/.test(p)))
assert.ok(!table.includes('row.stopId'))
const stopExpression = table.match(/<el-tag size="small">\s*\{\{([\s\S]*?)\}\}/)![1]
assert.equal(new Function('row', `return (${stopExpression})`)(rows[0]), '送货')
})