临时保存知情同意书PDF列表

This commit is contained in:
xianyi
2025-12-24 15:04:54 +08:00
parent e5ea1ab45e
commit e118538557
3 changed files with 124 additions and 7 deletions

View File

@@ -86,3 +86,55 @@ export const isExamActionDone = (examId: string | number, action: keyof ExamActi
return record?.[action] === true;
};
/**
* 知情同意书PDF信息
*/
export interface TongyishuPdfInfo {
/** PDF文件名称 */
pdf_name: string;
/** PDF文件地址 */
pdf_url: string;
/** 组合代码 */
combination_code?: number | null;
}
/**
* 获取知情同意书PDF列表的存储 key
*/
export const getTongyishuPdfListKey = (examId: string | number): string => {
const today = getTodayString();
return `yh_tongyishu_pdf_list_${today}_${examId}`;
};
/**
* 存储知情同意书PDF列表
*/
export const setTongyishuPdfList = (
examId: string | number,
pdfList: TongyishuPdfInfo[]
): void => {
if (typeof window === 'undefined') return;
const key = getTongyishuPdfListKey(examId);
localStorage.setItem(key, JSON.stringify(pdfList));
};
/**
* 获取知情同意书PDF列表
*/
export const getTongyishuPdfList = (examId: string | number): TongyishuPdfInfo[] | null => {
if (typeof window === 'undefined') return null;
const key = getTongyishuPdfListKey(examId);
const raw = localStorage.getItem(key);
if (!raw) return null;
try {
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed as TongyishuPdfInfo[] : null;
} catch (err) {
console.warn('知情同意书PDF列表解析失败', err);
return null;
}
};