fix(web-admin): 恢复采集大表导出并按运费批次归拢合并
去掉临时隐藏开关,导出自存/科研表时先按运费批次聚拢再合并单元格。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
95d6b6025f
commit
3ac30a6c2c
5 files changed
+152
-26
No files matched your search
@@ -10,7 +10,8 @@ import {
|
||||
buildFreightMergeRanges,
|
||||
buildPresignLedgerRows,
|
||||
buildResearchLedgerRows,
|
||||
formatLedgerDateTime
|
||||
formatLedgerDateTime,
|
||||
groupFlatRowsByFreightBatch
|
||||
} from './collection-ledger-export'
|
||||
import type { ProtocolAuditFlatRow } from './protocol-audit-flatten'
|
||||
|
||||
@@ -194,6 +195,71 @@ describe('buildCellStorageLedgerRows', () => {
|
||||
{ startRow: 2, endRow: 3, startCol: 54, endCol: 54 }
|
||||
])
|
||||
})
|
||||
|
||||
it('groups non-adjacent same freight batch before merging cells', () => {
|
||||
const shared = {
|
||||
protocol: { protocolStatus: 'sxz', remark: '', voidType: '', voidDesc: '' },
|
||||
sampleCollectTime: '2025-09-11 18:13:00',
|
||||
sampleTypeName: 'NK',
|
||||
regionName: '常州',
|
||||
hospitalName: '溧阳市人民医院',
|
||||
freightTransportLabel: '专线车',
|
||||
freightAmountLabel: '100'
|
||||
}
|
||||
const { rows, merges } = buildCellStorageLedgerRows([
|
||||
{
|
||||
...shared,
|
||||
motherName: '甲',
|
||||
sampleCode: 'S1',
|
||||
labStorageCode: 'UBMC1',
|
||||
freightId: 'batch-cell'
|
||||
} as unknown as ProtocolAuditFlatRow,
|
||||
{
|
||||
...shared,
|
||||
motherName: '丙',
|
||||
sampleCode: 'S3',
|
||||
labStorageCode: 'UBMC3',
|
||||
freightId: 'other',
|
||||
freightTransportLabel: '快递',
|
||||
freightAmountLabel: '25'
|
||||
} as unknown as ProtocolAuditFlatRow,
|
||||
{
|
||||
...shared,
|
||||
motherName: '乙',
|
||||
sampleCode: 'S2',
|
||||
labStorageCode: 'UBMC2',
|
||||
freightId: 'batch-cell'
|
||||
} as unknown as ProtocolAuditFlatRow
|
||||
])
|
||||
assert.equal(rows[0][8], '甲')
|
||||
assert.equal(rows[1][8], '乙')
|
||||
assert.equal(rows[2][8], '丙')
|
||||
assert.equal(rows[0][52], '专线车')
|
||||
assert.equal(rows[0][53], '100')
|
||||
assert.equal(rows[1][52], '')
|
||||
assert.equal(rows[1][53], '')
|
||||
assert.equal(rows[2][52], '快递')
|
||||
assert.equal(rows[2][53], '25')
|
||||
assert.deepEqual(merges, [
|
||||
{ startRow: 2, endRow: 3, startCol: 53, endCol: 53 },
|
||||
{ startRow: 2, endRow: 3, startCol: 54, endCol: 54 }
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('groupFlatRowsByFreightBatch', () => {
|
||||
it('keeps first-seen batch order and leaves empty freight rows in place', () => {
|
||||
const arranged = groupFlatRowsByFreightBatch([
|
||||
{ motherName: 'A', freightId: 'f1' },
|
||||
{ motherName: 'B', freightId: '' },
|
||||
{ motherName: 'C', freightId: 'f1' },
|
||||
{ motherName: 'D', freightId: 'f2' }
|
||||
] as unknown as ProtocolAuditFlatRow[])
|
||||
assert.deepEqual(
|
||||
arranged.map((row) => row.motherName),
|
||||
['A', 'C', 'B', 'D']
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildResearchLedgerRows', () => {
|
||||
@@ -335,6 +401,50 @@ describe('buildResearchLedgerRows', () => {
|
||||
{ startRow: 3, endRow: 4, startCol: 18, endCol: 18 }
|
||||
])
|
||||
})
|
||||
|
||||
it('groups non-adjacent same freight batch before merging research cells', () => {
|
||||
const shared = {
|
||||
protocol: { donationStatus: 'sxz', voidType: '', voidDesc: '', monthlyVerifyNo: '' },
|
||||
sampleCollectTime: '2025-09-11 18:13:00',
|
||||
sampleTypeName: 'NK',
|
||||
regionName: '常州',
|
||||
hospitalName: '溧阳市人民医院',
|
||||
freightTransportLabel: '专线车',
|
||||
freightAmountLabel: '100'
|
||||
}
|
||||
const { rows, merges } = buildResearchLedgerRows([
|
||||
{
|
||||
...shared,
|
||||
motherName: '甲',
|
||||
labStorageCode: 'A1',
|
||||
freightId: 'batch-a'
|
||||
} as unknown as ProtocolAuditFlatRow,
|
||||
{
|
||||
...shared,
|
||||
motherName: '散',
|
||||
labStorageCode: 'A9',
|
||||
freightId: '',
|
||||
freightTransportLabel: '',
|
||||
freightAmountLabel: ''
|
||||
} as unknown as ProtocolAuditFlatRow,
|
||||
{
|
||||
...shared,
|
||||
motherName: '乙',
|
||||
labStorageCode: 'A2',
|
||||
freightId: 'batch-a'
|
||||
} as unknown as ProtocolAuditFlatRow
|
||||
])
|
||||
assert.equal(rows[0][8], '甲')
|
||||
assert.equal(rows[1][8], '乙')
|
||||
assert.equal(rows[2][8], '散')
|
||||
assert.equal(rows[0][16], '专线车')
|
||||
assert.equal(rows[1][16], '')
|
||||
assert.equal(rows[1][17], '')
|
||||
assert.deepEqual(merges, [
|
||||
{ startRow: 2, endRow: 3, startCol: 17, endCol: 17 },
|
||||
{ startRow: 2, endRow: 3, startCol: 18, endCol: 18 }
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildCustomerServiceLedgerRows', () => {
|
||||
|
||||
Reference in new issue
Block a user