<template>
|
<a-spin :spinning="spinning" style="height: 100%">
|
<!--<template v-if="currentDocumentInfo.docSuffix==='pdf'">-->
|
<!--<iframe :src="pdfUrl" frameborder="0"-->
|
<!--style="width: 100%;height: calc(100% - 5px)"></iframe>-->
|
<!--</template>-->
|
|
<template>
|
<textarea id="ncFileInfo" style="resize:none;width:100%;height: 100%"></textarea>
|
</template>
|
</a-spin>
|
</template>
|
|
<script>
|
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
|
})
|
},
|
}
|
}
|
</script>
|
|
<style scoped>
|
/deep/ .ant-spin-container {
|
height: 100%;
|
}
|
</style>
|