| | |
| | | <!-- PDF加载完成时显示PDF --> |
| | | <iframe |
| | | v-else |
| | | :src="pdfUrl" style="width: 100%; height: 800px; border: 1px solid #ddd;" |
| | | :src="pdfUrl" style="width: 100%; height: 780px; border: 1px solid #ddd;" |
| | | title="PDF预览"> |
| | | </iframe> |
| | | </div> |
| | | |
| | | <div v-else style="margin-top: 20px;"> |
| | | <div style="display: flex; justify-content: center; align-items: center; height: 800px; border: 1px solid #ddd; background-color: white;"> |
| | | <div style="display: flex; justify-content: center; align-items: center; height: 780px; border: 1px solid #ddd; background-color: white;"> |
| | | <div style="text-align: center; color: #999;"> |
| | | <p style="font-size: 20px; margin-bottom: 10px;">优化报告预览区</p> |
| | | <p style="font-size: 14px;">点击上方"预览"按钮生成并查看优化报告</p> |
| | |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // const autoPreviewReport = async () => { |
| | | // try { |
| | | // await generateReport(); |
| | | // if (!filePath.value) { |
| | | // // 如果没有文件路径,不执行预览 |
| | | // return; |
| | | // } |
| | | // const encodedFilePath = encodeURIComponent(filePath.value); |
| | | // |
| | | // const response = await request.get('/glassOptimize/reports/pdf', { |
| | | // params: { filePath: encodedFilePath }, |
| | | // responseType: 'blob', |
| | | // headers: { |
| | | // 'Accept': 'application/pdf' |
| | | // } |
| | | // }); |
| | | // |
| | | // // 检查响应数据是否存在且有效 |
| | | // if (!response) { |
| | | // ElMessage.error('未能获取到PDF数据'); |
| | | // return; |
| | | // } |
| | | // |
| | | // const blob = new Blob([response], { type: 'application/pdf' }); |
| | | // |
| | | // // 检查 blob 是否有效 |
| | | // if (blob.size === 0) { |
| | | // ElMessage.error('接收到空的PDF文件'); |
| | | // return; |
| | | // } |
| | | // |
| | | // // 创建PDF URL并赋值给 pdfUrl 用于界面显示 |
| | | // const url = URL.createObjectURL(blob); |
| | | // pdfUrl.value = url; |
| | | // |
| | | // } catch (error) { |
| | | // console.error('自动预览流程异常:', error); |
| | | // } |
| | | // }; |
| | | // |
| | | // onMounted(() => { |
| | | // // 优先使用注入的 projectNo,其次使用 props,最后使用 localStorage |
| | | // if (injectedProjectNo) { |
| | | // processId.value = injectedProjectNo.value || injectedProjectNo; |
| | | // } else if (props.project) { |
| | | // processId.value = props.project.projectNumber || ''; |
| | | // state.value = props.state; |
| | | // } else if (savedProjectNo) { |
| | | // processId.value = savedProjectNo; |
| | | // } |
| | | // |
| | | // if (processId.value) { |
| | | // selectLayout(); |
| | | // selectReportData(); |
| | | // selectMaterialData(); |
| | | // selectProductData(); |
| | | // |
| | | // // 数据加载完成后自动预览 |
| | | // setTimeout(() => { |
| | | // autoPreviewReport(); |
| | | // }, 1000); // 延迟1秒确保所有数据加载完成 |
| | | // } |
| | | // }); |
| | | |
| | | const config = reactive({ |
| | | columnTypes: '两列', |