保存加项PDF
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useState, useRef } from 'react';
|
||||
|
||||
import type { ExamClient } from '../../data/mockData';
|
||||
import { searchPhysicalExamAddItem, getAddItemCustomerInfo, getChannelCompanyList, createNativePaymentQrcode, checkNativePaymentStatus, submitAddItemBillSign } from '../../api';
|
||||
import { searchPhysicalExamAddItem, getAddItemCustomerInfo, getChannelCompanyList, createNativePaymentQrcode, checkNativePaymentStatus, getAddItemBillPdf } from '../../api';
|
||||
import { Button, Input } from '../ui';
|
||||
import { cls } from '../../utils/cls';
|
||||
import nozImage from '../../assets/image/noz.png';
|
||||
@@ -358,43 +358,16 @@ export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 创建空白签名图片(用于自动生成PDF)
|
||||
const createBlankSignature = (): Promise<Blob> => {
|
||||
return new Promise((resolve) => {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 400;
|
||||
canvas.height = 200;
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (ctx) {
|
||||
// 创建白色背景
|
||||
ctx.fillStyle = '#FFFFFF';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
}
|
||||
canvas.toBlob((blob) => {
|
||||
if (blob) {
|
||||
resolve(blob);
|
||||
} else {
|
||||
// 如果转换失败,创建一个空的 Blob
|
||||
resolve(new Blob([], { type: 'image/png' }));
|
||||
}
|
||||
}, 'image/png');
|
||||
});
|
||||
};
|
||||
|
||||
// 获取加项PDF
|
||||
const fetchAddItemBillPdf = async (examId: number) => {
|
||||
try {
|
||||
// 创建空白签名
|
||||
const blankSignature = await createBlankSignature();
|
||||
|
||||
// 调用接口获取加项PDF
|
||||
const res = await submitAddItemBillSign({
|
||||
const res = await getAddItemBillPdf({
|
||||
exam_id: examId,
|
||||
sign_file: blankSignature,
|
||||
});
|
||||
|
||||
if (res.Status === 200 && res.Data?.pdf_url) {
|
||||
// 保存加项PDF信息
|
||||
// 保存加项PDF信息到localStorage
|
||||
setAddItemBillPdf(examId, {
|
||||
pdf_name: res.Data.pdf_name || '加项单',
|
||||
pdf_url: res.Data.pdf_url,
|
||||
|
||||
Reference in New Issue
Block a user