知情同意书签名

This commit is contained in:
xianyi
2026-01-06 17:48:38 +08:00
parent 973f5338af
commit c23c0ff663

View File

@@ -3,7 +3,7 @@ import * as pdfjsLib from 'pdfjs-dist';
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
import type { OutputTongyishuFileInfo } from '../../api';
import { getTongyishuPdf, signInMedicalExamCenter, submitTongyishuSign, submitDaojiandanSign, editDaojiandanPrintStatus, getDaojiandanPdf as getDaojiandanPdfApi, getAddItemBillPdf as getAddItemBillPdfApi, submitAddItemBillSign } from '../../api';
import { getTongyishuPdf, signInMedicalExamCenter, submitTongyishuSign, submitDaojiandanSign, editDaojiandanPrintStatus, getDaojiandanPdf as getDaojiandanPdfApi, submitAddItemBillSign } from '../../api';
import {
setExamActionRecord,
setTongyishuPdfList,
@@ -95,27 +95,10 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
return () => onBusyChange?.(false);
}, [busy, onBusyChange]);
const SIGN_STORAGE_KEY = `yh_signed_consents_${new Date().toISOString().slice(0, 10)}`;
const handlePickFile = () => {
fileInputRef.current?.click();
};
useEffect(() => {
if (typeof window === 'undefined') return;
const raw = localStorage.getItem(SIGN_STORAGE_KEY);
if (raw) {
try {
const parsed = JSON.parse(raw);
if (Array.isArray(parsed)) {
setSignedCombinationCodes(parsed.filter((x) => typeof x === 'number'));
}
} catch (err) {
console.warn('签名记录解析失败', err);
}
}
}, []);
const convertToJpg = async (file: File): Promise<File> => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@@ -244,11 +227,7 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
setSignedCombinationCodes((prev) => {
const code = Number(previewPdf.combination_code);
if (!Number.isFinite(code)) return prev || [];
const next = Array.from(new Set([...(prev || []), code]));
if (typeof window !== 'undefined') {
localStorage.setItem(SIGN_STORAGE_KEY, JSON.stringify(next));
}
return next;
return Array.from(new Set([...(prev || []), code]));
});
setTimeout(() => {
setShowSignature(false);
@@ -278,6 +257,12 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
// 先检查 localStorage 中是否有已签名的知情同意书
const storedList = getTongyishuPdfList(examId);
const signedFromStored =
storedList
?.filter((pdf) => pdf.is_signed === true && pdf.combination_code !== null && pdf.combination_code !== undefined)
.map((pdf) => Number(pdf.combination_code))
.filter((n) => Number.isFinite(n)) || [];
setSignedCombinationCodes(signedFromStored);
const allSigned = storedList && storedList.length > 0 && storedList.every((pdf) => pdf.is_signed === true);
// 如果所有知情同意书都已签名,直接使用 localStorage 中的数据,不请求接口
@@ -1921,7 +1906,6 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
{addItemBillList.length > 0 &&
addItemBillList.map((bill) => {
const isSigned = bill.is_signed === true;
const isCurrent = currentAddItemBill && currentAddItemBill.pdf_sort === bill.pdf_sort;
const displayName =
bill.pdf_name && bill.pdf_name.length > 12 ? bill.pdf_name.slice(0, 12) + '...' : bill.pdf_name || '加项单';
return (