From 8a8ababcc0bba7485c890bc95d1ee87546311202 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Mon, 31 Aug 2026 14:58:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(web-admin):=20=E7=94=9F=E4=BA=A7=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E6=8E=A5=E7=A7=8D=E9=87=8F=E6=94=B9=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E3=80=81=E5=86=BB=E5=AD=98=E6=97=B6=E9=97=B4=E6=94=B9=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 字段 kind 与只读格式对齐产品:自由文本接种量、冻存仅 YYYY-MM-DD。 Co-authored-by: Cursor --- ...sample-production-reception-fields.test.ts | 34 +++++++++++++++++++ .../sample-production-reception-fields.ts | 17 +++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 web-admin/src/utils/sample-production-reception-fields.test.ts diff --git a/web-admin/src/utils/sample-production-reception-fields.test.ts b/web-admin/src/utils/sample-production-reception-fields.test.ts new file mode 100644 index 00000000..57e486bd --- /dev/null +++ b/web-admin/src/utils/sample-production-reception-fields.test.ts @@ -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') + }) +}) diff --git a/web-admin/src/utils/sample-production-reception-fields.ts b/web-admin/src/utils/sample-production-reception-fields.ts index dac14990..045a07b1 100644 --- a/web-admin/src/utils/sample-production-reception-fields.ts +++ b/web-admin/src/utils/sample-production-reception-fields.ts @@ -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