[update] 企标制修订和企标更改流程左侧预览改成在线编辑预览
This commit is contained in:
@@ -98,3 +98,20 @@ export const onlineEditorView = async (fileId) => {
|
||||
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')
|
||||
}
|
||||
|
||||
// 根据文件id获取在线编辑查看路径
|
||||
export const onlineEditorGetUrl = 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={}`
|
||||
return url
|
||||
}
|
||||
|
||||
+8
-25
@@ -45,6 +45,7 @@ import { previewPdf } from '@/utils/previewPdf'
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import { queryFileInfoByEditId } from '../../../../api/workCenter'
|
||||
import { onlineEditorGetUrl, onlineEditorView } from '../../../../utils/onlyOfficeUtils'
|
||||
|
||||
const Base64 = require('js-base64').Base64
|
||||
|
||||
@@ -85,17 +86,17 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add (fileId) {
|
||||
this.getFileInfo(fileId).then(res => {
|
||||
this.handlePreview(res)
|
||||
})
|
||||
async add (fileId) {
|
||||
if (fileId) {
|
||||
this.iframeSrc = await onlineEditorGetUrl(fileId)
|
||||
}
|
||||
this.visible = true
|
||||
this.form.resetFields()
|
||||
},
|
||||
edit (fileId, record, index) {
|
||||
this.getFileInfo(fileId).then(res => {
|
||||
this.handlePreview(res)
|
||||
})
|
||||
if (fileId) {
|
||||
this.iframeSrc = onlineEditorGetUrl(fileId)
|
||||
}
|
||||
this.visible = true
|
||||
this.index = index
|
||||
this.form.resetFields()
|
||||
@@ -104,24 +105,6 @@ export default {
|
||||
this.form.setFieldsValue(pick(this.model, 'clause', 'requirement'))
|
||||
})
|
||||
},
|
||||
getFileInfo (fileId) {
|
||||
return new Promise(resolve => {
|
||||
let fileInfo
|
||||
queryFileInfoByEditId({ id: fileId }).then(res => {
|
||||
if (res.success) {
|
||||
fileInfo = res.result
|
||||
}
|
||||
}).finally(() => {
|
||||
resolve(fileInfo)
|
||||
})
|
||||
})
|
||||
},
|
||||
handlePreview (file) {
|
||||
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))}`
|
||||
this.iframeSrc = url
|
||||
},
|
||||
close () {
|
||||
this.visible = false
|
||||
this.model = {}
|
||||
|
||||
@@ -64,6 +64,7 @@ import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import { USER_INFO } from '../../../../store/mutation-types'
|
||||
import { queryFileInfoByEditId } from '../../../../api/workCenter'
|
||||
import { onlineEditorGetUrl } from '../../../../utils/onlyOfficeUtils'
|
||||
|
||||
const Base64 = require('js-base64').Base64
|
||||
|
||||
@@ -124,18 +125,18 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add (file) {
|
||||
this.getFileInfo(file).then(res => {
|
||||
this.handlePreview(res)
|
||||
})
|
||||
async add (file) {
|
||||
if (file) {
|
||||
this.iframeSrc = await onlineEditorGetUrl(file)
|
||||
}
|
||||
this.isAdd = true
|
||||
this.visible = true
|
||||
this.form.resetFields()
|
||||
},
|
||||
edit (file, record, index) {
|
||||
this.getFileInfo(file).then(res => {
|
||||
this.handlePreview(res)
|
||||
})
|
||||
async edit (file, record, index) {
|
||||
if (file) {
|
||||
this.iframeSrc = await onlineEditorGetUrl(file)
|
||||
}
|
||||
this.visible = true
|
||||
this.index = index
|
||||
this.form.resetFields()
|
||||
@@ -144,24 +145,6 @@ export default {
|
||||
this.form.setFieldsValue(pick(this.model, 'clauseNum', 'clauseName', 'editAdvice'))
|
||||
})
|
||||
},
|
||||
getFileInfo (fileId) {
|
||||
return new Promise(resolve => {
|
||||
let fileInfo
|
||||
queryFileInfoByEditId({ id: fileId }).then(res => {
|
||||
if (res.success) {
|
||||
fileInfo = res.result
|
||||
}
|
||||
}).finally(() => {
|
||||
resolve(fileInfo)
|
||||
})
|
||||
})
|
||||
},
|
||||
handlePreview (file) {
|
||||
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))}`
|
||||
this.iframeSrc = url
|
||||
},
|
||||
close () {
|
||||
this.visible = false
|
||||
this.model = {}
|
||||
|
||||
Reference in New Issue
Block a user