去除控制台调试信息
This commit is contained in:
parent
689a1a2b7a
commit
a035ee216f
@ -675,12 +675,14 @@
|
||||
<div class="report-item" style="width: 800px;height: 1123px;margin:0 auto;position: relative;">
|
||||
<div class="report-title">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<span>前言</span>
|
||||
<span></span>
|
||||
<span>填充值</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="repott_concent">
|
||||
<div class="content">
|
||||
<h1 style="text-align: center;">前言</h1>
|
||||
<p class="greeting">尊敬的<span class="underline">________</span>先生/女士:</p>
|
||||
|
||||
<div class="paragraph-group">
|
||||
@ -979,7 +981,6 @@
|
||||
|
||||
// 页面加载完成后立即开始预渲染所有PDF为图片
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
console.log('页面加载完成,开始预渲染PDF为图片');
|
||||
setTimeout(() => {
|
||||
preRenderAllPDFs();
|
||||
}, 1000);
|
||||
@ -1001,13 +1002,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
console.log('所有PDF预渲染完成');
|
||||
}
|
||||
|
||||
// 将PDF渲染为图片 - 完全重写
|
||||
async function renderPDFAsImage(url, container) {
|
||||
try {
|
||||
console.log('开始渲染PDF为图片:', url);
|
||||
const loadingElem = container.querySelector('.pdf-loading');
|
||||
const imageContainer = container.querySelector('.pdf-image-container');
|
||||
|
||||
@ -1020,8 +1019,6 @@
|
||||
});
|
||||
|
||||
const pdf = await loadingTask.promise;
|
||||
console.log('PDF加载成功, 页数:', pdf.numPages);
|
||||
|
||||
// 只渲染第一页
|
||||
const page = await pdf.getPage(1);
|
||||
|
||||
@ -1032,7 +1029,6 @@
|
||||
if (reportItem && reportItem.classList.contains('ultrasound-exam')) {
|
||||
// 超声检查报告使用更大的缩放比例
|
||||
scale = 3.0;
|
||||
console.log('检测到超声检查报告,使用更大缩放比例:', scale);
|
||||
}
|
||||
|
||||
const viewport = page.getViewport({ scale: scale });
|
||||
@ -1105,8 +1101,6 @@
|
||||
// 隐藏加载提示,显示图片
|
||||
if (loadingElem) loadingElem.style.display = 'none';
|
||||
imageContainer.style.display = 'block';
|
||||
|
||||
console.log('PDF渲染为图片完成');
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('渲染PDF为图片失败:', error);
|
||||
@ -1132,7 +1126,6 @@
|
||||
|
||||
// 打印前事件处理
|
||||
window.addEventListener('beforeprint', () => {
|
||||
console.log('打印前事件触发');
|
||||
// 显示所有打印容器
|
||||
document.querySelectorAll('.print-only').forEach(el => {
|
||||
el.style.display = 'block';
|
||||
@ -1150,13 +1143,9 @@
|
||||
});
|
||||
|
||||
if (!allRendered) {
|
||||
console.log('有PDF尚未渲染完成,尝试再次渲染');
|
||||
// 如果有未渲染完成的,尝试再次渲染
|
||||
preRenderAllPDFs().catch(error => {
|
||||
console.error('打印前渲染失败:', error);
|
||||
});
|
||||
} else {
|
||||
console.log('所有PDF已渲染为图片,可以直接打印');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -70,7 +70,6 @@ watch(
|
||||
const handleIframeLoad = async () => {
|
||||
const iframe = document.querySelector('iframe')
|
||||
const reportData = await PatientApi.getReportAll(props.reportData.medicalSn)
|
||||
console.log('获取到的报告数据:', reportData)
|
||||
|
||||
if (iframe && iframe.contentWindow) {
|
||||
const doc = iframe.contentWindow.document
|
||||
@ -138,13 +137,6 @@ const handleIframeLoad = async () => {
|
||||
console.log('未找到头像元素')
|
||||
}
|
||||
}
|
||||
|
||||
// 更新标题
|
||||
const title = doc.querySelector('h1')
|
||||
if (title) {
|
||||
title.textContent = `体检检查报告汇总 - ${reportData.pName || ''}`
|
||||
}
|
||||
|
||||
// 更新前言中的姓名
|
||||
const prefaceGreeting = doc.querySelector('.greeting .underline')
|
||||
if (prefaceGreeting) {
|
||||
@ -183,7 +175,6 @@ const handleIframeLoad = async () => {
|
||||
|
||||
// 更新超声检查报告
|
||||
const ultrasoundData = reportData.data.find((item) => item.itemName === '超声' || item.itemName === 'US')
|
||||
console.log('超声检查数据:', ultrasoundData)
|
||||
if (ultrasoundData) {
|
||||
// 更新超声检查报告内容
|
||||
const ultrasoundSummary = doc.querySelector('.report-item.ultrasound-exam .report-summary')
|
||||
@ -208,7 +199,6 @@ const handleIframeLoad = async () => {
|
||||
// 更新屏幕显示的iframe
|
||||
const iframeElement = doc.querySelector('.ultrasound-exam .screen-only iframe')
|
||||
if (iframeElement) {
|
||||
console.log('设置超声检查iframe src:', pdfUrl)
|
||||
iframeElement.src = pdfUrl
|
||||
} else {
|
||||
console.error('未找到超声检查iframe元素')
|
||||
@ -217,7 +207,6 @@ const handleIframeLoad = async () => {
|
||||
// 更新打印用的PDF容器
|
||||
const pdfContainer = doc.querySelector('.ultrasound-exam .print-only.pdf-container')
|
||||
if (pdfContainer) {
|
||||
console.log('设置超声检查PDF容器URL:', pdfUrl)
|
||||
pdfContainer.setAttribute('data-pdf-url', pdfUrl)
|
||||
} else {
|
||||
console.error('未找到超声检查PDF容器')
|
||||
@ -237,7 +226,6 @@ const handleIframeLoad = async () => {
|
||||
|
||||
// 更新生化检查
|
||||
const biochemData = reportData.data.find((item) => item.itemName === '生化')
|
||||
console.log('生化检查数据:', biochemData)
|
||||
if (biochemData) {
|
||||
// 改为第7个report-item(原4→7)
|
||||
const biochemSummary = doc.querySelector('.report-item:nth-of-type(7) .report-summary p')
|
||||
@ -360,22 +348,10 @@ const waitForAllPDFsRendered = () => {
|
||||
return new Promise((resolve) => {
|
||||
const checkRendering = () => {
|
||||
const containers = document.querySelectorAll('.pdf-container');
|
||||
let allDone = true;
|
||||
|
||||
console.log('开始检查PDF渲染状态...');
|
||||
|
||||
let allDone = true;
|
||||
containers.forEach((container, index) => {
|
||||
const imageContainer = container.querySelector('.pdf-image-container');
|
||||
const img = imageContainer?.querySelector('img');
|
||||
|
||||
console.log(`检查第${index + 1}个PDF:`, {
|
||||
hasImageContainer: !!imageContainer,
|
||||
hasImage: !!img,
|
||||
imageComplete: img?.complete,
|
||||
imageDisplay: imageContainer?.style.display,
|
||||
imageSrc: img?.src
|
||||
});
|
||||
|
||||
// 更严格的检查条件
|
||||
if (!imageContainer ||
|
||||
!img ||
|
||||
@ -383,15 +359,12 @@ const waitForAllPDFsRendered = () => {
|
||||
imageContainer.style.display !== 'block' ||
|
||||
!img.src) {
|
||||
allDone = false;
|
||||
console.log(`第${index + 1}个PDF未完成渲染`);
|
||||
}
|
||||
});
|
||||
|
||||
if (allDone) {
|
||||
console.log('所有PDF都已渲染完成,可以进行打印');
|
||||
resolve(true);
|
||||
resolve(true);
|
||||
} else {
|
||||
console.log('PDF还在渲染中,继续等待...');
|
||||
setTimeout(checkRendering, 1000); // 增加检查间隔到1秒
|
||||
}
|
||||
};
|
||||
@ -423,19 +396,14 @@ const handlePrint = async () => {
|
||||
try {
|
||||
// 获取所有需要转换的PDF容器
|
||||
const containers = iframeDoc.querySelectorAll('.pdf-container');
|
||||
console.log('开始转换PDF为图片...');
|
||||
|
||||
// 执行所有PDF转换
|
||||
for (const container of containers) {
|
||||
const pdfUrl = container.getAttribute('data-pdf-url');
|
||||
if (pdfUrl) {
|
||||
await iframe.contentWindow.renderPDFAsImage(pdfUrl, container);
|
||||
console.log(`PDF转换完成: ${pdfUrl}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('所有PDF转换完成,开始打印');
|
||||
// 移除加载提示
|
||||
iframeDoc.body.removeChild(loadingMessage);
|
||||
|
||||
// 执行打印
|
||||
|
||||
Loading…
Reference in New Issue
Block a user