27 lines
940 B
TypeScript
27 lines
940 B
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)
|
|
}
|
|
}
|