diff --git a/src/components/ProcessDetailList.vue b/src/components/ProcessDetailList.vue index 6e1dccdc..67f15656 100644 --- a/src/components/ProcessDetailList.vue +++ b/src/components/ProcessDetailList.vue @@ -96,7 +96,6 @@ import Vue from 'vue' import { ACCESS_TOKEN } from '../store/mutation-types.js' import { downloadFile, getFileAccessHttpUrl, getAction } from '../api/manage.js' import { previewPdf } from '../utils/previewPdf.js' -import { Base64 } from 'js-base64' import FlowChartModal from './FlowChartModal.vue' import UploadFile from './UploadFile' import { filterObj } from '../utils/util' @@ -318,13 +317,8 @@ export default { window.open(url) return } - // word用KKfile预览 - if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) { - kkFilePreview(fileFullUrl) - return - } - // 如果都不能预览就下载 - downloadFile(`/sys/common/download/${file.id}`, file.fileName) + // 其余可预览文件仍使用KKFile进行预览 + kkFilePreview(fileFullUrl) } } } diff --git a/src/views/businessSupport/questionAnswerLibrary/QuestionAnswerList.vue b/src/views/businessSupport/questionAnswerLibrary/QuestionAnswerList.vue index d4755e28..5dcc9349 100644 --- a/src/views/businessSupport/questionAnswerLibrary/QuestionAnswerList.vue +++ b/src/views/businessSupport/questionAnswerLibrary/QuestionAnswerList.vue @@ -128,6 +128,8 @@ import { kkFilePreview } from '@/utils/kkFilePreview' const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw'] const FILE_TYPE_PDF = 'pdf' +// 支持预览的文件后缀 +const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'] export default { name: 'QuestionAnswerList', @@ -224,6 +226,14 @@ export default { // 截取文件后缀名 const fileSuffix = record.declareFileName ? record.declareFileName.split('.')[record.declareFileName.split('.').length - 1] : '' const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.declareFile}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.declareFileName}` + const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix === tt) + // 判断是否为可预览格式的文件 + if (!canPreview) { + this.$message.loading(this.$t('uploadFile.cannotPreview')).then(() => { + this.handleDownload(record.declareFile, record.declareFileName) + }) + return + } // 图片预览,使用自己添加的组件 if (FILE_TYPE_IMGS.includes(fileSuffix)) { this.imageUrl = getFileAccessHttpUrl(record.declareFile) @@ -240,13 +250,12 @@ export default { window.open(url) return } - // word用KKfile预览 - if (fileSuffix === 'doc' || fileSuffix === 'docx') { - kkFilePreview(fileFullUrl) - return - } - // 如果都不能预览就下载 - downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName) + // 其余可预览文件仍使用KKFile进行预览 + kkFilePreview(fileFullUrl) + }, + handleDownload (id, name) { + // 下载文件 + downloadFile(`/sys/common/download/${id}`, name) }, // 查看 handleDetail (record) { diff --git a/src/views/businessSupport/questionAnswerLibrary/page/AnswerPage.vue b/src/views/businessSupport/questionAnswerLibrary/page/AnswerPage.vue index efa31fe0..4d37abb7 100644 --- a/src/views/businessSupport/questionAnswerLibrary/page/AnswerPage.vue +++ b/src/views/businessSupport/questionAnswerLibrary/page/AnswerPage.vue @@ -230,13 +230,8 @@ export default { window.open(url) return } - // word用KKfile预览 - if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) { - kkFilePreview(fileFullUrl) - return - } - // 如果都不能预览就下载 - downloadFile(`/sys/common/download/${file.id}`, file.fileName) + // 其余可预览文件仍使用KKFile进行预览 + kkFilePreview(fileFullUrl) }, handleDownload (file) { // 下载文件 diff --git a/src/views/enterpriseStandardLibrary/check/modules/CheckReportModal.vue b/src/views/enterpriseStandardLibrary/check/modules/CheckReportModal.vue index ed847ec7..44c68b99 100644 --- a/src/views/enterpriseStandardLibrary/check/modules/CheckReportModal.vue +++ b/src/views/enterpriseStandardLibrary/check/modules/CheckReportModal.vue @@ -53,6 +53,8 @@ import { kkFilePreview } from '@/utils/kkFilePreview' const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw'] const FILE_TYPE_PDF = 'pdf' +// 支持预览的文件后缀 +const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'] export default { name: 'CheckReportModal', @@ -150,6 +152,14 @@ export default { // 截取文件后缀名 const fileSuffix = record.declareFileName ? record.declareFileName.split('.')[record.declareFileName.split('.').length - 1] : '' const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.declareFile}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.declareFileName}` + const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix === tt) + // 判断是否为可预览格式的文件 + if (!canPreview) { + this.$message.loading(this.$t('uploadFile.cannotPreview')).then(() => { + this.handleDownload(record.declareFile, record.declareFileName) + }) + return + } // 图片预览,使用自己添加的组件 if (FILE_TYPE_IMGS.includes(fileSuffix)) { this.imageUrl = getFileAccessHttpUrl(record.declareFile) @@ -166,13 +176,12 @@ export default { window.open(url) return } - // word用KKfile预览 - if (fileSuffix === 'doc' || fileSuffix === 'docx') { - kkFilePreview(fileFullUrl) - return - } - // 如果都不能预览就下载 - downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName) + // 其余可预览文件仍使用KKFile进行预览 + kkFilePreview(fileFullUrl) + }, + handleDownload (id, name) { + // 下载文件 + downloadFile(`/sys/common/download/${id}`, name) }, handleCancel () { this.close() diff --git a/src/views/enterpriseStandardLibrary/plan/detail/PlanDetail.vue b/src/views/enterpriseStandardLibrary/plan/detail/PlanDetail.vue index 82d93a5d..9c4854c3 100644 --- a/src/views/enterpriseStandardLibrary/plan/detail/PlanDetail.vue +++ b/src/views/enterpriseStandardLibrary/plan/detail/PlanDetail.vue @@ -161,8 +161,6 @@ import { getFileAccessHttpUrl, downloadFile } from '@/api/manage' import { getFileInfo } from '../../../../api/api' import { kkFilePreview } from '@/utils/kkFilePreview' -// 支持预览的文件类型 -const CAN_PREVIEW_FILE_TYPE = ['pdf', 'image'] // 支持预览的文件后缀 const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'] const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw'] @@ -242,13 +240,8 @@ export default { window.open(url) return } - // word用KKfile预览 - if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) { - kkFilePreview(fileFullUrl) - return - } - // 如果都不能预览就下载 - downloadFile(`/sys/common/download/${file.id}`, file.fileName) + // 其余可预览文件仍使用KKFile进行预览 + kkFilePreview(fileFullUrl) }, getFileInfo (fileId) { return new Promise(resolve => { diff --git a/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue b/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue index 88a02589..4e44df3c 100644 --- a/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue +++ b/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue @@ -294,13 +294,8 @@ export default { window.open(url) return } - // word用KKfile预览 - if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) { - kkFilePreview(fileFullUrl) - return - } - // 如果都不能预览就下载 - downloadFile(`/sys/common/download/${file.id}`, file.fileName) + // 其余可预览文件仍使用KKFile进行预览 + kkFilePreview(fileFullUrl) }, handleDownload (file) { // 下载文件 diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue index dca95248..0ecfb3eb 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue @@ -363,13 +363,8 @@ export default { window.open(url) return } - // word用KKfile预览 - if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) { - kkFilePreview(fileFullUrl) - return - } - // 如果都不能预览就下载 - downloadFile(`/sys/common/download/${record.standardFile}`, record.standardFile_dictText) + // 其余可预览文件仍使用KKFile进行预览 + kkFilePreview(fileFullUrl) }, // 下载企标文本 handleDownloadUploadStandard (record) {