[update] 修改预览word文件改成公用方法

This commit is contained in:
lideqin
2024-01-02 15:21:41 +08:00
parent 74e6cdba16
commit 1870dd41ac
8 changed files with 62 additions and 35 deletions
+2 -2
View File
@@ -100,6 +100,7 @@ import { Base64 } from 'js-base64'
import FlowChartModal from './FlowChartModal.vue'
import UploadFile from './UploadFile'
import { filterObj } from '../utils/util'
import { kkFilePreview } from '../utils/kkFilePreview'
// 支持预览的文件后缀
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
@@ -314,8 +315,7 @@ export default {
}
// word用KKfile预览
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
@@ -122,12 +122,12 @@ import JTable from '@/components/jero/JTable'
import Vue from 'vue'
import { ACCESS_TOKEN, USER_INFO } from '@/store/mutation-types'
import { previewPdf } from '@/utils/previewPdf'
import { getFileAccessHttpUrl } from '@/api/manage'
import { getFileAccessHttpUrl, downloadFile } from '@/api/manage'
import QuizModal from './modules/QuizModal'
import { kkFilePreview } from '@/utils/kkFilePreview'
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
const FILE_TYPE_PDF = 'pdf'
const Base64 = require('js-base64').Base64
export default {
name: 'QuestionAnswerList',
@@ -240,9 +240,13 @@ export default {
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
// word用KKfile预览
if (fileSuffix === 'doc' || fileSuffix === 'docx') {
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName)
},
// 查看
handleDetail (record) {
@@ -116,6 +116,7 @@ import { getQuizById, answerQuiz, setOrCancelTop, deleteAnswer } from '@/api/bus
import { getFileInfo } from '@/api/api'
import { previewPdf } from '@/utils/previewPdf'
import InternalDetailPage from '@/components/InternalDetailPage'
import { kkFilePreview } from '@/utils/kkFilePreview'
// 支持预览的文件后缀
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
@@ -229,9 +230,13 @@ export default {
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
// word用KKfile预览
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
downloadFile(`/sys/common/download/${file.id}`, file.fileName)
},
handleDownload (file) {
// 下载文件
@@ -45,14 +45,14 @@
<script>
import Vue from 'vue'
import { getFileAccessHttpUrl } from '@/api/manage'
import { getFileAccessHttpUrl, downloadFile } from '@/api/manage'
import { previewPdf } from '@/utils/previewPdf'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getCheckReportById } from '@/api/enterpriseStandardLibraryApi'
import { kkFilePreview } from '@/utils/kkFilePreview'
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
const FILE_TYPE_PDF = 'pdf'
const Base64 = require('js-base64').Base64
export default {
name: 'CheckReportModal',
@@ -166,9 +166,13 @@ export default {
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
// word用KKfile预览
if (fileSuffix === 'doc' || fileSuffix === 'docx') {
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName)
},
handleCancel () {
this.close()
@@ -157,8 +157,9 @@ import { getEnterpriseStandardPlanInfoById } from '@/api/enterpriseStandardLibra
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { previewPdf } from '@/utils/previewPdf'
import { getFileAccessHttpUrl } from '@/api/manage'
import { getFileAccessHttpUrl, downloadFile } from '@/api/manage'
import { getFileInfo } from '../../../../api/api'
import { kkFilePreview } from '@/utils/kkFilePreview'
// 支持预览的文件类型
const CAN_PREVIEW_FILE_TYPE = ['pdf', 'image']
@@ -166,7 +167,6 @@ 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']
const FILE_TYPE_PDF = 'pdf'
const Base64 = require('js-base64').Base64
export default {
name: 'PlanDetail',
@@ -242,9 +242,13 @@ export default {
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
// word用KKfile预览
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
downloadFile(`/sys/common/download/${file.id}`, file.fileName)
},
getFileInfo (fileId) {
return new Promise(resolve => {
@@ -110,12 +110,11 @@ import { JeroListMixin } from '@/mixins/JeroListMixin'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { previewPdf } from '@/utils/previewPdf'
import { getFileAccessHttpUrl } from '@/api/manage'
import { downFile } from '../../../api/manage'
import { getFileAccessHttpUrl, downFile, downloadFile } from '@/api/manage'
import { kkFilePreview } from '@/utils/kkFilePreview'
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
const FILE_TYPE_PDF = 'pdf'
const Base64 = require('js-base64').Base64
export default {
name: 'EnterpriseStandardPublicize',
@@ -224,9 +223,13 @@ export default {
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
// word用KKfile预览
if (fileSuffix === 'doc' || fileSuffix === 'docx') {
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName)
},
// 导出
handleExportXls (fileName) {
@@ -143,12 +143,12 @@ import { previewPdf } from '@/utils/previewPdf'
import { getFileInfo } from '../../../../api/api'
import UserSelectModal from '@comp/selection/UserSelectModal'
import StandardResolutionSheetModal from '@views/standardRegulationLibrary/commonPage/modules/StandardResolutionSheetModal'
import { kkFilePreview } from '@/utils/kkFilePreview'
// 支持预览的文件后缀
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
const FILE_TYPE_PDF = 'pdf'
const Base64 = require('js-base64').Base64
export default {
name: 'EnterpriseStandardDetail',
@@ -292,9 +292,13 @@ export default {
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
// word用KKfile预览
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
downloadFile(`/sys/common/download/${file.id}`, file.fileName)
},
handleDownload (file) {
// 下载文件
@@ -179,14 +179,13 @@ import Vue from 'vue'
import { previewPdf } from '@/utils/previewPdf'
import { downloadFile, getFileAccessHttpUrl } from '@/api/manage'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { kkFilePreview } from '@/utils/kkFilePreview'
// 支持预览的文件后缀
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
const FILE_TYPE_PDF = 'pdf'
const Base64 = require('js-base64').Base64
export default {
name: 'MainDrafterCollectUploadMinuteBaseInfo',
components: { BaseInfoForm, UserSelection, JTable, CheckContentModal, UploadFile },
@@ -366,9 +365,13 @@ export default {
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = window._CONFIG.onlinePreviewDomainURL + '?url=' + encodeURIComponent(Base64.encode(fileFullUrl))
window.open(url)
// word用KKfile预览
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
kkFilePreview(fileFullUrl)
return
}
// 如果都不能预览就下载
downloadFile(`/sys/common/download/${record.standardFile}`, record.standardFile_dictText)
},
// 下载企标文本
handleDownloadUploadStandard (record) {