feat(web-admin): 生产接收接种量改文本、冻存时间改日期展示
字段 kind 与只读格式对齐产品:自由文本接种量、冻存仅 YYYY-MM-DD。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
431d7b9835
commit
8a8ababcc0
2 files changed
+47
-4
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
resolveProductionReceptionFields,
|
||||
formatProductionFieldValue,
|
||||
type ProductionReceptionRecord
|
||||
} from './sample-production-reception-fields'
|
||||
|
||||
describe('inoculationAmount / cryopreservationTime field kinds', () => {
|
||||
it('marks inoculationAmount as text and cryopreservationTime as date for UC-MSC profiles', () => {
|
||||
for (const source of ['cell_storage', 'research_donation'] as const) {
|
||||
const fields = resolveProductionReceptionFields(source, '脐带间充质干细胞')
|
||||
const inoc = fields.find((f) => f.key === 'inoculationAmount')
|
||||
const cryo = fields.find((f) => f.key === 'cryopreservationTime')
|
||||
assert.ok(inoc)
|
||||
assert.equal(inoc.kind, 'text')
|
||||
assert.equal(inoc.maxLength, 255)
|
||||
assert.ok(cryo)
|
||||
assert.equal(cryo.kind, 'date')
|
||||
}
|
||||
})
|
||||
|
||||
it('formats free-text inoculation and date-only cryopreservation', () => {
|
||||
const fields = resolveProductionReceptionFields('cell_storage', '脐带间充质干细胞')
|
||||
const inoc = fields.find((f) => f.key === 'inoculationAmount')!
|
||||
const cryo = fields.find((f) => f.key === 'cryopreservationTime')!
|
||||
const record: ProductionReceptionRecord = {
|
||||
inoculationAmount: '约 5×10⁶ cells,接种体积 2ml',
|
||||
cryopreservationTime: '2026-07-14 15:30:00'
|
||||
}
|
||||
assert.equal(formatProductionFieldValue(inoc, record), '约 5×10⁶ cells,接种体积 2ml')
|
||||
assert.equal(formatProductionFieldValue(cryo, record), '2026-07-14')
|
||||
})
|
||||
})
|
||||
@@ -22,7 +22,8 @@ export type ProductionReceptionFieldKey =
|
||||
export type ProductionReceptionFieldDef = {
|
||||
key: ProductionReceptionFieldKey
|
||||
label: string
|
||||
kind: 'number' | 'text' | 'datetime' | 'select' | 'integer'
|
||||
kind: 'number' | 'text' | 'datetime' | 'date' | 'select' | 'integer'
|
||||
maxLength?: number
|
||||
selectOptions?: Array<{ label: string; value: string }>
|
||||
}
|
||||
|
||||
@@ -47,8 +48,13 @@ const FIELD_DEFS: Record<ProductionReceptionFieldKey, ProductionReceptionFieldDe
|
||||
label: '冻存液用量/ml',
|
||||
kind: 'number'
|
||||
},
|
||||
inoculationAmount: { key: 'inoculationAmount', label: '接种量', kind: 'number' },
|
||||
cryopreservationTime: { key: 'cryopreservationTime', label: '冻存时间', kind: 'datetime' },
|
||||
inoculationAmount: {
|
||||
key: 'inoculationAmount',
|
||||
label: '接种量',
|
||||
kind: 'text',
|
||||
maxLength: 255
|
||||
},
|
||||
cryopreservationTime: { key: 'cryopreservationTime', label: '冻存时间', kind: 'date' },
|
||||
storageTotalTubes: { key: 'storageTotalTubes', label: '储存总量(管)', kind: 'integer' },
|
||||
availableCellCount1e7: {
|
||||
key: 'availableCellCount1e7',
|
||||
@@ -113,7 +119,7 @@ export type ProductionReceptionRecord = {
|
||||
infectiousFourTestResultLabel?: string
|
||||
enrichedBloodWeightG?: number
|
||||
cryopreservationVolumeMl?: number
|
||||
inoculationAmount?: number
|
||||
inoculationAmount?: string
|
||||
cryopreservationTime?: string
|
||||
storageTotalTubes?: number
|
||||
availableCellCount1e7?: number
|
||||
@@ -147,5 +153,8 @@ export function formatProductionFieldValue(
|
||||
if (def.kind === 'datetime') {
|
||||
return formatDateTimeDisplay(String(raw)) || '—'
|
||||
}
|
||||
if (def.kind === 'date') {
|
||||
return formatDateOnly(String(raw)) || '—'
|
||||
}
|
||||
return String(raw)
|
||||
}
|
||||
Reference in new issue
Block a user