diff --git a/src/common/index.js b/src/common/index.js index b0254e402..9e702c2e8 100644 --- a/src/common/index.js +++ b/src/common/index.js @@ -5,6 +5,8 @@ import base64 from './base64' import dateFormat from './date' import hasPermission from './hasPermission' +import preview from './preview' + // 表单验证 import verify from './verify' const install = function (Vue) { @@ -31,6 +33,11 @@ const install = function (Vue) { get () { return hasPermission } + }, + $preview: { + get () { + return preview + } } }) } diff --git a/src/common/preview/index.js b/src/common/preview/index.js new file mode 100644 index 000000000..0edbbe501 --- /dev/null +++ b/src/common/preview/index.js @@ -0,0 +1,23 @@ +/** + * 文件预览 + */ +import { onlyOfficeUrl } from '@/sysConfig' +import { getBusStandFileByAttId } from 'api/process' +export default attId => { + 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) + } + } + }).catch(e => { + }) +} diff --git a/src/components/CustomFormComponents/File.vue b/src/components/CustomFormComponents/File.vue index dba1a65e4..fb95df303 100644 --- a/src/components/CustomFormComponents/File.vue +++ b/src/components/CustomFormComponents/File.vue @@ -353,39 +353,26 @@ export default { this.$message.warning('文件不存在,下载失败') } } else { - this.getBusStandFileByAttId(attId) - .then(res => { - console.log(res) - if(res){ - const editFileInfo = res - console.log(editFileInfo) - if(editFileInfo.fileSuffix === 'pdg' || editFileInfo.fileSuffix === 'PDG'){ - window.open('book://ssreader/e0?url='+editFileInfo.downLoadUrl) - }else if(editFileInfo.fileSuffix === 'pdf' || editFileInfo.fileSuffix === '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('http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(editFileInfo.downLoadUrl))); - 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('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + editFileInfo.id)) - } - // switch (res.convertState) { - // case 'ERROR': - // this.$message.warning('文档转换失败') - // break - // case 'LODING': - // this.$message.info('文档转换中,请稍后查看') - // break - // case 'SUCCESS': - // const { convertFileInfo } = res - // window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + convertFileInfo.id)) - // break - // } - }).catch(e => { - console.log(e) - this.$message.warning('文件不存在,预览失败') - }) + this.$preview(attId) + // this.getBusStandFileByAttId(attId) + // .then(res => { + // console.log(res) + // if(res){ + // const editFileInfo = res + // console.log(editFileInfo) + // if(editFileInfo.fileSuffix === 'pdg' || editFileInfo.fileSuffix === 'PDG'){ + // window.open('book://ssreader/e0?url='+editFileInfo.downLoadUrl) + // }else if(editFileInfo.fileSuffix === 'pdf' || editFileInfo.fileSuffix === '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) + // } + // } + // }).catch(e => { + // console.log(e) + // this.$message.warning('文件不存在,预览失败') + // }) } }, diff --git a/src/pages/details/otherStandardDetails/index.vue b/src/pages/details/otherStandardDetails/index.vue index 3706a9596..7a2fd5c71 100644 --- a/src/pages/details/otherStandardDetails/index.vue +++ b/src/pages/details/otherStandardDetails/index.vue @@ -2789,7 +2789,6 @@ export default { this.downloadFile(attId) return true } - // 缺少文件 if (this.$route.params.pageType === 'INLAND_STAND') { if (this.$hasPermission('2d6ab9d465ab73d415194e1ca4313793')) { @@ -2803,23 +2802,9 @@ export default { window.open('book://ssreader/e0?url='+editFileInfo.downLoadUrl) }else { const nowTime = new Date().getTime() - // window.open('http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(editFileInfo.downLoadUrl))); - // 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(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('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + editFileInfo.id)) } - // switch (res.convertState) { - // case 'ERROR': - // this.$message.warning('文档转换失败') - // break - // case 'LODING': - // this.$message.info('文档转换中,请稍后查看') - // break - // case 'SUCCESS': - // const { convertFileInfo } = res - // window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + convertFileInfo.id)) - // break - // } }).catch(e => { console.log(e) this.$message.warning('文件不存在,预览失败') diff --git a/src/pages/localTool/standCalendar/index.vue b/src/pages/localTool/standCalendar/index.vue index 06d16e9c9..60be276ca 100644 --- a/src/pages/localTool/standCalendar/index.vue +++ b/src/pages/localTool/standCalendar/index.vue @@ -216,6 +216,7 @@ name="file" :file-list="reData" accept=".ZIP, .zip, .docx, .DOCX, .xls, .xlsx, .pdf, .PDF" + :http-request="httpRequest" :before-upload="handleBeforeUpload" :before-remove="handleBeforeRemove" :on-success="handleOnsuccess" @@ -233,6 +234,8 @@ + +