临时保存知情同意书PDF列表
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user