更新新签到
This commit is contained in:
@@ -4,7 +4,6 @@ import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
|
||||
|
||||
import { getDaojiandanPdf as getDaojiandanPdfApi, submitDaojiandanSign, editDaojiandanPrintStatus } from '../../api';
|
||||
import type { ExamClient } from '../../data/mockData';
|
||||
import { setExamActionRecord, setDaojiandanPdf, getDaojiandanPdf } from '../../utils/examActions';
|
||||
import type { SignaturePadHandle } from '../ui';
|
||||
import { Button, SignaturePad } from '../ui';
|
||||
|
||||
@@ -69,17 +68,7 @@ export const ExamPrintPanel = ({ client }: { client: ExamClient }) => {
|
||||
setSubmitMessage('签名提交成功,正在加载导检单...');
|
||||
setSignatureSubmitted(true);
|
||||
const pdfUrlValue = res.Data.pdf_url;
|
||||
const pdfNameValue = res.Data.pdf_name || '导检单';
|
||||
setPdfUrl(pdfUrlValue);
|
||||
// 保存导检单PDF信息到localStorage
|
||||
setDaojiandanPdf(examId, {
|
||||
pdf_name: pdfNameValue,
|
||||
pdf_url: pdfUrlValue,
|
||||
is_signed: true,
|
||||
});
|
||||
// 记录打印导检单是否签名操作
|
||||
setExamActionRecord(examId, 'printSign', true);
|
||||
|
||||
// 更新导检单打印状态
|
||||
try {
|
||||
await editDaojiandanPrintStatus({ exam_id: examId });
|
||||
@@ -102,12 +91,6 @@ export const ExamPrintPanel = ({ client }: { client: ExamClient }) => {
|
||||
useEffect(() => {
|
||||
const examId = Number(client.id);
|
||||
if (!examId) return;
|
||||
|
||||
const storedPdf = getDaojiandanPdf(examId);
|
||||
if (storedPdf && storedPdf.pdf_url) {
|
||||
setPdfUrl(storedPdf.pdf_url);
|
||||
setShowPreview(true);
|
||||
}
|
||||
}, [client.id]);
|
||||
|
||||
// 获取导检单PDF(优先使用localStorage,没有则调用接口)
|
||||
@@ -122,16 +105,6 @@ export const ExamPrintPanel = ({ client }: { client: ExamClient }) => {
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// 先尝试从localStorage获取
|
||||
const storedPdf = getDaojiandanPdf(examId);
|
||||
if (storedPdf && storedPdf.pdf_url) {
|
||||
setPdfUrl(storedPdf.pdf_url);
|
||||
setShowPreview(true);
|
||||
setFetchLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果没有存储的,则调用接口获取
|
||||
const res = await getDaojiandanPdfApi({ exam_id: examId });
|
||||
if (res.Status === 200 && res.Data?.pdf_url) {
|
||||
const pdfUrlValue = res.Data.pdf_url;
|
||||
|
||||
Reference in New Issue
Block a user