预览word

This commit is contained in:
qq787203167
2022-03-22 21:51:15 +08:00
parent db2994dbf2
commit 22a8f4826f
5 changed files with 25 additions and 13 deletions
+3 -2
View File
@@ -27,6 +27,7 @@
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getAction, postAction, downFile, downloadFile } from '@/api/manage'
import { Base64 } from 'js-base64'
export default {
name: 'file',
@@ -182,10 +183,10 @@
if (fileSuffix === '.pdf') {
window.open('/pdf/web/viewer.html?file=' + encodeURIComponent('/jero-boot/sys/common/pdf/viewFile?id=' + fileQuery.id))
} else if (fileSuffix === '.docx') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(this.downLoadFileUrl + '?id=' + fileQuery.id)
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else if (fileSuffix === '.xlsx' || fileSuffix === '.xls') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(this.downLoadFileUrl + '?id=' + fileQuery.id)
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else {
downloadFile('/sys/common/download', fileQuery.fileName, { id: fileQuery.id })
@@ -169,6 +169,7 @@
</template>
<script>
import { getAction, postAction, downFile, downloadFile } from '@/api/manage'
import { Base64 } from 'js-base64';
export default {
name: 'docIndex',
@@ -240,13 +241,15 @@
let index1 = fileName.lastIndexOf('.')
let index2 = fileName.length
let fileSuffix = fileName.substring(index1, index2)
debugger
if (fileSuffix == '.pdf') {
window.open('/pdf/web/viewer.html?file=' + encodeURIComponent('/jero-boot/sys/common/pdf/viewFile?id=' + fileQuery.id))
} else if (fileSuffix == '.docx') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(this.downLoadFileUrl + '?id=' + fileQuery.id)
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else if (fileSuffix == '.xlsx' || fileSuffix == '.xls') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(this.downLoadFileUrl + '?id=' + fileQuery.id)
console.log(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else {
downloadFile('/sys/common/download', fileQuery.fileName, { id: fileQuery.id })
@@ -168,6 +168,7 @@
import { getAction, postAction, downloadFile } from '@/api/manage'
import libraryPush from '@/components/libraryPush/index'
import moment from 'moment'
import { Base64 } from 'js-base64'
export default {
name: 'DocumentLibrary',
@@ -288,7 +289,7 @@
loading: false,
selectModel: '',
fileList: [],
downLoadFileUrl: window._CONFIG['domianURL'] + '/sys/common/download',
downLoadFileUrl: window._CONFIG['domianURL'] + '/sys/common/download'
}
},
watch: {
@@ -469,10 +470,10 @@
if (fileSuffix == '.pdf') {
window.open('/pdf/web/viewer.html?file=' + encodeURIComponent('/jero-boot/sys/common/pdf/viewFile?id=' + fileQuery.id))
} else if (fileSuffix == '.docx') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(this.downLoadFileUrl + '?id=' + fileQuery.id)
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else if (fileSuffix == '.xlsx' || fileSuffix == '.xls') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(this.downLoadFileUrl + '?id=' + fileQuery.id)
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else {
downloadFile('/sys/common/download', fileQuery.fileName, { id: fileQuery.id })