fix: repair print/PDF in Reports — fix document.write/appendChild mix, add printPdfBlob for print format

This commit is contained in:
Agent Zero
2026-07-26 09:40:43 +02:00
parent 0571cc8193
commit 4dbbc422ce
2 changed files with 98 additions and 78 deletions
+11 -2
View File
@@ -17,6 +17,7 @@ import {
} from 'lucide-react';
import clsx from 'clsx';
import { PrintButton } from '@/components/common/PrintButton';
import { printPdfBlob } from '@/utils/print';
import { useToast } from '@/components/ui/Toast';
import {
useReportTemplates,
@@ -163,7 +164,11 @@ export function ReportsPage() {
output_format: editorFormat,
});
const filename = `report_${selectedTemplate.name}.${editorFormat === 'excel' ? 'xlsx' : editorFormat}`;
downloadBlob(response.data as Blob, filename);
if (editorFormat === 'print') {
printPdfBlob(response.data as Blob);
} else {
downloadBlob(response.data as Blob, filename);
}
setDownloadHistory((prev) => [
{ id: Date.now().toString(), name: selectedTemplate.name, format: editorFormat, timestamp: new Date().toLocaleString() },
...prev,
@@ -192,7 +197,11 @@ export function ReportsPage() {
});
const ext = activePresetFormat === 'excel' ? 'xlsx' : activePresetFormat === 'print' ? 'pdf' : activePresetFormat;
const filename = `${preset.key}_report.${ext}`;
downloadBlob(response.data as Blob, filename);
if (activePresetFormat === 'print') {
printPdfBlob(response.data as Blob);
} else {
downloadBlob(response.data as Blob, filename);
}
setDownloadHistory((prev) => [
{ id: Date.now().toString(), name: preset.name, format: activePresetFormat, timestamp: new Date().toLocaleString() },
...prev,