Browse Source

Word / Excel 通过后端转 PDF 后预览

master
han\hanst 12 hours ago
parent
commit
271d90acc3
  1. 30
      src/views/modules/eam/com_project_proof_record.vue

30
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())) {

Loading…
Cancel
Save