update 在线编辑
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import { getFileInfo } from '../api/api'
|
||||
import { generateEmptyFileTemplate } from '../api/workCenter'
|
||||
import { USER_INFO } from '../store/mutation-types'
|
||||
import Vue from 'vue'
|
||||
|
||||
/**
|
||||
* 获取文件信息
|
||||
* @param fileId
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
const queryFileInfo = (fileId) => {
|
||||
return new Promise(resolve => {
|
||||
let fileInfo
|
||||
getFileInfo({ id: fileId }).then(res => {
|
||||
if (res.success) {
|
||||
fileInfo = res.result
|
||||
}
|
||||
}).finally(() => {
|
||||
resolve(fileInfo)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成空白模板并获取模板路径
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
const getEmptyFileTemplate = (params) => {
|
||||
return new Promise(resolve => {
|
||||
let fileInfo
|
||||
generateEmptyFileTemplate(params).then(res => {
|
||||
if (res.success) {
|
||||
fileInfo = res.result
|
||||
}
|
||||
}).finally(() => {
|
||||
resolve(fileInfo)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转在线编辑
|
||||
* @param params Object {
|
||||
* standard_number: 标准编号,
|
||||
* substitute_standard_number: 代替标准号,
|
||||
* implementation_date: 实施日期,
|
||||
* release_date: 发布日期,
|
||||
* standard_name: 标准名称
|
||||
* }
|
||||
* @param fileId 文件id,有的话是编辑,没有是新增
|
||||
*/
|
||||
export const onlineEditor = async (params, fileId) => {
|
||||
let fileInfo = {
|
||||
'id': '1749318391395676161',
|
||||
'standId': null,
|
||||
'userId': null,
|
||||
'mesg': null,
|
||||
'taskInfo': null,
|
||||
'taskId': 'task_2442bc43',
|
||||
'fileName': 'Q/JC 40004-2023 ldq流程新建完整字段企标计划.docx',
|
||||
'createTime': '2024-01-22 14:29:39',
|
||||
'updateTime': null,
|
||||
'editStatus': null,
|
||||
'editFilePath': 'model/task_2442bc43/task_2442bc43_top_2442bc43_node.docx',
|
||||
'editType': null,
|
||||
'delFlag': '0',
|
||||
'downLoadUrl': null,
|
||||
'pid': 'top_2442bc43'
|
||||
}
|
||||
if (fileId) {
|
||||
fileInfo = await queryFileInfo(fileId)
|
||||
} else {
|
||||
const param = {
|
||||
model: `${params.standard_name}` // 处理文件名
|
||||
}
|
||||
fileInfo = await getEmptyFileTemplate(param)
|
||||
}
|
||||
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 filePathArr = fileInfo.editFilePath.split('/')
|
||||
// const filePath = filePathArr[0] + '/' + filePathArr[1] + '/'
|
||||
const url = `${window._CONFIG.onlyOfficeUrl}/editor?filePath=${fileInfo.editFilePath}&fileName=${fileInfo.fileName}&fileType=${fileSuffix}&fileId=${fileInfo.id}&key=${fileInfo.id}&userId=${userInfo.id}&userName=${userInfo.realname}`
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
Reference in New Issue
Block a user