质检样本接收列表与弹窗需查看采集协议侧附件。后端待接收/已接收列表补齐协议附件字段;前端列表增加知情同意书缩略图,接收弹窗右侧改为上运输、下协议附件分组展示。 关联 cykj/zkxw#43 Co-authored-by: Cursor <cursoragent@cursor.com>
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
export type ProtocolSourceAttachmentMeta = {
|
|
label: string
|
|
files: Array<Record<string, unknown>>
|
|
}
|
|
|
|
function normalizeAttachmentFiles(raw: unknown): Array<Record<string, unknown>> {
|
|
if (!Array.isArray(raw)) return []
|
|
return raw.filter((item) => item && typeof item === 'object') as Array<Record<string, unknown>>
|
|
}
|
|
|
|
/** 按来源返回协议级主附件标签与文件列表(细胞存储=孕妇健康调查表,科研捐赠=传染病检测报告) */
|
|
export function getSourceProtocolAttachment(
|
|
row: Record<string, unknown>
|
|
): ProtocolSourceAttachmentMeta {
|
|
const source = String(row.sourceType || 'cell_storage').trim()
|
|
if (source === 'research_donation') {
|
|
return {
|
|
label: '传染病检测报告',
|
|
files: normalizeAttachmentFiles(row.infectiousDiseaseReportAttachmentFiles)
|
|
}
|
|
}
|
|
return {
|
|
label: '孕妇健康调查表',
|
|
files: normalizeAttachmentFiles(row.healthSurveyAttachmentFiles)
|
|
}
|
|
}
|
|
|
|
/** 知情同意书(细胞存储与科研捐赠共用字段) */
|
|
export function getConsentProtocolAttachment(
|
|
row: Record<string, unknown>
|
|
): ProtocolSourceAttachmentMeta {
|
|
return {
|
|
label: '知情同意书',
|
|
files: normalizeAttachmentFiles(row.consentAttachmentFiles)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 样本接收弹窗:按来源返回质检需查看的协议附件分组。
|
|
* 细胞存储:协议附件 / 知情同意书 / 孕妇健康调查表
|
|
* 科研捐赠:知情同意书 / 传染病检测报告 / 其他附件
|
|
*/
|
|
export function getSourceProtocolAttachmentGroups(
|
|
row: Record<string, unknown>
|
|
): ProtocolSourceAttachmentMeta[] {
|
|
const source = String(row.sourceType || 'cell_storage').trim()
|
|
if (source === 'research_donation') {
|
|
return [
|
|
{
|
|
label: '知情同意书',
|
|
files: normalizeAttachmentFiles(row.consentAttachmentFiles)
|
|
},
|
|
{
|
|
label: '传染病检测报告',
|
|
files: normalizeAttachmentFiles(row.infectiousDiseaseReportAttachmentFiles)
|
|
},
|
|
{
|
|
label: '其他附件',
|
|
files: normalizeAttachmentFiles(row.attachmentFiles)
|
|
}
|
|
]
|
|
}
|
|
return [
|
|
{
|
|
label: '协议附件',
|
|
files: normalizeAttachmentFiles(row.protocolAttachmentFiles)
|
|
},
|
|
{
|
|
label: '知情同意书',
|
|
files: normalizeAttachmentFiles(row.consentAttachmentFiles)
|
|
},
|
|
{
|
|
label: '孕妇健康调查表',
|
|
files: normalizeAttachmentFiles(row.healthSurveyAttachmentFiles)
|
|
}
|
|
]
|
|
}
|