fix: repair print/PDF in Reports — fix document.write/appendChild mix, add printPdfBlob for print format
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user