| screen/src/view/planOfAudit/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| screen/src/view/planOfAudit/service.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| screen/src/view/projectHome/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| screen/src/view/projectList/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| screen/src/view/projectList/service.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
screen/src/view/planOfAudit/index.vue
@@ -682,6 +682,7 @@ if (!checkTaskId) { this.$message.error("缺少检查任务ID"); this.loading = false; this.reportVisible = false; return; } @@ -690,30 +691,41 @@ // 第一步:调用接口生成Word文档(返回Word文档流) let wordBlob; if (type === "safe") { // 安全报告(模糊评价) if (!safetyId) { this.$message.error("缺少安全报告模板ID"); this.loading = false; return; try { if (type === "safe") { // 安全报告(模糊评价) if (!safetyId) { this.$message.error("缺少安全报告模板ID"); this.loading = false; this.reportVisible = false; return; } wordBlob = await getFuzzyReportWord({ checkTaskId: checkTaskId, templateId: safetyId, uuid: uuid }); } else { // 设备报告(打分评价) if (!deviceTemplateId) { this.$message.error("缺少设备报告模板ID"); this.loading = false; this.reportVisible = false; return; } wordBlob = await getScoreReportWord({ checkTaskId: checkTaskId, templateId: deviceTemplateId, uuid: uuid }); } wordBlob = await getFuzzyReportWord({ checkTaskId: checkTaskId, templateId: safetyId, uuid: uuid }); } else { // 设备报告(打分评价) if (!deviceTemplateId) { this.$message.error("缺少设备报告模板ID"); this.loading = false; return; } wordBlob = await getScoreReportWord({ checkTaskId: checkTaskId, templateId: deviceTemplateId, uuid: uuid }); } catch (error) { // 捕获生成Word文档时的错误 console.error("生成Word文档失败:", error); this.$message.error(error.message || "生成报告失败"); this.loading = false; this.reportVisible = false; return; } // 检查 Word 文档是否生成成功 @@ -722,15 +734,25 @@ if (!wordBlob || wordBlob.size === 0) { this.$message.error("报告生成失败"); this.loading = false; this.reportVisible = false; return; } // 第二步:使用uuid获取PDF链接 let pdfUrlResponse; if (type === "safe") { pdfUrlResponse = await getFuzzyReportPdfUrl({ uuid: uuid }); } else { pdfUrlResponse = await getScoreReportPdfUrl({ uuid: uuid }); try { if (type === "safe") { pdfUrlResponse = await getFuzzyReportPdfUrl({ uuid: uuid }); } else { pdfUrlResponse = await getScoreReportPdfUrl({ uuid: uuid }); } } catch (error) { // 捕获获取PDF链接时的错误 console.error("获取PDF链接失败:", error); this.$message.error(error.message || "获取PDF链接失败"); this.loading = false; this.reportVisible = false; return; } console.log('PDF链接响应:', pdfUrlResponse); @@ -742,6 +764,7 @@ if (!pdfUrl) { this.$message.error("获取PDF链接失败"); this.loading = false; this.reportVisible = false; return; } @@ -754,7 +777,10 @@ } catch (error) { console.error("获取报告失败:", error); if (error.response) { // 优先显示错误对象中的 message if (error.message) { this.$message.error(error.message); } else if (error.response) { const status = error.response.status; if (status === 404) { this.$message.error("报告不存在"); @@ -767,6 +793,7 @@ this.$message.error("获取报告失败,请检查网络连接"); } this.showPreview = false; this.reportVisible = false; } finally { this.loading = false; } screen/src/view/planOfAudit/service.js
@@ -25,10 +25,30 @@ // 响应拦截 - 文件流直接返回 blob reportRequest.interceptors.response.use( response => { // 对于 blob 类型的响应,直接返回 data async response => { // 对于 blob 类型的响应,需要判断是否是错误信息 if (response.config.responseType === 'blob') { return response.data const blob = response.data // 检查 blob 的 type,如果是 application/json,说明返回的是错误信息 if (blob.type === 'application/json') { try { // 将 blob 转换为文本 const text = await blob.text() const errorData = JSON.parse(text) // 抛出错误信息 return Promise.reject({ message: errorData.errorMsg || errorData.msg || '操作失败', data: errorData }) } catch (e) { return Promise.reject({ message: '解析错误信息失败' }) } } // 正常的文件流,直接返回 return blob } return response.data }, screen/src/view/projectHome/index.vue
@@ -524,12 +524,12 @@ this.projectName = res.name const permissions = res.permissionProject ? res.permissionProject.split(",") : [] this.permissionProject = permissions localStorage.setItem("permissionProject", JSON.stringify(permissions)); localStorage.setItem("deviceTemplateId", res.deviceTemplateId);//设备模板id localStorage.setItem("safetyId", res.safetyId);//安全报告模板id localStorage.setItem("bigHiddenDanger", res.bigHiddenDanger); //1开启 2关闭 重大隐患 localStorage.setItem("generalHiddenDanger", res.generalHiddenDanger);//1开启 2关闭 一般隐患 localStorage.setItem("commentType", res.commentType); //1模糊评价 2打分评价 localStorage.setItem('permissionProject', JSON.stringify(permissions)); localStorage.setItem('deviceTemplateId', res.deviceTemplateId) // 设备模板id localStorage.setItem("safetyId", res.safetyId) // 安全报告模板id localStorage.setItem("bigHiddenDanger", res.bigHiddenDanger) // 1开启 2关闭 重大隐患 localStorage.setItem("generalHiddenDanger", res.generalHiddenDanger) // 1开启 2关闭 一般隐患 localStorage.setItem("commentType", res.commentType) // 1模糊评价 2打分评价 }).catch(err => { console.error('获取登录信息失败:', err) // 设置默认值,确保页面可以继续渲染 screen/src/view/projectList/index.vue
@@ -810,6 +810,7 @@ if (!checkTaskId) { this.$message.error("缺少检查任务ID"); this.reportLoading = false; this.reportVisible = false; return; } @@ -818,30 +819,41 @@ // 第一步:调用接口生成Word文档(返回Word文档流) let wordBlob; if (type === "safe") { // 安全报告(模糊评价) if (!safetyId) { this.$message.error("缺少安全报告模板ID"); this.reportLoading = false; return; try { if (type === "safe") { // 安全报告(模糊评价) if (!safetyId) { this.$message.error("缺少安全报告模板ID"); this.reportLoading = false; this.reportVisible = false; return; } wordBlob = await getFuzzyReportWord({ checkTaskId: checkTaskId, templateId: safetyId, uuid: uuid }); } else { // 设备报告(打分评价) if (!deviceTemplateId) { this.$message.error("缺少设备报告模板ID"); this.reportLoading = false; this.reportVisible = false; return; } wordBlob = await getScoreReportWord({ checkTaskId: checkTaskId, templateId: deviceTemplateId, uuid: uuid }); } wordBlob = await getFuzzyReportWord({ checkTaskId: checkTaskId, templateId: safetyId, uuid: uuid }); } else { // 设备报告(打分评价) if (!deviceTemplateId) { this.$message.error("缺少设备报告模板ID"); this.reportLoading = false; return; } wordBlob = await getScoreReportWord({ checkTaskId: checkTaskId, templateId: deviceTemplateId, uuid: uuid }); } catch (error) { // 捕获生成Word文档时的错误 console.error("生成Word文档失败:", error); this.$message.error(error.message || "生成报告失败"); this.reportLoading = false; this.reportVisible = false; return; } // 检查 Word 文档是否生成成功 @@ -850,15 +862,25 @@ if (!wordBlob || wordBlob.size === 0) { this.$message.error("报告生成失败"); this.reportLoading = false; this.reportVisible = false; return; } // 第二步:使用uuid获取PDF链接 let pdfUrlResponse; if (type === "safe") { pdfUrlResponse = await getFuzzyReportPdfUrl({ uuid: uuid }); } else { pdfUrlResponse = await getScoreReportPdfUrl({ uuid: uuid }); try { if (type === "safe") { pdfUrlResponse = await getFuzzyReportPdfUrl({ uuid: uuid }); } else { pdfUrlResponse = await getScoreReportPdfUrl({ uuid: uuid }); } } catch (error) { // 捕获获取PDF链接时的错误 console.error("获取PDF链接失败:", error); this.$message.error(error.message || "获取PDF链接失败"); this.reportLoading = false; this.reportVisible = false; return; } console.log('PDF链接响应:', pdfUrlResponse); @@ -870,6 +892,7 @@ if (!pdfUrl) { this.$message.error("获取PDF链接失败"); this.reportLoading = false; this.reportVisible = false; return; } @@ -882,7 +905,10 @@ } catch (error) { console.error("获取报告失败:", error); if (error.response) { // 优先显示错误对象中的 message if (error.message) { this.$message.error(error.message); } else if (error.response) { const status = error.response.status; if (status === 404) { this.$message.error("报告不存在"); @@ -895,6 +921,7 @@ this.$message.error("获取报告失败,请检查网络连接"); } this.showPreview = false; this.reportVisible = false; } finally { this.reportLoading = false; } screen/src/view/projectList/service.js
@@ -26,10 +26,30 @@ // 响应拦截 - 文件流直接返回 blob reportRequest.interceptors.response.use( response => { // 对于 blob 类型的响应,直接返回 data async response => { // 对于 blob 类型的响应,需要判断是否是错误信息 if (response.config.responseType === 'blob') { return response.data const blob = response.data // 检查 blob 的 type,如果是 application/json,说明返回的是错误信息 if (blob.type === 'application/json') { try { // 将 blob 转换为文本 const text = await blob.text() const errorData = JSON.parse(text) // 抛出错误信息 return Promise.reject({ message: errorData.message || errorData.msg || '操作失败', data: errorData }) } catch (e) { return Promise.reject({ message: '解析错误信息失败' }) } } // 正常的文件流,直接返回 return blob } return response.data },