diff --git a/src/components/UploadFile.vue b/src/components/UploadFile.vue index 17c87c36..f317ffda 100644 --- a/src/components/UploadFile.vue +++ b/src/components/UploadFile.vue @@ -205,6 +205,7 @@ export default { name: fileInfo.fileName, status: 'done', url: fileInfo.url, + pdfId: fileInfo.pdfId, // response用于下载和预览 response: { success: true, @@ -299,6 +300,13 @@ export default { if (!file || !file.url) { return } + console.log(file) + if (file.pdfId) { + // 说明是onlyOffice生成的 + const url = previewPdf(file.pdfId) + window.open(url) + return + } // 截取文件后缀名 const fileSuffix = (file.name ? file.name.split('.')[file.name.split('.').length - 1] : '').toLowerCase() const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix === tt) diff --git a/src/views/dashboard/search/AdvancedSearch.vue b/src/views/dashboard/search/AdvancedSearch.vue index 980308d9..3fa85ef8 100644 --- a/src/views/dashboard/search/AdvancedSearch.vue +++ b/src/views/dashboard/search/AdvancedSearch.vue @@ -394,6 +394,14 @@ export default { } console.log('seletedFile', file) + // 是onlyOffice生成的,预览关联的pdf文件 + if (file.pdfId) { + // 说明是onlyOffice生成的 + const url = previewPdf(file.pdfId) + window.open(url) + return + } + // 预览选择的文件 const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` console.log(fileFullUrl) @@ -410,7 +418,10 @@ export default { */ async selectNewestFile (fileList) { if (!fileList || fileList.length === 0) return null - if (fileList.length === 1) return fileList[0] + if (fileList.length === 1) { + const res = await getFileInfo(fileList[0]) + return { ...fileList[0], ...res.result } + } const newFileList = [] // 获取时间信息 for (const file of fileList) { diff --git a/src/views/dashboard/search/GeneralSearch.vue b/src/views/dashboard/search/GeneralSearch.vue index 6b2a34ec..b26b91c6 100644 --- a/src/views/dashboard/search/GeneralSearch.vue +++ b/src/views/dashboard/search/GeneralSearch.vue @@ -618,6 +618,14 @@ export default { } console.log('seletedFile', file) + // 是onlyOffice生成的,预览关联的pdf文件 + if (file.pdfId) { + // 说明是onlyOffice生成的 + const url = previewPdf(file.pdfId) + window.open(url) + return + } + // 预览选择的文件 const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` console.log(fileFullUrl) @@ -634,7 +642,10 @@ export default { */ async selectNewestFile (fileList) { if (!fileList || fileList.length === 0) return null - if (fileList.length === 1) return fileList[0] + if (fileList.length === 1) { + const res = await getFileInfo(fileList[0]) + return { ...fileList[0], ...res.result } + } const newFileList = [] // 获取时间信息 for (const file of fileList) { diff --git a/src/views/enterpriseStandardLibrary/standard/EnterpriseStandardList.vue b/src/views/enterpriseStandardLibrary/standard/EnterpriseStandardList.vue index 330de42c..a34a5d02 100644 --- a/src/views/enterpriseStandardLibrary/standard/EnterpriseStandardList.vue +++ b/src/views/enterpriseStandardLibrary/standard/EnterpriseStandardList.vue @@ -828,6 +828,14 @@ export default { } console.log('seletedFile', file) + // 是onlyOffice生成的,预览关联的pdf文件 + if (file.pdfId) { + // 说明是onlyOffice生成的 + const url = previewPdf(file.pdfId) + window.open(url) + return + } + // 预览选择的文件 const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` console.log(fileFullUrl) @@ -844,7 +852,10 @@ export default { */ async selectNewestFile (fileList) { if (!fileList || fileList.length === 0) return null - if (fileList.length === 1) return fileList[0] + if (fileList.length === 1) { + const res = await getFileInfo(fileList[0]) + return { ...fileList[0], ...res.result } + } const newFileList = [] // 获取时间信息 for (const file of fileList) { diff --git a/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue b/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue index b4009aa3..fd403106 100644 --- a/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue +++ b/src/views/enterpriseStandardLibrary/standard/detail/EnterpriseStandardDetail.vue @@ -287,6 +287,12 @@ export default { if (!file || !file.url) { return } + if (file.pdfId) { + // 说明是onlyOffice生成的 + const url = previewPdf(file.pdfId) + window.open(url) + return + } // 截取文件后缀名 const fileSuffix = file.fileName ? file.fileName.split('.')[file.fileName.split('.').length - 1] : '' const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix.toLowerCase() === tt)