| | |
| | | </template> |
| | | |
| | | <script> |
| | | import dncApi from '@/api/dnc' |
| | | import dncApi from '@/api/dnc' |
| | | |
| | | export default { |
| | | name: 'FilePreview', |
| | | components: {}, |
| | | props: { |
| | | currentDocumentInfo: { |
| | | type: Object |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | spinning: false, |
| | | pdfUrl: '' |
| | | } |
| | | }, |
| | | methods: { |
| | | getFilePreviewByApi() { |
| | | const { docId, docSuffix } = this.currentDocumentInfo |
| | | console.log('currentDocumentInfo', this.currentDocumentInfo) |
| | | // if (docSuffix !== 'pdf') { |
| | | // document.getElementById('ncFileInfo').innerHTML = '' |
| | | // dncApi.getFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // console.log('res----------------------------', res) |
| | | // if (res.success && res.list) { |
| | | // let str = '' |
| | | // res.list.forEach((val, k) => { |
| | | // str += val |
| | | // if (k != res.list.length - 1) { |
| | | // str += '\n' |
| | | // } |
| | | // }) |
| | | // document.getElementById('ncFileInfo').innerHTML = str |
| | | // } else { |
| | | // this.$notification.error({ |
| | | // message: '消息', |
| | | // description: res.message |
| | | // }) |
| | | // } |
| | | // }) |
| | | // } else { |
| | | // dncApi.getPdfFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // let url = window.URL.createObjectURL(new Blob([res], { type: 'application/zip' })) |
| | | // this.pdfUrl = './static/pdf/web/viewer.html?file=' + encodeURIComponent(url) |
| | | // console.log('url===========================', url) |
| | | // console.log('pdfUrl===========================', this.pdfUrl) |
| | | // }) |
| | | // } |
| | | this.spinning = true |
| | | document.getElementById('ncFileInfo').innerHTML = '' |
| | | dncApi.getFilePreviewApi(docId) |
| | | .then(res => { |
| | | console.log('res----------------------------', res) |
| | | if (res.success && res.list) { |
| | | let str = '' |
| | | res.list.forEach((val, k) => { |
| | | str += val |
| | | if (k != res.list.length - 1) { |
| | | str += '\n' |
| | | } |
| | | }) |
| | | document.getElementById('ncFileInfo').innerHTML = str |
| | | } else { |
| | | this.$notification.error({ |
| | | message: '消息', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | this.spinning = false |
| | | }) |
| | | }, |
| | | export default { |
| | | name: 'FilePreview', |
| | | components: {}, |
| | | props: { |
| | | currentDocumentInfo: { |
| | | type: Object |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | spinning: false, |
| | | pdfUrl: '' |
| | | } |
| | | }, |
| | | methods: { |
| | | getFilePreviewByApi() { |
| | | const { docId, docSuffix } = this.currentDocumentInfo |
| | | console.log('currentDocumentInfo', this.currentDocumentInfo) |
| | | // if (docSuffix !== 'pdf') { |
| | | // document.getElementById('ncFileInfo').innerHTML = '' |
| | | // dncApi.getFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // console.log('res----------------------------', res) |
| | | // if (res.success && res.list) { |
| | | // let str = '' |
| | | // res.list.forEach((val, k) => { |
| | | // str += val |
| | | // if (k != res.list.length - 1) { |
| | | // str += '\n' |
| | | // } |
| | | // }) |
| | | // document.getElementById('ncFileInfo').innerHTML = str |
| | | // } else { |
| | | // this.$notification.error({ |
| | | // message: '消息', |
| | | // description: res.message |
| | | // }) |
| | | // } |
| | | // }) |
| | | // } else { |
| | | // dncApi.getPdfFilePreviewApi(docId) |
| | | // .then(res => { |
| | | // let url = window.URL.createObjectURL(new Blob([res], { type: 'application/zip' })) |
| | | // this.pdfUrl = './static/pdf/web/viewer.html?file=' + encodeURIComponent(url) |
| | | // console.log('url===========================', url) |
| | | // console.log('pdfUrl===========================', this.pdfUrl) |
| | | // }) |
| | | // } |
| | | document.getElementById('ncFileInfo').innerHTML = '' |
| | | if (docSuffix == 'jpg' || docSuffix == 'png' || docSuffix == 'jpeg' || docSuffix === 'gif' || docSuffix == 'pdf') return |
| | | this.spinning = true |
| | | dncApi.getFilePreviewApi(docId) |
| | | .then(res => { |
| | | console.log('res----------------------------', res) |
| | | if (res.success && res.list) { |
| | | let str = '' |
| | | res.list.forEach((val, k) => { |
| | | str += val |
| | | if (k != res.list.length - 1) { |
| | | str += '\n' |
| | | } |
| | | }) |
| | | document.getElementById('ncFileInfo').innerHTML = str |
| | | } else { |
| | | this.$notification.error({ |
| | | message: '消息', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | this.spinning = false |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | /deep/ .ant-spin-container { |
| | | height: 100%; |
| | | } |
| | | /deep/ .ant-spin-container { |
| | | height: 100%; |
| | | } |
| | | </style> |