diff --git a/src/views/modules/eam/com_project_proof_record.vue b/src/views/modules/eam/com_project_proof_record.vue index 56075f0..31d06b0 100644 --- a/src/views/modules/eam/com_project_proof_record.vue +++ b/src/views/modules/eam/com_project_proof_record.vue @@ -654,6 +654,7 @@ import moment from 'moment'; import 'moment/locale/zh-cn'; import {downLoadObjectFile} from "../../../api/eam/eam_object_list"; + import {previewOssFileById2} from '@/api/oss/oss'; import async from "async"; import {EventBus} from "../../../main"; import {getSiteAndBuByUserName} from "../../../api/qc/qc"; @@ -2316,19 +2317,26 @@ }) } else if (office.includes(row.fileType.toLowerCase())) { - if (row.fileType.toLowerCase() === 'doc' || row.fileType.toLowerCase() === 'docx') { - type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' - } else if (row.fileType.toLowerCase() === 'ppt' || row.fileType.toLowerCase() === 'pptx') { - type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation' + const lowerType = row.fileType.toLowerCase() + if (lowerType === 'ppt' || lowerType === 'pptx') { + this.$message.warning('该文件格式暂不支持预览,请下载后查看') + return + } + // Office文件不支持预览 + if (lowerType === 'doc' || lowerType === 'ppt' || lowerType === 'pptx') { + this.$message.warning('该文件格式暂不支持预览,请下载后查看') + return + } + // Word / Excel 通过后端转 PDF 后预览 + if (lowerType === 'docx') { + type = 'word' } else { - type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + type = 'excel' } - downLoadObjectFile(row).then(({data}) => { - const blob = new Blob([data], { type: type }); - // 创建URL来生成预览 - const fileURL = URL.createObjectURL(blob); - // 在新标签页中打开文件预览 - const newTab = window.open(fileURL, '_blank') + previewOssFileById2({ id: row.id, fileType: type }).then(({data}) => { + const blob = new Blob([data], { type: 'application/pdf;charset=UTF-8' }) + const fileURL = URL.createObjectURL(blob) + window.open(fileURL, '_blank') }) } else if (pdf.includes(row.fileType.toLowerCase())) {