From 271d90acc329198e22ff277cc49760823a99d9bb Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Mon, 2 Mar 2026 14:13:54 +0800 Subject: [PATCH] =?UTF-8?q?Word=20/=20Excel=20=E9=80=9A=E8=BF=87=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E8=BD=AC=20PDF=20=E5=90=8E=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/eam/com_project_proof_record.vue | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) 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())) {