export type ProtocolSourceAttachmentMeta = { label: string files: Array> } function normalizeAttachmentFiles(raw: unknown): Array> { if (!Array.isArray(raw)) return [] return raw.filter((item) => item && typeof item === 'object') as Array> } /** 按来源返回协议级主附件标签与文件列表(细胞存储=孕妇健康调查表,科研捐赠=传染病检测报告) */ export function getSourceProtocolAttachment( row: Record ): 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 ): ProtocolSourceAttachmentMeta { return { label: '知情同意书', files: normalizeAttachmentFiles(row.consentAttachmentFiles) } } /** * 样本接收弹窗:按来源返回质检需查看的协议附件分组。 * 细胞存储:仅知情同意书 / 孕妇健康调查表(不展示「协议附件」项) * 科研捐赠:知情同意书 / 传染病检测报告 / 其他附件 */ export function getSourceProtocolAttachmentGroups( row: Record ): 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 ?? row.otherAttachmentFiles) } ] } return [ { label: '知情同意书', files: normalizeAttachmentFiles(row.consentAttachmentFiles) }, { label: '孕妇健康调查表', files: normalizeAttachmentFiles(row.healthSurveyAttachmentFiles) } ] }