| | |
| | | <img :src="fileUrl" alt="Image Preview" /> |
| | | </div> |
| | | <div v-if="isPdf"> |
| | | <object :data="fileUrl" type="application/pdf" width="100%" height="600px"> |
| | | <object :data="fileUrl" type="application/pdf" width="100%" height="750px"> |
| | | <p>您的浏览器不支持 PDF 预览。<a :href="fileUrl">下载 PDF 文件</a></p> |
| | | </object> |
| | | </div> |
| | | <div v-if="isDoc"> |
| | | <p v-if="!isDocShow">文档无法直接预览,请下载查看。</p> |
| | | <a :href="fileUrl" v-if="!isDocShow">下载文件</a> |
| | | <vue-office-docx |
| | | <vue-office-docx v-else |
| | | :src="fileUrl" |
| | | style="height: 100vh;" |
| | | @rendered="renderedHandler" |
| | |
| | | <div v-if="isXls"> |
| | | <p v-if="!isDocShow">文档无法直接预览,请下载查看。</p> |
| | | <a :href="fileUrl" v-if="!isDocShow">下载文件</a> |
| | | <vue-office-excel |
| | | <vue-office-excel v-else |
| | | :src="fileUrl" |
| | | :options="options" |
| | | style="height: 100vh;" |
| | |
| | | return /\.(doc|docx)$/i.test(this.fileUrl); |
| | | }, |
| | | isXls(){ |
| | | return /\.(xls|xlsx)$/i.test(this.fileUrl); |
| | | let state = /\.(xls|xlsx)$/i.test(this.fileUrl) |
| | | if(state){ |
| | | if(/\.(xlsx)$/i.test(this.fileUrl)){ |
| | | this.options.xls = false |
| | | }else{ |
| | | this.options.xls = true |
| | | } |
| | | } |
| | | return state; |
| | | }, |
| | | isZipOrRar() { |
| | | return /\.(zip|rar)$/i.test(this.fileUrl); |
| | |
| | | renderedHandler() { |
| | | console.log("渲染完成") |
| | | this.isDocShow = true |
| | | this.resetStyle() |
| | | }, |
| | | errorHandler() { |
| | | console.log("渲染失败") |
| | |
| | | column:[] |
| | | } |
| | | obj.tableData = this.formatCSVToTable(m.content.replaceAll('null',' ')) |
| | | // .replaceAll('MIN','=MIN').replaceAll('MAX','=MAX').replaceAll('AVERAGE','=AVERAGE') |
| | | for (let item in obj.tableData[0]) { |
| | | obj.column.push({ |
| | | label: item, |
| | |
| | | } |
| | | return result |
| | | }, |
| | | resetStyle(){ |
| | | const elements = document.querySelectorAll('[style*="pt"]'); |
| | | for (const element of elements) { |
| | | const style = element.getAttribute('style'); |
| | | if (!!style) { |
| | | element.setAttribute('style', style.replace(/pt/g, 'px')); |
| | | } |
| | | } |
| | | }, |
| | | } |
| | | } |
| | | </script> |