diff --git a/src/views/enterpriseStandardLibrary/check/modules/CheckReportModal.vue b/src/views/enterpriseStandardLibrary/check/modules/CheckReportModal.vue index ed847ec7..7937a07b 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', @@ -149,7 +151,15 @@ export default { handleRelatedMaterialClick (record) { // 截取文件后缀名 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}?at=${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/workCenter/enterpriseStandardInspectionProcess/modules/InspectionProcessContentModal.vue b/src/views/workCenter/enterpriseStandardInspectionProcess/modules/InspectionProcessContentModal.vue index 407aee32..7f237a6f 100644 --- a/src/views/workCenter/enterpriseStandardInspectionProcess/modules/InspectionProcessContentModal.vue +++ b/src/views/workCenter/enterpriseStandardInspectionProcess/modules/InspectionProcessContentModal.vue @@ -22,13 +22,14 @@ + v-decorator.trim="[ 'clause', validatorRules.sectionNumber ]" /> @@ -58,7 +59,8 @@ import { getFileInfo } from '@/api/api' import { previewPdf } from '@/utils/previewPdf' import Vue from 'vue' import { ACCESS_TOKEN } from '@/store/mutation-types' -import { addInspectionContentTable, editInspectionContentTable, getFileByInspectId } from '@api/workCenter' +import { getFileByInspectId } from '@api/workCenter' +import moment from 'moment/moment' const Base64 = require('js-base64').Base64 @@ -98,7 +100,7 @@ export default { validateTrigger: 'blur' } }, - index: undefined, // 编辑的表格的下标 + index: -1, // 编辑的表格的下标 iframeSrc: '' // 左侧预览的路径 } }, @@ -152,8 +154,8 @@ export default { // pdf预览 const url = previewPdf(file.id) this.iframeSrc = url - } else if (fileSuffix === 'docx') { - const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}` + } else if (['doc', 'docx'].includes(fileSuffix)) { + const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}` // word文件仍使用KKFile进行预览 const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}` this.iframeSrc = url @@ -162,7 +164,7 @@ export default { close () { this.visible = false this.model = {} - this.index = undefined + this.index = -1 this.iframeSrc = '' }, handleCancel () { @@ -170,53 +172,26 @@ export default { }, // 提交并新增 handleSubmitAddAdd () { - if (this.confirmLoading) return this.form.validateFields((err, values) => { if (!err) { - this.confirmLoading = true const param = Object.assign({}, this.model, values) - if (!param.processEsInspectId) { - param.processEsInspectId = this.data.id + if (!param.createTime) { + param.createTime = moment().format('YYYY-MM-DD HH:mm:ss') } - console.log(param) - const fn = param.id ? editInspectionContentTable : addInspectionContentTable - fn(param).then(res => { - if (res.success) { - this.$message.success(res.message) - this.$emit('ok', param, this.index) - this.form.resetFields() - this.model = {} - } else { - this.$message.warn(res.message) - } - }).finally(() => { - this.confirmLoading = false - }) + this.$emit('ok', param, this.index) + this.form.resetFields() } }) }, handleOk () { - if (this.confirmLoading) return this.form.validateFields((err, values) => { if (!err) { - this.confirmLoading = true const param = Object.assign({}, this.model, values) - if (!this.model.processEsInspectId) { - param.processEsInspectId = this.data.id + if (!param.createTime) { + param.createTime = moment().format('YYYY-MM-DD HH:mm:ss') } - console.log(param) - const fn = param.id ? editInspectionContentTable : addInspectionContentTable - fn(param).then(res => { - if (res.success) { - this.$message.success(res.message) - this.$emit('ok', param, this.index) - this.close() - } else { - this.$message.warn(res.message) - } - }).finally(() => { - this.confirmLoading = false - }) + this.$emit('ok', param, this.index) + this.close() } }) } @@ -232,7 +207,6 @@ export default { .content-left { width: 60%; height: 100%; - overflow-y: scroll; iframe { height: calc(100% - 20px) !important; }