添加打印按钮

This commit is contained in:
xianyi
2026-01-06 10:23:47 +08:00
parent 43182051a7
commit 44ec203dea

View File

@@ -1119,7 +1119,20 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
padding: 0;
}
.print-button {
display: none;
position: fixed;
top: 20px;
right: 20px;
padding: 10px 20px;
background-color: #2563eb;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
z-index: 1000;
}
.print-button:hover {
background-color: #1d4ed8;
}
img {
display: block;
@@ -1220,7 +1233,20 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
padding: 0;
}
.print-button {
display: none;
position: fixed;
top: 20px;
right: 20px;
padding: 10px 20px;
background-color: #2563eb;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
z-index: 1000;
}
.print-button:hover {
background-color: #1d4ed8;
}
img {
display: block;
@@ -1376,6 +1402,41 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
}
}
// 处理加项单(如果有且已签名)
if (addItemBillUrl && isAddItemBillSigned) {
try {
const response = await fetch(addItemBillUrl);
if (response.ok) {
const blob = await response.blob();
const arrayBuffer = await blob.arrayBuffer();
const pdf = await pdfjsLib.getDocument({ data: arrayBuffer }).promise;
for (let pageNum = 1; pageNum <= pdf.numPages; pageNum++) {
const page = await pdf.getPage(pageNum);
const viewport = page.getViewport({ scale });
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
if (!context) continue;
canvas.height = viewport.height;
canvas.width = viewport.width;
const renderContext = {
canvasContext: context,
viewport: viewport,
} as any;
await page.render(renderContext).promise;
allImages.push(canvas.toDataURL('image/png'));
}
}
} catch (err) {
console.error('处理加项单失败', err);
}
}
if (allImages.length === 0) {
alert('没有可打印的内容');
return;
@@ -1416,7 +1477,20 @@ export const ExamSignPanel = ({ examId, onBusyChange }: ExamSignPanelProps) => {
padding: 0;
}
.print-button {
display: none;
position: fixed;
top: 20px;
right: 20px;
padding: 10px 20px;
background-color: #2563eb;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
z-index: 1000;
}
.print-button:hover {
background-color: #1d4ed8;
}
img {
display: block;