fix: 统一预览方式
This commit is contained in:
+79
-28
@@ -1,35 +1,86 @@
|
|||||||
/**
|
/**
|
||||||
* 文件预览
|
* 文件预览
|
||||||
*/
|
*/
|
||||||
import { onlyOfficeUrl,kkFileViewUrl } from '@/sysConfig'
|
import { onlyOfficeUrl, kkFileViewUrl } from '@/sysConfig'
|
||||||
import { getBusStandFileByAttId } from 'api/process'
|
import { getBusStandFileByAttId } from 'api/process'
|
||||||
let Base64 = require('js-base64').Base64;
|
const Base64 = require('js-base64').Base64;
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { Loading } from "element-ui";
|
import { Loading } from 'element-ui';
|
||||||
|
import axios from '@/common/axiosV2'
|
||||||
|
|
||||||
export default attId => {
|
// 获取转换为pdf的文件
|
||||||
const loading = Loading.service({
|
function queryConvertAtt (data) {
|
||||||
lock: true,
|
return axios({
|
||||||
text: '正在加载文件',
|
url: 'api/lawss/sarLawsFile/queryConvertAtt',
|
||||||
spinner: 'el-icon-loading',
|
method: 'get',
|
||||||
})
|
params: data
|
||||||
getBusStandFileByAttId({
|
})
|
||||||
attId
|
|
||||||
}).then(res => {
|
|
||||||
if(res){
|
|
||||||
const editFileInfo = res.data
|
|
||||||
if(editFileInfo.fileSuffix.toLowerCase() === 'pdg'){
|
|
||||||
window.open('book://ssreader/e0?url='+editFileInfo.downLoadUrl)
|
|
||||||
}else if(editFileInfo.fileSuffix.toLowerCase() === 'pdf'){
|
|
||||||
window.open('./static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + editFileInfo.id))
|
|
||||||
}else {
|
|
||||||
const nowTime = new Date().getTime()
|
|
||||||
// window.open(onlyOfficeUrl+'/onlyOffice?oldFileName=' + editFileInfo.oldFileName + '&fileType=' + editFileInfo.fileSuffix + '&attId=' + editFileInfo.id + '&fileUrl=' + editFileInfo.downLoadUrl + '&key=' + editFileInfo.id + nowTime+'&filePath='+editFileInfo.filePath+'&fileName='+editFileInfo.fileName)
|
|
||||||
window.open(kkFileViewUrl+'/onlinePreview?url='+encodeURIComponent(Base64.encode(editFileInfo.downLoadUrl)) + '&watermarkTxt=' + encodeURIComponent(store.getters.userInfo.userName));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).finally(() => {
|
|
||||||
loading.close()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function preview (attId) {
|
||||||
|
const loading = Loading.service({
|
||||||
|
lock: true,
|
||||||
|
text: '正在加载文件',
|
||||||
|
spinner: 'el-icon-loading',
|
||||||
|
})
|
||||||
|
const res = await getBusStandFileByAttId({ attId })
|
||||||
|
if (res.ok && res.data) {
|
||||||
|
const file = res.data
|
||||||
|
if (file.fileSuffix.toLowerCase() === 'pdg') {
|
||||||
|
window.open('book://ssreader/e0?url=' + file.downLoadUrl)
|
||||||
|
} else if (file.fileSuffix.toLowerCase() === 'pdf') {
|
||||||
|
window.open('./static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + file.id))
|
||||||
|
} else {
|
||||||
|
// onlyoffice在线编辑文件转换为pdf预览 -> kkfileview预览乱码
|
||||||
|
if (file.onlined && file.onlined === 1) {
|
||||||
|
const res = await queryConvertAtt({ attId })
|
||||||
|
if (res.ok && res.data) {
|
||||||
|
window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + res.data.attId))
|
||||||
|
} else {
|
||||||
|
this.$message.error('文档未转换成功或本地读取不到该文档')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.open(kkFileViewUrl + '/onlinePreview?url=' + encodeURIComponent(Base64.encode(file.downLoadUrl)) + '&watermarkTxt=' + encodeURIComponent(store.getters.userInfo.userName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loading.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
export default preview;
|
||||||
|
// export default (attId) => {
|
||||||
|
// const loading = Loading.service({
|
||||||
|
// lock: true,
|
||||||
|
// text: '正在加载文件',
|
||||||
|
// spinner: 'el-icon-loading',
|
||||||
|
// })
|
||||||
|
// getBusStandFileByAttId({
|
||||||
|
// attId
|
||||||
|
// }).then(res => {
|
||||||
|
// if(res) {
|
||||||
|
// const editFileInfo = res.data
|
||||||
|
// if(editFileInfo.fileSuffix.toLowerCase() === 'pdg') {
|
||||||
|
// window.open('book://ssreader/e0?url=' + editFileInfo.downLoadUrl)
|
||||||
|
// }else if(editFileInfo.fileSuffix.toLowerCase() === 'pdf') {
|
||||||
|
// window.open('./static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + editFileInfo.id))
|
||||||
|
// }else {
|
||||||
|
// // const nowTime = new Date().getTime()
|
||||||
|
// // window.open(onlyOfficeUrl+'/onlyOffice?oldFileName=' + editFileInfo.oldFileName + '&fileType=' + editFileInfo.fileSuffix + '&attId=' + editFileInfo.id + '&fileUrl=' + editFileInfo.downLoadUrl + '&key=' + editFileInfo.id + nowTime+'&filePath='+editFileInfo.filePath+'&fileName='+editFileInfo.fileName)
|
||||||
|
// if (res.data && res.data.onlined === 1) {
|
||||||
|
// queryConvertAtt({ attId }).then(res => {
|
||||||
|
// if (res.ok && res.data) {
|
||||||
|
// window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + res.data.attId))
|
||||||
|
// } else {
|
||||||
|
// this.$message.error('文档未转换成功或本地读取不到该文档')
|
||||||
|
// }
|
||||||
|
// }).catch(() => {
|
||||||
|
// this.$message.error('文档未转换成功或本地读取不到该文档')
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// window.open(kkFileViewUrl + '/onlinePreview?url=' + encodeURIComponent(Base64.encode(editFileInfo.downLoadUrl)) + '&watermarkTxt=' + encodeURIComponent(store.getters.userInfo.userName));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }).finally(() => {
|
||||||
|
// loading.close()
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user