fix 标准入库/变更、标准征求意见、法规采购流程保存
This commit is contained in:
@@ -13,11 +13,7 @@ function fillZero (str) {
|
||||
return realNum
|
||||
}
|
||||
|
||||
/**
|
||||
* kkFile预览文件并添加水印
|
||||
* @param fileUrl
|
||||
*/
|
||||
export const kkFilePreview = (fileUrl) => {
|
||||
export function dealUrl (fileUrl) {
|
||||
const userInfo = Vue.ls.get(USER_INFO)
|
||||
// 获取当前时间
|
||||
const date = new Date()
|
||||
@@ -32,6 +28,13 @@ export const kkFilePreview = (fileUrl) => {
|
||||
const watermarkTxt = `${userInfo.username} ${userInfo.realname} ${time}`
|
||||
// 客户环境预览需要加的加密参数
|
||||
const watermarkSign = md5(watermarkTxt + 'cnhtc')
|
||||
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileUrl))}&watermarkTxt=${encodeURIComponent(watermarkTxt)}&watermarkSign=${watermarkSign}`
|
||||
window.open(url)
|
||||
}
|
||||
return `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileUrl))}&watermarkTxt=${encodeURIComponent(watermarkTxt)}&watermarkSign=${watermarkSign}`
|
||||
}
|
||||
|
||||
/**
|
||||
* kkFile预览文件并添加水印
|
||||
* @param fileUrl
|
||||
*/
|
||||
export const kkFilePreview = (fileUrl) => {
|
||||
window.open(dealUrl(fileUrl))
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ import Vue from 'vue'
|
||||
import * as api from '@/api/api'
|
||||
import { isURL } from '@/utils/validate'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
import { getFileInfo } from '@/api/api'
|
||||
import { dealUrl, kkFilePreview } from './kkFilePreview'
|
||||
import { previewPdf } from './previewPdf'
|
||||
// import onlineCommons from '@/components/onlineForm/onlineForm'
|
||||
|
||||
//
|
||||
@@ -678,3 +681,37 @@ export function getConfusionCode (tableName, fieldName) {
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过文件id在当前窗口预览文件
|
||||
* @param fileId
|
||||
*/
|
||||
export function previewFileCurrentWindowByFileId (fileId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getFileInfo({ id: fileId }).then(res => {
|
||||
if (res.success) {
|
||||
const file = res.result || {}
|
||||
// 支持预览的文件后缀
|
||||
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
|
||||
const fileSuffix = file.fileName ? file.fileName.split('.')[file.fileName.split('.').length - 1] : ''
|
||||
const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix.toLowerCase() === tt)
|
||||
// 判断是否为可预览格式的文件
|
||||
if (!canPreview) {
|
||||
reject('该文件类型不支持预览')
|
||||
}
|
||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
||||
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
||||
const FILE_TYPE_PDF = 'pdf'
|
||||
// pdf预览
|
||||
if (canPreview && FILE_TYPE_PDF.includes(fileSuffix)) {
|
||||
const url = previewPdf(file.id)
|
||||
window.open(url, '_self')
|
||||
return
|
||||
}
|
||||
// 其余可预览文件仍使用KKFile进行预览
|
||||
const kkFileUrl = dealUrl(fileFullUrl)
|
||||
window.open(kkFileUrl, '_self')
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user