diff --git a/src/utils/onlyOfficeUtils.js b/src/utils/onlyOfficeUtils.js index 6ef93350..0aff7b10 100644 --- a/src/utils/onlyOfficeUtils.js +++ b/src/utils/onlyOfficeUtils.js @@ -81,3 +81,20 @@ export const onlineEditor = async (params, fileId) => { window.open(url, '_blank') return fileInfo.id } + +// 跳转在线编辑查看 +export const onlineEditorView = async (fileId) => { + let fileInfo + if (fileId) { + fileInfo = await queryFileInfo(fileId) + } + if (!fileInfo) { + return false + } + // 获取用户信息 + const userInfo = Vue.ls.get(USER_INFO) + // 截取文件后缀名 + const fileSuffix = (fileInfo.fileName ? fileInfo.fileName.split('.')[fileInfo.fileName.split('.').length - 1] : '').toLowerCase() + const url = `${window._CONFIG.onlyOfficeUrl}/previewHistoryPage?filePath=${fileInfo.editFilePath}&fileName=${fileInfo.fileName}&fileType=${fileSuffix}&fileId=${fileInfo.id}&key=${fileInfo.id}&userId=${userInfo.id}&userName=${userInfo.realname}&fileInfo={}` + window.open(url, '_blank') +} diff --git a/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue b/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue index 43f89aa0..356da24f 100644 --- a/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue @@ -49,6 +49,7 @@ import { ACCESS_TOKEN } from '@/store/mutation-types' import { kkFilePreview } from '@/utils/kkFilePreview' import { queryFileInfoByEditId } from '../../../../api/workCenter' import { Base64 } from 'js-base64' +import { onlineEditorView } from '../../../../utils/onlyOfficeUtils' export default { name: 'ApproveBaseInfo', @@ -185,18 +186,9 @@ export default { if (!this.onEditFile) { this.$message.warning(this.$t('workCenter.enStandardRevision.noStandardTextLook')) return + } else { + onlineEditorView(this.onEditFile) } - queryFileInfoByEditId({ id: this.onEditFile }).then(res => { - if (res.success) { - const file = res.result - const filePaths = file.editFilePath.split('/') - const fileName = filePaths[filePaths.length - 1] - const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.editFilePath + '&fullfilename=' + fileName))}` - window.open(url, '_blank') - } else { - this.$message.warning(res.message) - } - }) } } } diff --git a/src/views/workCenter/enterpriseStandardRevision/EnterpriseStandardRevisionFlow.vue b/src/views/workCenter/enterpriseStandardRevision/EnterpriseStandardRevisionFlow.vue index a8db4474..72dc23d2 100644 --- a/src/views/workCenter/enterpriseStandardRevision/EnterpriseStandardRevisionFlow.vue +++ b/src/views/workCenter/enterpriseStandardRevision/EnterpriseStandardRevisionFlow.vue @@ -181,11 +181,12 @@ import { enStandardEditGetDataDraft, enStandardEditReject, enStandardEditSave, - enStandardEditTurnTo + enStandardEditTurnTo, + queryFileInfoByEditId } from '@/api/workCenter' import { WorkCenterMixin } from '@/mixins/WorkCenterMixin' -import { queryFileInfoByEditId } from '../../../api/workCenter' import { Base64 } from 'js-base64' +import { onlineEditorView } from '../../../utils/onlyOfficeUtils' export default { name: 'EnterpriseStandardRevisionFlow', @@ -716,20 +717,9 @@ export default { onlineEditView (fileId) { if (!fileId) { this.$message.warning(this.$t('workCenter.enStandardRevision.noStandardTextLook')) - return + } else { + onlineEditorView(fileId) } - queryFileInfoByEditId({ id: fileId }).then(res => { - if (res.success) { - const file = res.result - const filePaths = file.editFilePath.split('/') - const fileName = filePaths[filePaths.length - 1] - const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(this.documentUrl + file.editFilePath + '&fullfilename=' + fileName))}` - console.log(this.documentUrl + file.editFilePath + '&fullfilename=' + fileName) - window.open(url, '_blank') - } else { - this.$message.warning(res.message) - } - }) } } }