feat(sample): 展示样本状态并支持样本废弃与作废原因

生产/质检入库卡片展示样本状态并支持【样本废弃】;市场 Web 列表与移动市场部卡片补充样本状态及问号查看作废原因;样本表新增 void_desc,人工作废不联动接收但全部作废时自动作废协议(#131)。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-11-19 14:25:24 +08:00
1 parent 7751cc0f4a
commit 0b4c8dfda8
53 files changed
+1527 -82

No files matched your search

@@ -40,6 +40,7 @@ export const LAB_PROCESS_TABS: Array<{
const CELL_HSC_COLUMNS: LabColumn[] = [
{ prop: 'cellCode', label: '细胞编码', minWidth: 140 },
{ prop: 'sampleStatus', label: '样本状态', minWidth: 140 },
{ prop: 'motherName', label: '准妈妈姓名', minWidth: 110 },
{ prop: 'collectionTime', label: '采集时间', minWidth: 200 },
{ prop: 'hospitalName', label: '采集医院', minWidth: 140 },
@@ -72,6 +73,7 @@ const CELL_HSC_COLUMNS: LabColumn[] = [
const DONATION_HSC_COLUMNS: LabColumn[] = [
{ prop: 'cellCode', label: '细胞编码', minWidth: 140 },
{ prop: 'sampleStatus', label: '样本状态', minWidth: 140 },
{ prop: 'motherName', label: '准妈妈姓名', minWidth: 110 },
{ prop: 'labMaterialCode', label: '实验室物料编码', minWidth: 130 },
{ prop: 'inboundCode', label: '入库编码', minWidth: 140 },
@@ -98,6 +100,7 @@ const DONATION_HSC_COLUMNS: LabColumn[] = [
const MSC_COLUMNS: LabColumn[] = [
{ prop: 'labFlowCode', label: '实验室流转编码', minWidth: 140 },
{ prop: 'sampleStatus', label: '样本状态', minWidth: 140 },
{ prop: 'motherName', label: '母亲姓名', minWidth: 110 },
{ prop: 'cordCollectTime', label: '脐带采集时间', minWidth: 200 },
{ prop: 'transportTempC', label: '运输温度/℃', minWidth: 110 },
@@ -14,7 +14,7 @@ import type { ProductionWorkOrderTabKey } from '@/utils/production-work-order-ta
import { resolveTabKeyFromWorkOrder } from '@/utils/production-work-order-tabs'
import { formatMoneyDisplay } from '@/utils/money-format'
export type CardMetaFieldKind = 'text' | 'tag'
export type CardMetaFieldKind = 'text' | 'tag' | 'sample-status'
export type CardMetaField = {
label: string
@@ -84,6 +84,11 @@ function buildInboundMetaFields(tabKey: ProductionWorkOrderTabKey): CardMetaFiel
return [
{ label: '实验室入库编码', getValue: (row) => row.labStorageCode || '—' },
{ label: '样本类型', getValue: (row) => row.sampleTypeName || '—' },
{
label: '样本状态',
kind: 'sample-status',
getValue: (row) => String(row.sampleStatus || '')
},
{ label: '接收经手人', getValue: (row) => row.handlerName || '—' },
{ label: '接收时间', getValue: (row) => formatDisplayOrDash(row.receptionTime) },
{
@@ -63,6 +63,19 @@ describe('flattenProtocolAuditRows', () => {
assert.equal(rows[0].sampleCode, 'ZKZX34000199')
})
it('passes sample status and sample void reason from sample items', () => {
const rows = flattenProtocolAuditRows([
{
id: 'p-status',
voidDesc: '协议作废',
sampleItems: [{ sampleCode: 'S-VOID', sampleStatus: 'yzf', voidDesc: '样本破损' }]
}
])
assert.equal(rows[0].voidDesc, '协议作废')
assert.equal(rows[0].sampleStatus, 'yzf')
assert.equal(rows[0].sampleVoidDesc, '样本破损')
})
it('zero samples → one placeholder row, not co-stored', () => {
const rows = flattenProtocolAuditRows([{ id: 'p2', protocolNo: 'ZKZX2', sampleItems: [] }])
assert.equal(rows.length, 1)
@@ -34,6 +34,9 @@ export type ProtocolAuditFlatRow = {
regionManagerUserName: string
sampleTypeName: string
sampleCode: string
sampleStatus: string
/** 样本作废原因;协议作废原因仍用 voidDesc */
sampleVoidDesc: string
labStorageCode: string
transportType: string
transportLabel: string
@@ -120,6 +123,8 @@ export function flattenProtocolAuditRows(
regionManagerUserName: str(protocol.regionManagerUserName),
sampleTypeName: str(rec.sampleTypeName),
sampleCode: str(rec.sampleCode),
sampleStatus: str(rec.sampleStatus),
sampleVoidDesc: str(rec.voidDesc),
labStorageCode: str(rec.labStorageCode),
transportType,
transportLabel: '',
@@ -16,7 +16,7 @@ import {
type QcWorkOrderProtocolGroupModel
} from '@/utils/qc-work-order-groups'
export type CardMetaFieldKind = 'text' | 'tag'
export type CardMetaFieldKind = 'text' | 'tag' | 'sample-status'
export type CardMetaField = {
label: string
@@ -134,6 +134,12 @@ const inboundGroupedFields: CardMetaField[] = [
visible: (row) => (row.triggerSource || 'reception') === 'production'
},
{ label: '样本编码', getValue: (row) => row.sampleCode || '—', visible: isInboundUserInfoRow },
{
label: '样本状态',
kind: 'sample-status',
getValue: (row) => String(row.sampleStatus || ''),
visible: isInboundUserInfoRow
},
{
label: '样本类型',
getValue: (row) => row.sampleTypeName || '—',
@@ -21,6 +21,8 @@ export type SampleFreightFlatRow = {
motherName?: string
newbornName?: string
sampleCode?: string
sampleStatus?: string
voidDesc?: string
sampleTypeName?: string
sampleId?: string
protocolId?: string
@@ -53,6 +55,8 @@ export function flattenSampleFreights(list: SampleFreight[]): SampleFreightFlatR
motherName: it?.motherName,
newbornName: it?.newbornName,
sampleCode: it?.sampleCode,
sampleStatus: it?.sampleStatus,
voidDesc: it?.voidDesc,
sampleTypeName: it?.sampleTypeName,
sampleId: it?.sampleId,
protocolId: it?.protocolId,
+41
View File
@@ -0,0 +1,41 @@
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { isSampleAlreadyVoided, resolveSampleVoidTarget } from './sample-void'
describe('resolveSampleVoidTarget', () => {
it('uses protocol sample id, code and protocol id', () => {
const target = resolveSampleVoidTarget({
receptionSource: 'cell_storage',
protocolSampleId: 'ps-1',
sampleCode: 'S1',
collectionProtocolId: 'p-1'
})
assert.deepEqual(target, {
receptionSource: 'cell_storage',
sampleId: 'ps-1',
sampleCode: 'S1',
protocolId: 'p-1'
})
})
it('falls back to tab source when row source is empty', () => {
const target = resolveSampleVoidTarget({
sampleCode: 'S2',
fallbackSource: 'research_donation'
})
assert.equal(target?.receptionSource, 'research_donation')
assert.equal(target?.sampleCode, 'S2')
})
it('returns null without a sample identifier', () => {
assert.equal(resolveSampleVoidTarget({ receptionSource: 'cell_storage' }), null)
})
})
describe('isSampleAlreadyVoided', () => {
it('matches yzf only', () => {
assert.equal(isSampleAlreadyVoided('yzf'), true)
assert.equal(isSampleAlreadyVoided(' yzf '), true)
assert.equal(isSampleAlreadyVoided('ycj'), false)
})
})
+29
View File
@@ -0,0 +1,29 @@
import type { SampleVoidTarget } from '../api/business-sample'
export function isSampleAlreadyVoided(status?: string | null): boolean {
return String(status || '').trim() === 'yzf'
}
export function resolveSampleVoidTarget(input: {
receptionSource?: string | null
protocolSampleId?: string | null
sampleCode?: string | null
collectionProtocolId?: string | null
fallbackSource?: string | null
}): SampleVoidTarget | null {
let source = String(input.receptionSource || '').trim()
if (source !== 'cell_storage' && source !== 'research_donation') {
source = String(input.fallbackSource || '').trim()
}
if (source !== 'cell_storage' && source !== 'research_donation') return null
const sampleId = String(input.protocolSampleId || '').trim()
const sampleCode = String(input.sampleCode || '').trim()
const protocolId = String(input.collectionProtocolId || '').trim()
if (!sampleId && !sampleCode) return null
return {
receptionSource: source,
sampleId: sampleId || undefined,
sampleCode: sampleCode || undefined,
protocolId: protocolId || undefined
}
}