diff --git a/web-admin/src/utils/protocol-audit-flatten.test.ts b/web-admin/src/utils/protocol-audit-flatten.test.ts index 7b54ceb7..97213d6e 100644 --- a/web-admin/src/utils/protocol-audit-flatten.test.ts +++ b/web-admin/src/utils/protocol-audit-flatten.test.ts @@ -26,6 +26,8 @@ describe('flattenProtocolAuditRows', () => { id: 'p1', protocolNo: 'ZKZX1', motherName: '郭梦朵', + projectName: '测试项目', + teamName: '陈星项目组111', sampleCollectTime: '2025-09-15 08:51:00', sampleItems: [ { sampleTypeName: '脐带血', sampleCode: 'A1', labStorageCode: 'B0000004' }, @@ -40,6 +42,25 @@ describe('flattenProtocolAuditRows', () => { assert.equal(rows[0].labStorageCode, 'B0000004') assert.equal(rows[1].labStorageCode, 'B0000004A') assert.equal(rows[0].protocolId, 'p1') + assert.equal(rows[0].projectName, '测试项目') + assert.equal(rows[0].teamName, '陈星项目组111') + assert.equal(rows[1].projectName, '测试项目') + assert.equal(rows[1].teamName, '陈星项目组111') + }) + + it('copies protocol project attribution onto each flat row for table props', () => { + const rows = flattenProtocolAuditRows([ + { + id: 'p-attr', + projectName: '归属项目', + teamName: '归属项目组', + sampleItems: [{ sampleCode: 'ZKZX34000199', sampleTypeName: '围产期造血干细胞' }] + } + ]) + assert.equal(rows.length, 1) + assert.equal(rows[0].projectName, '归属项目') + assert.equal(rows[0].teamName, '归属项目组') + assert.equal(rows[0].sampleCode, 'ZKZX34000199') }) it('zero samples → one placeholder row, not co-stored', () => { diff --git a/web-admin/src/utils/protocol-audit-flatten.ts b/web-admin/src/utils/protocol-audit-flatten.ts index 9aa627e4..b64fb7c5 100644 --- a/web-admin/src/utils/protocol-audit-flatten.ts +++ b/web-admin/src/utils/protocol-audit-flatten.ts @@ -20,6 +20,9 @@ export type ProtocolAuditFlatRow = { sampleCount: number sampleIndex: number isCoStored: boolean + /** 协议级项目归属,供扁平行表格 prop 绑定 */ + projectName: string + teamName: string collectDate: string sampleCollectTime: string motherName: string @@ -95,6 +98,8 @@ export function flattenProtocolAuditRows( sampleCount, sampleIndex, isCoStored, + projectName: str(protocol.projectName), + teamName: str(protocol.teamName), collectDate: extractCollectDate(str(protocol.sampleCollectTime)), sampleCollectTime: str(protocol.sampleCollectTime), motherName: str(protocol.motherName),