From 3955dd6049f81d9efed0caed50062681f37a0ff9 Mon Sep 17 00:00:00 2001 From: Ethanfly Date: Fri, 9 Jan 2026 12:06:55 +0800 Subject: [PATCH] Refactor PDF generation in week report view. Removed temporary container for PDF content and implemented direct printing in a new window. Enhanced styling for printed output and improved user feedback during the PDF generation process. --- resources/views/weekreport/index.blade.php | 163 +++++++++------------ 1 file changed, 68 insertions(+), 95 deletions(-) diff --git a/resources/views/weekreport/index.blade.php b/resources/views/weekreport/index.blade.php index 62a5737..0b38b78 100644 --- a/resources/views/weekreport/index.blade.php +++ b/resources/views/weekreport/index.blade.php @@ -1530,9 +1530,6 @@ document.querySelector('.loading-text').textContent = '正在生成PDF...'; try { - // 创建临时容器用于PDF生成 - const tempDiv = document.createElement('div'); - tempDiv.id = 'pdf-content'; // 转换Markdown为HTML let htmlContent = ''; if (typeof marked !== 'undefined') { @@ -1547,100 +1544,76 @@ .replace(/\n/gim, '
'); } - tempDiv.innerHTML = ` -
+ // 使用新窗口打印方式生成PDF + const printWindow = window.open('', '_blank'); + printWindow.document.write(` + + + + + 周报_${document.getElementById('week-start').value} + + + ${htmlContent} -
- `; - tempDiv.style.cssText = ` - position: absolute; - left: -9999px; - top: 0; - width: 210mm; - background: white; - font-family: "Microsoft YaHei", "SimHei", "PingFang SC", -apple-system, sans-serif; - font-size: 12pt; - line-height: 1.6; - color: #333; - `; +