[update] 修改预览调公用方法不止word文件,其他能预览的都调
This commit is contained in:
@@ -96,7 +96,6 @@ import Vue from 'vue'
|
|||||||
import { ACCESS_TOKEN } from '../store/mutation-types.js'
|
import { ACCESS_TOKEN } from '../store/mutation-types.js'
|
||||||
import { downloadFile, getFileAccessHttpUrl, getAction } from '../api/manage.js'
|
import { downloadFile, getFileAccessHttpUrl, getAction } from '../api/manage.js'
|
||||||
import { previewPdf } from '../utils/previewPdf.js'
|
import { previewPdf } from '../utils/previewPdf.js'
|
||||||
import { Base64 } from 'js-base64'
|
|
||||||
import FlowChartModal from './FlowChartModal.vue'
|
import FlowChartModal from './FlowChartModal.vue'
|
||||||
import UploadFile from './UploadFile'
|
import UploadFile from './UploadFile'
|
||||||
import { filterObj } from '../utils/util'
|
import { filterObj } from '../utils/util'
|
||||||
@@ -318,13 +317,8 @@ export default {
|
|||||||
window.open(url)
|
window.open(url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// word用KKfile预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
|
||||||
kkFilePreview(fileFullUrl)
|
kkFilePreview(fileFullUrl)
|
||||||
return
|
|
||||||
}
|
|
||||||
// 如果都不能预览就下载
|
|
||||||
downloadFile(`/sys/common/download/${file.id}`, file.fileName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,8 @@ import { kkFilePreview } from '@/utils/kkFilePreview'
|
|||||||
|
|
||||||
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
||||||
const FILE_TYPE_PDF = 'pdf'
|
const FILE_TYPE_PDF = 'pdf'
|
||||||
|
// 支持预览的文件后缀
|
||||||
|
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'QuestionAnswerList',
|
name: 'QuestionAnswerList',
|
||||||
@@ -224,6 +226,14 @@ export default {
|
|||||||
// 截取文件后缀名
|
// 截取文件后缀名
|
||||||
const fileSuffix = record.declareFileName ? record.declareFileName.split('.')[record.declareFileName.split('.').length - 1] : ''
|
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 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)) {
|
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
||||||
this.imageUrl = getFileAccessHttpUrl(record.declareFile)
|
this.imageUrl = getFileAccessHttpUrl(record.declareFile)
|
||||||
@@ -240,13 +250,12 @@ export default {
|
|||||||
window.open(url)
|
window.open(url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// word用KKfile预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
if (fileSuffix === 'doc' || fileSuffix === 'docx') {
|
|
||||||
kkFilePreview(fileFullUrl)
|
kkFilePreview(fileFullUrl)
|
||||||
return
|
},
|
||||||
}
|
handleDownload (id, name) {
|
||||||
// 如果都不能预览就下载
|
// 下载文件
|
||||||
downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName)
|
downloadFile(`/sys/common/download/${id}`, name)
|
||||||
},
|
},
|
||||||
// 查看
|
// 查看
|
||||||
handleDetail (record) {
|
handleDetail (record) {
|
||||||
|
|||||||
@@ -230,13 +230,8 @@ export default {
|
|||||||
window.open(url)
|
window.open(url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// word用KKfile预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
|
||||||
kkFilePreview(fileFullUrl)
|
kkFilePreview(fileFullUrl)
|
||||||
return
|
|
||||||
}
|
|
||||||
// 如果都不能预览就下载
|
|
||||||
downloadFile(`/sys/common/download/${file.id}`, file.fileName)
|
|
||||||
},
|
},
|
||||||
handleDownload (file) {
|
handleDownload (file) {
|
||||||
// 下载文件
|
// 下载文件
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ import { kkFilePreview } from '@/utils/kkFilePreview'
|
|||||||
|
|
||||||
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
||||||
const FILE_TYPE_PDF = 'pdf'
|
const FILE_TYPE_PDF = 'pdf'
|
||||||
|
// 支持预览的文件后缀
|
||||||
|
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CheckReportModal',
|
name: 'CheckReportModal',
|
||||||
@@ -150,6 +152,14 @@ export default {
|
|||||||
// 截取文件后缀名
|
// 截取文件后缀名
|
||||||
const fileSuffix = record.declareFileName ? record.declareFileName.split('.')[record.declareFileName.split('.').length - 1] : ''
|
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 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)) {
|
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
||||||
this.imageUrl = getFileAccessHttpUrl(record.declareFile)
|
this.imageUrl = getFileAccessHttpUrl(record.declareFile)
|
||||||
@@ -166,13 +176,12 @@ export default {
|
|||||||
window.open(url)
|
window.open(url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// word用KKfile预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
if (fileSuffix === 'doc' || fileSuffix === 'docx') {
|
|
||||||
kkFilePreview(fileFullUrl)
|
kkFilePreview(fileFullUrl)
|
||||||
return
|
},
|
||||||
}
|
handleDownload (id, name) {
|
||||||
// 如果都不能预览就下载
|
// 下载文件
|
||||||
downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName)
|
downloadFile(`/sys/common/download/${id}`, name)
|
||||||
},
|
},
|
||||||
handleCancel () {
|
handleCancel () {
|
||||||
this.close()
|
this.close()
|
||||||
|
|||||||
@@ -161,8 +161,6 @@ import { getFileAccessHttpUrl, downloadFile } from '@/api/manage'
|
|||||||
import { getFileInfo } from '../../../../api/api'
|
import { getFileInfo } from '../../../../api/api'
|
||||||
import { kkFilePreview } from '@/utils/kkFilePreview'
|
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 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_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
||||||
@@ -242,13 +240,8 @@ export default {
|
|||||||
window.open(url)
|
window.open(url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// word用KKfile预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
|
||||||
kkFilePreview(fileFullUrl)
|
kkFilePreview(fileFullUrl)
|
||||||
return
|
|
||||||
}
|
|
||||||
// 如果都不能预览就下载
|
|
||||||
downloadFile(`/sys/common/download/${file.id}`, file.fileName)
|
|
||||||
},
|
},
|
||||||
getFileInfo (fileId) {
|
getFileInfo (fileId) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
|||||||
@@ -294,13 +294,8 @@ export default {
|
|||||||
window.open(url)
|
window.open(url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// word用KKfile预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
|
||||||
kkFilePreview(fileFullUrl)
|
kkFilePreview(fileFullUrl)
|
||||||
return
|
|
||||||
}
|
|
||||||
// 如果都不能预览就下载
|
|
||||||
downloadFile(`/sys/common/download/${file.id}`, file.fileName)
|
|
||||||
},
|
},
|
||||||
handleDownload (file) {
|
handleDownload (file) {
|
||||||
// 下载文件
|
// 下载文件
|
||||||
|
|||||||
+1
-6
@@ -363,13 +363,8 @@ export default {
|
|||||||
window.open(url)
|
window.open(url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// word用KKfile预览
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
if (canPreview && (fileSuffix === 'doc' || fileSuffix === 'docx')) {
|
|
||||||
kkFilePreview(fileFullUrl)
|
kkFilePreview(fileFullUrl)
|
||||||
return
|
|
||||||
}
|
|
||||||
// 如果都不能预览就下载
|
|
||||||
downloadFile(`/sys/common/download/${record.standardFile}`, record.standardFile_dictText)
|
|
||||||
},
|
},
|
||||||
// 下载企标文本
|
// 下载企标文本
|
||||||
handleDownloadUploadStandard (record) {
|
handleDownloadUploadStandard (record) {
|
||||||
|
|||||||
Reference in New Issue
Block a user