| | |
| | | </template> |
| | | |
| | | <script> |
| | | import HeaderBox from "../header/index.vue"; |
| | | import moment from "moment"; |
| | | import HeaderBox from '../header/index.vue' |
| | | import moment from 'moment' |
| | | import { |
| | | getProjectList, |
| | | projectList, |
| | |
| | | getFuzzyReportWord, |
| | | getScoreReportWord, |
| | | getFuzzyReportPdfUrl, |
| | | getScoreReportPdfUrl, |
| | | } from "./service"; |
| | | getScoreReportPdfUrl |
| | | } from './service' |
| | | export default { |
| | | components: { HeaderBox }, |
| | | props: {}, |
| | | data() { |
| | | data () { |
| | | return { |
| | | // 搜索条件 |
| | | searchProjectId: null, // 项目选择 |
| | |
| | | riskLevel: null, // 项目风险 |
| | | startTime: null, // 开始时间 |
| | | endTime: null, // 结束时间 |
| | | startTimeTxt: "", // 开始时间显示文本 |
| | | endTimeTxt: "", // 结束时间显示文本 |
| | | projectName: "", // 项目名称搜索 |
| | | startTimeTxt: '', // 开始时间显示文本 |
| | | endTimeTxt: '', // 结束时间显示文本 |
| | | projectName: '', // 项目名称搜索 |
| | | |
| | | // 下拉选项 |
| | | projectOptions: [], // 项目下拉列表 |
| | | projectTypeOptions: [ |
| | | { label: "房建", value: 0 }, |
| | | { label: "市政", value: 1 }, |
| | | { label: "固定资产", value: 2 }, |
| | | { label: '房建', value: 0 }, |
| | | { label: '市政', value: 1 }, |
| | | { label: '固定资产', value: 2 } |
| | | ], // 项目类型下拉列表 |
| | | riskLevelOptions: [ |
| | | { label: "拒绝接受风险", value: 0 }, |
| | | { label: "不可接受风险", value: 1 }, |
| | | { label: "可接受风险", value: 2 }, |
| | | { label: "可容忍风险", value: 3 }, |
| | | { label: "可忽略风险", value: 4 }, |
| | | { label: '拒绝接受风险', value: 0 }, |
| | | { label: '不可接受风险', value: 1 }, |
| | | { label: '可接受风险', value: 2 }, |
| | | { label: '可容忍风险', value: 3 }, |
| | | { label: '可忽略风险', value: 4 } |
| | | ], |
| | | |
| | | // 表格数据 |
| | |
| | | |
| | | // 用户信息 |
| | | userInfo: {}, |
| | | clientId: localStorage.getItem("clientId"), |
| | | clientId: localStorage.getItem('clientId'), |
| | | isClientMode: false, // 是否是委托方模式 |
| | | |
| | | // 报告相关 |
| | | reportUrl: "", // 已废弃,保留兼容性 |
| | | reportBlobUrl: "", // Blob URL用于下载 |
| | | pdfUrl: "", // PDF预览URL |
| | | reportUrl: '', // 已废弃,保留兼容性 |
| | | reportBlobUrl: '', // Blob URL用于下载 |
| | | pdfUrl: '', // PDF预览URL |
| | | reportLoading: false, |
| | | showPreview: false, // 是否显示预览 |
| | | currentRow: null, // 当前选中的行数据 |
| | | |
| | | // 评价类型 |
| | | commentType: localStorage.getItem("commentType") || null, |
| | | projectCategory: null, |
| | | }; |
| | | commentType: localStorage.getItem('commentType') || null, |
| | | projectCategory: null |
| | | } |
| | | }, |
| | | computed: { |
| | | // 是否显示风险类型列(commentType 不为 2 时显示) |
| | | shouldShowRiskLevel() { |
| | | return this.commentType != "2"; |
| | | }, |
| | | shouldShowRiskLevel () { |
| | | return this.commentType != '2' |
| | | } |
| | | }, |
| | | watch: { |
| | | startTime: { |
| | | handler(newVal) { |
| | | handler (newVal) { |
| | | if (newVal) { |
| | | this.startTimeTxt = moment(newVal).format("YYYY年MM月DD日 HH:mm:ss"); |
| | | this.startTimeTxt = moment(newVal).format('YYYY年MM月DD日 HH:mm:ss') |
| | | } else { |
| | | this.startTimeTxt = ""; |
| | | this.startTimeTxt = '' |
| | | } |
| | | }, |
| | | immediate: true, |
| | | immediate: true |
| | | }, |
| | | endTime: { |
| | | handler(newVal) { |
| | | handler (newVal) { |
| | | if (newVal) { |
| | | this.endTimeTxt = moment(newVal).format("YYYY年MM月DD日 HH:mm:ss"); |
| | | this.endTimeTxt = moment(newVal).format('YYYY年MM月DD日 HH:mm:ss') |
| | | } else { |
| | | this.endTimeTxt = ""; |
| | | this.endTimeTxt = '' |
| | | } |
| | | }, |
| | | immediate: true, |
| | | }, |
| | | immediate: true |
| | | } |
| | | }, |
| | | created() { |
| | | created () { |
| | | if (this.$route.query.projectCategory) { |
| | | this.projectCategory = this.$route.query.projectCategory; |
| | | this.projectCategory = this.$route.query.projectCategory |
| | | } |
| | | |
| | | // 接收从 home 页面传递过来的时间参数并回填 |
| | | if (this.$route.query.startTime) { |
| | | this.startTime = new Date(this.$route.query.startTime); |
| | | this.startTime = new Date(this.$route.query.startTime) |
| | | } |
| | | if (this.$route.query.endTime) { |
| | | this.endTime = new Date(this.$route.query.endTime); |
| | | this.endTime = new Date(this.$route.query.endTime) |
| | | } |
| | | |
| | | this.initUserInfo(); |
| | | this.initData(); |
| | | this.initUserInfo() |
| | | this.initData() |
| | | }, |
| | | mounted() {}, |
| | | mounted () {}, |
| | | methods: { |
| | | // 初始化用户信息 |
| | | initUserInfo() { |
| | | const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}"); |
| | | this.userInfo = userInfo; |
| | | initUserInfo () { |
| | | const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}') |
| | | this.userInfo = userInfo |
| | | // 判断是否是委托方(type为1表示委托方) |
| | | this.isClientMode = userInfo.type === 1; |
| | | this.isClientMode = userInfo.type === 1 |
| | | }, |
| | | |
| | | // 初始化数据 |
| | | async initData() { |
| | | await this.loadProjectOptions(); |
| | | await this.loadTableData(); |
| | | async initData () { |
| | | await this.loadProjectOptions() |
| | | await this.loadTableData() |
| | | }, |
| | | |
| | | // 加载项目下拉列表(仅委托方需要) |
| | | async loadProjectOptions() { |
| | | if (!this.isClientMode) return; |
| | | async loadProjectOptions () { |
| | | if (!this.isClientMode) return |
| | | |
| | | try { |
| | | const res = await getProjectList({ |
| | | clientId: this.clientId, |
| | | projectCategory: ["ongoing", "fixed"][ |
| | | localStorage.getItem("activeTab") - 1 |
| | | ], |
| | | }); |
| | | projectCategory: ['ongoing', 'fixed'][ |
| | | localStorage.getItem('activeTab') - 1 |
| | | ] |
| | | }) |
| | | if (res) { |
| | | this.projectOptions = res.map((item) => ({ |
| | | label: item.name, |
| | | value: item.id, |
| | | })); |
| | | value: item.id |
| | | })) |
| | | } |
| | | } catch (error) { |
| | | console.error("加载项目列表失败:", error); |
| | | console.error('加载项目列表失败:', error) |
| | | } |
| | | }, |
| | | |
| | | // 加载表格数据 |
| | | async loadTableData() { |
| | | this.loading = true; |
| | | async loadTableData () { |
| | | this.loading = true |
| | | try { |
| | | const params = { |
| | | pageNum: this.currentPage, |
| | | pageSize: this.pageSize, |
| | | clientId: this.clientId, |
| | | }; |
| | | clientId: this.clientId |
| | | } |
| | | |
| | | // 添加搜索条件 |
| | | if (this.searchProjectId) params.projectId = this.searchProjectId; |
| | | if (this.projectType) params.type = this.projectType; |
| | | if (this.riskLevel !== null && this.riskLevel !== "") { |
| | | params.riskLevel = this.riskLevel; |
| | | if (this.searchProjectId) params.projectId = this.searchProjectId |
| | | if (this.projectType) params.type = this.projectType |
| | | if (this.riskLevel !== null && this.riskLevel !== '') { |
| | | params.riskLevel = this.riskLevel |
| | | } |
| | | if (this.startTime) { |
| | | params.startTime = moment(this.startTime).format( |
| | | "YYYY-MM-DD HH:mm:ss" |
| | | ); |
| | | 'YYYY-MM-DD HH:mm:ss' |
| | | ) |
| | | } |
| | | if (this.endTime) { |
| | | params.endTime = moment(this.endTime).format("YYYY-MM-DD HH:mm:ss"); |
| | | params.endTime = moment(this.endTime).format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | if (this.projectName) params.name = this.projectName; |
| | | if (this.projectName) params.name = this.projectName |
| | | if (this.projectCategory) { |
| | | params.category = localStorage.getItem("activeTab"); |
| | | params.category = localStorage.getItem('activeTab') |
| | | } |
| | | |
| | | const res = await projectList(params); |
| | | const res = await projectList(params) |
| | | if (res) { |
| | | this.tableData = res.records || []; |
| | | this.total = res.total || 0; |
| | | this.tableData = res.records || [] |
| | | this.total = res.total || 0 |
| | | } |
| | | } catch (error) { |
| | | console.error("加载项目列表失败:", error); |
| | | this.$message.error("加载项目列表失败"); |
| | | console.error('加载项目列表失败:', error) |
| | | this.$message.error('加载项目列表失败') |
| | | } finally { |
| | | this.loading = false; |
| | | this.loading = false |
| | | } |
| | | }, |
| | | |
| | | // 搜索 |
| | | handleSearch() { |
| | | this.currentPage = 1; |
| | | this.loadTableData(); |
| | | handleSearch () { |
| | | this.currentPage = 1 |
| | | this.loadTableData() |
| | | }, |
| | | |
| | | // 清除项目选择 |
| | | clearSearchProjectId() { |
| | | this.searchProjectId = null; |
| | | this.handleSearch(); |
| | | clearSearchProjectId () { |
| | | this.searchProjectId = null |
| | | this.handleSearch() |
| | | }, |
| | | |
| | | // 清除项目类型 |
| | | clearProjectType() { |
| | | this.projectType = null; |
| | | this.handleSearch(); |
| | | clearProjectType () { |
| | | this.projectType = null |
| | | this.handleSearch() |
| | | }, |
| | | |
| | | // 清除风险等级 |
| | | clearRiskLevel() { |
| | | this.riskLevel = null; |
| | | this.handleSearch(); |
| | | clearRiskLevel () { |
| | | this.riskLevel = null |
| | | this.handleSearch() |
| | | }, |
| | | |
| | | // 清除开始时间 |
| | | clearStartTime() { |
| | | this.startTime = null; |
| | | this.handleSearch(); |
| | | clearStartTime () { |
| | | this.startTime = null |
| | | this.handleSearch() |
| | | }, |
| | | |
| | | // 清除结束时间 |
| | | clearEndTime() { |
| | | this.endTime = null; |
| | | this.handleSearch(); |
| | | clearEndTime () { |
| | | this.endTime = null |
| | | this.handleSearch() |
| | | }, |
| | | |
| | | // 分页大小改变 |
| | | handleSizeChange(val) { |
| | | this.pageSize = val; |
| | | this.currentPage = 1; |
| | | this.loadTableData(); |
| | | handleSizeChange (val) { |
| | | this.pageSize = val |
| | | this.currentPage = 1 |
| | | this.loadTableData() |
| | | }, |
| | | |
| | | // 当前页改变 |
| | | handleCurrentChange(val) { |
| | | this.currentPage = val; |
| | | this.loadTableData(); |
| | | handleCurrentChange (val) { |
| | | this.currentPage = val |
| | | this.loadTableData() |
| | | }, |
| | | |
| | | // 点击日期选择器 |
| | | handleClick(type) { |
| | | this.$refs[`datetime${type}`].focus(); |
| | | handleClick (type) { |
| | | this.$refs[`datetime${type}`].focus() |
| | | }, |
| | | |
| | | // 返回 |
| | | backFun() { |
| | | this.$router.go(-1); |
| | | backFun () { |
| | | this.$router.go(-1) |
| | | }, |
| | | |
| | | // 跳转到项目详情 |
| | | toProjectDetail(row) { |
| | | toProjectDetail (row) { |
| | | this.$router.push({ |
| | | path: "/projectHome", |
| | | path: '/projectHome', |
| | | query: { |
| | | projectId: row.id, |
| | | projectName: row.name, |
| | | }, |
| | | }); |
| | | projectName: row.name |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 跳转到隐患页面 |
| | | toHiddenDanger(row, type) { |
| | | toHiddenDanger (row, type) { |
| | | this.$router.push({ |
| | | path: "/hiddenDanger", |
| | | path: '/hiddenDanger', |
| | | query: { |
| | | projectId: row.id, |
| | | activeTab: type, |
| | | projectCategory: ["ongoing", "fixed"][ |
| | | localStorage.getItem("activeTab") - 1 |
| | | ], |
| | | }, |
| | | }); |
| | | projectCategory: ['ongoing', 'fixed'][ |
| | | localStorage.getItem('activeTab') - 1 |
| | | ] |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 打开报告弹窗 |
| | | async openReportDialog(row) { |
| | | this.currentProjectId = row.id; |
| | | this.projectVisible = true; |
| | | await this.loadCheckList(row.id); |
| | | async openReportDialog (row) { |
| | | this.currentProjectId = row.id |
| | | this.projectVisible = true |
| | | await this.loadCheckList(row.id) |
| | | }, |
| | | |
| | | // 加载检查列表 |
| | | async loadCheckList(projectId) { |
| | | this.checkLoading = true; |
| | | async loadCheckList (projectId) { |
| | | this.checkLoading = true |
| | | try { |
| | | const res = await getDeviceDetailCheckList({ |
| | | projectId: projectId, |
| | | }); |
| | | projectId: projectId |
| | | }) |
| | | if (res) { |
| | | this.checkList = res.records || []; |
| | | this.checkList = res.records || [] |
| | | } |
| | | } catch (error) { |
| | | console.error("加载检查列表失败:", error); |
| | | this.$message.error("加载检查列表失败"); |
| | | console.error('加载检查列表失败:', error) |
| | | this.$message.error('加载检查列表失败') |
| | | } finally { |
| | | this.checkLoading = false; |
| | | this.checkLoading = false |
| | | } |
| | | }, |
| | | |
| | | // 打开单位信息弹窗 |
| | | openCompanyDialog(row) { |
| | | openCompanyDialog (row) { |
| | | // 解析单位信息 |
| | | this.companyInfo = { |
| | | construction: this.parseCompanyInfo(row.constructionCompanyInfo), |
| | | supervisor: this.parseCompanyInfo(row.supervisorCompanyInfo), |
| | | development: this.parseCompanyInfo(row.developmentCompanyInfo), |
| | | }; |
| | | this.companyVisible = true; |
| | | development: this.parseCompanyInfo(row.developmentCompanyInfo) |
| | | } |
| | | this.companyVisible = true |
| | | }, |
| | | |
| | | // 解析单位信息字符串 |
| | | parseCompanyInfo(infoStr) { |
| | | if (!infoStr) return {}; |
| | | parseCompanyInfo (infoStr) { |
| | | if (!infoStr) return {} |
| | | try { |
| | | return JSON.parse(infoStr); |
| | | return JSON.parse(infoStr) |
| | | } catch (error) { |
| | | return {}; |
| | | return {} |
| | | } |
| | | }, |
| | | |
| | | // 检查是否有任何报告 |
| | | hasAnyReport(row) { |
| | | return row.containSystemRes === 1 || row.containDeviceRes === 1; |
| | | hasAnyReport (row) { |
| | | return row.containSystemRes === 1 || row.containDeviceRes === 1 |
| | | }, |
| | | |
| | | // 检查报告可用性(当按钮被禁用时点击) |
| | | checkReportAvailability(row) { |
| | | checkReportAvailability (row) { |
| | | if (!this.hasAnyReport(row)) { |
| | | this.$message.warning("该计划暂无可查看的报告"); |
| | | this.$message.warning('该计划暂无可查看的报告') |
| | | } |
| | | }, |
| | | |
| | | // 打开报告 |
| | | async openReport(type, row) { |
| | | async openReport (type, row) { |
| | | // 根据类型检查是否有对应报告 |
| | | const hasReport = |
| | | type === "safe" |
| | | type === 'safe' |
| | | ? row.containSystemRes === 1 |
| | | : row.containDeviceRes === 1; |
| | | : row.containDeviceRes === 1 |
| | | |
| | | if (!hasReport) { |
| | | this.$message.warning(`暂无${type === "safe" ? "安全" : "设备"}报告`); |
| | | return; |
| | | this.$message.warning(`暂无${type === 'safe' ? '安全' : '设备'}报告`) |
| | | return |
| | | } |
| | | |
| | | this.currentRow = row; |
| | | this.reportVisible = true; |
| | | this.showPreview = false; |
| | | this.reportLoading = true; |
| | | this.currentRow = row |
| | | this.reportVisible = true |
| | | this.showPreview = false |
| | | this.reportLoading = true |
| | | |
| | | try { |
| | | // 从 localStorage 获取模板 ID |
| | | const deviceTemplateId = localStorage.getItem("deviceTemplateId"); |
| | | const safetyId = localStorage.getItem("safetyId"); |
| | | const safetyName = localStorage.getItem("safetyName"); |
| | | const deviceTemplateName = localStorage.getItem("deviceTemplateName"); |
| | | const deviceTemplateId = localStorage.getItem('deviceTemplateId') |
| | | const safetyId = localStorage.getItem('safetyId') |
| | | const safetyName = localStorage.getItem('safetyName') |
| | | const deviceTemplateName = localStorage.getItem('deviceTemplateName') |
| | | |
| | | // 检查任务 ID |
| | | const checkTaskId = row.id; |
| | | const checkTaskId = row.id |
| | | if (!checkTaskId) { |
| | | this.$message.error("缺少检查任务ID"); |
| | | this.reportLoading = false; |
| | | this.reportVisible = false; |
| | | return; |
| | | this.$message.error('缺少检查任务ID') |
| | | this.reportLoading = false |
| | | this.reportVisible = false |
| | | return |
| | | } |
| | | |
| | | // 使用当前时间戳作为 uuid |
| | | const uuid = Date.now().toString(); |
| | | const uuid = Date.now().toString() |
| | | |
| | | // 第一步:调用接口生成Word文档(返回Word文档流) |
| | | let wordBlob; |
| | | let wordBlob |
| | | try { |
| | | if (type === "safe") { |
| | | if (type === 'safe') { |
| | | // 安全报告(模糊评价) |
| | | if (!safetyId) { |
| | | this.$message.error("缺少安全报告模板ID"); |
| | | this.reportLoading = false; |
| | | this.reportVisible = false; |
| | | return; |
| | | this.$message.error('缺少安全报告模板ID') |
| | | this.reportLoading = false |
| | | this.reportVisible = false |
| | | return |
| | | } |
| | | const safeCommentType = parseInt( |
| | | localStorage.getItem("commentType") || "1" |
| | | ); |
| | | localStorage.getItem('commentType') || '1' |
| | | ) |
| | | if (safeCommentType === 1) { |
| | | wordBlob = await getFuzzyReportWord({ |
| | | checkTaskId: checkTaskId, |
| | | templateId: safetyId, |
| | | uuid: safetyName, |
| | | }); |
| | | uuid: safetyName |
| | | }) |
| | | } else { |
| | | wordBlob = await getScoreReportWord({ |
| | | checkTaskId: checkTaskId, |
| | | templateId: safetyId, |
| | | uuid: safetyName, |
| | | }); |
| | | uuid: safetyName |
| | | }) |
| | | } |
| | | } else { |
| | | // 设备报告(打分评价) |
| | | if (!deviceTemplateId) { |
| | | this.$message.error("缺少设备报告模板ID"); |
| | | this.reportLoading = false; |
| | | this.reportVisible = false; |
| | | return; |
| | | this.$message.error('缺少设备报告模板ID') |
| | | this.reportLoading = false |
| | | this.reportVisible = false |
| | | return |
| | | } |
| | | const safeCommentType = parseInt( |
| | | localStorage.getItem("commentType") || "1" |
| | | ); |
| | | localStorage.getItem('commentType') || '1' |
| | | ) |
| | | if (safeCommentType === 1) { |
| | | wordBlob = await getFuzzyReportWord({ |
| | | checkTaskId: checkTaskId, |
| | | templateId: deviceTemplateId, |
| | | uuid: deviceTemplateName, |
| | | }); |
| | | uuid: deviceTemplateName |
| | | }) |
| | | } else { |
| | | wordBlob = await getScoreReportWord({ |
| | | checkTaskId: checkTaskId, |
| | | templateId: deviceTemplateId, |
| | | uuid: deviceTemplateName, |
| | | }); |
| | | uuid: deviceTemplateName |
| | | }) |
| | | } |
| | | } |
| | | } catch (error) { |
| | | // 捕获生成Word文档时的错误 |
| | | console.error("生成Word文档失败:", error); |
| | | this.$message.error(error.message || "生成报告失败"); |
| | | this.reportLoading = false; |
| | | this.reportVisible = false; |
| | | return; |
| | | console.error('生成Word文档失败:', error) |
| | | this.$message.error(error.message || '生成报告失败') |
| | | this.reportLoading = false |
| | | this.reportVisible = false |
| | | return |
| | | } |
| | | |
| | | // 检查 Word 文档是否生成成功 |
| | | |
| | | if (!wordBlob || wordBlob.size === 0) { |
| | | this.$message.error("报告生成失败"); |
| | | this.reportLoading = false; |
| | | this.reportVisible = false; |
| | | return; |
| | | this.$message.error('报告生成失败') |
| | | this.reportLoading = false |
| | | this.reportVisible = false |
| | | return |
| | | } |
| | | |
| | | // 第二步:使用uuid获取PDF链接 |
| | | let pdfUrlResponse; |
| | | let pdfUrlResponse |
| | | try { |
| | | if (type === "safe") { |
| | | pdfUrlResponse = await getFuzzyReportPdfUrl({ uuid: safetyName }); |
| | | if (type === 'safe') { |
| | | pdfUrlResponse = await getFuzzyReportPdfUrl({ uuid: safetyName }) |
| | | } else { |
| | | pdfUrlResponse = await getFuzzyReportPdfUrl({ |
| | | uuid: deviceTemplateName, |
| | | }); |
| | | uuid: deviceTemplateName |
| | | }) |
| | | } |
| | | } catch (error) { |
| | | // 捕获获取PDF链接时的错误 |
| | | console.error("获取PDF链接失败:", error); |
| | | this.$message.error(error.message || "获取PDF链接失败"); |
| | | this.reportLoading = false; |
| | | this.reportVisible = false; |
| | | return; |
| | | console.error('获取PDF链接失败:', error) |
| | | this.$message.error(error.message || '获取PDF链接失败') |
| | | this.reportLoading = false |
| | | this.reportVisible = false |
| | | return |
| | | } |
| | | |
| | | // 根据后端返回的数据结构获取PDF链接 |
| | | // 假设后端返回格式为 { data: "http://xxx.pdf" } 或直接返回字符串 |
| | | const pdfUrl = pdfUrlResponse.data || pdfUrlResponse; |
| | | const pdfUrl = pdfUrlResponse.data || pdfUrlResponse |
| | | |
| | | if (!pdfUrl) { |
| | | this.$message.error("获取PDF链接失败"); |
| | | this.reportLoading = false; |
| | | this.reportVisible = false; |
| | | return; |
| | | this.$message.error('获取PDF链接失败') |
| | | this.reportLoading = false |
| | | this.reportVisible = false |
| | | return |
| | | } |
| | | |
| | | // 保存PDF链接用于预览和下载 |
| | | this.pdfUrl = pdfUrl; |
| | | this.reportBlobUrl = pdfUrl; // 用于下载 |
| | | this.showPreview = true; |
| | | this.pdfUrl = pdfUrl |
| | | this.reportBlobUrl = pdfUrl // 用于下载 |
| | | this.showPreview = true |
| | | |
| | | this.$message.success("报告加载成功"); |
| | | this.$message.success('报告加载成功') |
| | | } catch (error) { |
| | | console.error("获取报告失败:", error); |
| | | console.error('获取报告失败:', error) |
| | | // 优先显示错误对象中的 message |
| | | if (error.message) { |
| | | this.$message.error(error.message); |
| | | this.$message.error(error.message) |
| | | } else if (error.response) { |
| | | const status = error.response.status; |
| | | const status = error.response.status |
| | | if (status === 404) { |
| | | this.$message.error("报告不存在"); |
| | | this.$message.error('报告不存在') |
| | | } else if (status === 500) { |
| | | this.$message.error("服务器错误,请稍后重试"); |
| | | this.$message.error('服务器错误,请稍后重试') |
| | | } else { |
| | | this.$message.error( |
| | | `获取报告失败: ${error.response.statusText || "未知错误"}` |
| | | ); |
| | | `获取报告失败: ${error.response.statusText || '未知错误'}` |
| | | ) |
| | | } |
| | | } else { |
| | | this.$message.error("获取报告失败,请检查网络连接"); |
| | | this.$message.error('获取报告失败,请检查网络连接') |
| | | } |
| | | this.showPreview = false; |
| | | this.reportVisible = false; |
| | | this.showPreview = false |
| | | this.reportVisible = false |
| | | } finally { |
| | | this.reportLoading = false; |
| | | this.reportLoading = false |
| | | } |
| | | }, |
| | | |
| | | // 下载报告 |
| | | downloadReport() { |
| | | downloadReport () { |
| | | if (!this.reportBlobUrl) { |
| | | this.$message.warning("报告未加载"); |
| | | return; |
| | | this.$message.warning('报告未加载') |
| | | return |
| | | } |
| | | |
| | | try { |
| | | // 直接打开PDF链接进行下载 |
| | | window.open(this.reportBlobUrl, "_blank"); |
| | | this.$message.success("报告下载成功"); |
| | | window.open(this.reportBlobUrl, '_blank') |
| | | this.$message.success('报告下载成功') |
| | | } catch (error) { |
| | | console.error("下载报告失败:", error); |
| | | this.$message.error("下载报告失败"); |
| | | console.error('下载报告失败:', error) |
| | | this.$message.error('下载报告失败') |
| | | } |
| | | }, |
| | | |
| | | // 关闭报告弹窗 |
| | | closeReportDialog() { |
| | | this.reportVisible = false; |
| | | this.showPreview = false; |
| | | closeReportDialog () { |
| | | this.reportVisible = false |
| | | this.showPreview = false |
| | | |
| | | // 清空PDF链接(不需要释放URL,因为是服务器链接) |
| | | this.reportBlobUrl = ""; |
| | | this.pdfUrl = ""; |
| | | this.reportUrl = ""; // 保留兼容性 |
| | | this.reportBlobUrl = '' |
| | | this.pdfUrl = '' |
| | | this.reportUrl = '' // 保留兼容性 |
| | | }, |
| | | |
| | | // 格式化项目类型 |
| | | formatProjectType(type) { |
| | | formatProjectType (type) { |
| | | const typeMap = { |
| | | 0: "房建", |
| | | 1: "市政", |
| | | 2: "建筑工程", |
| | | }; |
| | | return typeMap[type] || "-"; |
| | | 0: '房建', |
| | | 1: '市政', |
| | | 2: '建筑工程' |
| | | } |
| | | return typeMap[type] || '-' |
| | | }, |
| | | |
| | | // 格式化风险等级 |
| | | formatRiskLevel(level) { |
| | | formatRiskLevel (level) { |
| | | const levelMap = { |
| | | 0: "拒绝接受风险", |
| | | 1: "不可接受风险", |
| | | 2: "可接受风险", |
| | | 3: "可容忍风险", |
| | | 4: "可忽略风险", |
| | | }; |
| | | return levelMap[level] || "-"; |
| | | 0: '拒绝接受风险', |
| | | 1: '不可接受风险', |
| | | 2: '可接受风险', |
| | | 3: '可容忍风险', |
| | | 4: '可忽略风险' |
| | | } |
| | | return levelMap[level] || '-' |
| | | }, |
| | | |
| | | // 格式化时间 |
| | | formatTime(time) { |
| | | return time ? moment(time).format("YYYY-MM-DD HH:mm:ss") : "-"; |
| | | formatTime (time) { |
| | | return time ? moment(time).format('YYYY-MM-DD HH:mm:ss') : '-' |
| | | }, |
| | | |
| | | // 格式化计划类型 |
| | | formatPlanType(type) { |
| | | formatPlanType (type) { |
| | | const typeMap = { |
| | | 1: "日常检查", |
| | | 2: "专项检查", |
| | | 3: "综合检查", |
| | | }; |
| | | return typeMap[type] || "-"; |
| | | 1: '日常检查', |
| | | 2: '专项检查', |
| | | 3: '综合检查' |
| | | } |
| | | return typeMap[type] || '-' |
| | | }, |
| | | |
| | | // 判断检查情况是否良好(用于控制图标颜色) |
| | | isCheckResultGood(checkResult) { |
| | | isCheckResultGood (checkResult) { |
| | | // 检查情况只有"已检查"和"未检查"两种状态 |
| | | // 已检查显示绿色,未检查显示红色 |
| | | if (!checkResult) return false; |
| | | if (!checkResult) return false |
| | | |
| | | return checkResult.includes("已检查"); |
| | | return checkResult.includes('已检查') |
| | | }, |
| | | |
| | | // 格式化地址信息 |
| | | formatAddress(addressInfo) { |
| | | if (!addressInfo) return "-"; |
| | | formatAddress (addressInfo) { |
| | | if (!addressInfo) return '-' |
| | | try { |
| | | const addressObj = JSON.parse(addressInfo); |
| | | const addressObj = JSON.parse(addressInfo) |
| | | // 拼接完整地址:省 + 市 + 区 + 详细地址 |
| | | const { province, city, district, detail } = addressObj; |
| | | const parts = []; |
| | | if (province) parts.push(province); |
| | | if (city) parts.push(city); |
| | | if (district && district !== "其它区") parts.push(district); |
| | | if (detail) parts.push(detail); |
| | | return parts.join("") || "-"; |
| | | const { province, city, district, detail } = addressObj |
| | | const parts = [] |
| | | if (province) parts.push(province) |
| | | if (city) parts.push(city) |
| | | if (district && district !== '其它区') parts.push(district) |
| | | if (detail) parts.push(detail) |
| | | return parts.join('') || '-' |
| | | } catch (error) { |
| | | // 如果解析失败,直接返回原始字符串 |
| | | return addressInfo || "-"; |
| | | return addressInfo || '-' |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style lang="less"> |
| | | .custom-popper { |