前端代码
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import { generateEmptyFileTemplate, queryFileInfoByEditId } 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
|
||||
queryFileInfoByEditId({ 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
|
||||
if (fileId) {
|
||||
fileInfo = await queryFileInfo(fileId)
|
||||
} else {
|
||||
const param = {
|
||||
model: `${params.standard_number} ${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()
|
||||
// Q/ZZ 部分截取
|
||||
const standardNumberPrefix = params.standard_number ? params.standard_number.split(' ')[0] : null
|
||||
const businessParams = {
|
||||
standCode: params.standard_number,
|
||||
dtqbbhbuss: params.substitute_standard_number,
|
||||
standName: params.standard_name,
|
||||
standEnName: params.standard_english_name,
|
||||
issueTime: params.release_date,
|
||||
putTime: params.implementation_date,
|
||||
standardNumberPrefix: standardNumberPrefix
|
||||
}
|
||||
const url = `${window._CONFIG.onlyOfficeUrl}/editorPage?filePath=${fileInfo.editFilePath}&fileName=${fileInfo.fileName}&fileType=${fileSuffix}&fileId=${fileInfo.id}&key=${fileInfo.id}&userId=${userInfo.id}&userName=${userInfo.realname}&business=${JSON.stringify(businessParams)}`
|
||||
window.open(url, '_blank')
|
||||
return fileInfo.id
|
||||
}
|
||||
Reference in New Issue
Block a user