Browse Source

预览下载优化

master
xuhuajiao 3 weeks ago
parent
commit
12f4bf20c3
  1. 6
      src/views/preview/index.vue

6
src/views/preview/index.vue

@ -42,7 +42,7 @@
<li>尺寸{{ (!(fileCurrent && fileCurrent.file_dpi) || (fileCurrent && fileCurrent.file_dpi === 'null')) ? '-' : fileCurrent.file_dpi }}</li> <li>尺寸{{ (!(fileCurrent && fileCurrent.file_dpi) || (fileCurrent && fileCurrent.file_dpi === 'null')) ? '-' : fileCurrent.file_dpi }}</li>
</ul> </ul>
<div class="preview-btn"> <div class="preview-btn">
<el-button class="iconfont icon-xiazai" @click="downloadFile(fileCurrent)">下载</el-button>
<el-button :loading="downloading" class="iconfont icon-xiazai" @click="downloadFile(fileCurrent)">下载</el-button>
<el-button v-print="printObj" class="iconfont icon-dayin">打印</el-button> <el-button v-print="printObj" class="iconfont icon-dayin">打印</el-button>
</div> </div>
</div> </div>
@ -78,6 +78,7 @@ export default {
}, },
data() { data() {
return { return {
downloading: false,
src: '', src: '',
logo: require('../../assets/images/logo.png'), logo: require('../../assets/images/logo.png'),
// //
@ -169,6 +170,7 @@ export default {
downloadFile(row) { downloadFile(row) {
// filePath // filePath
// bucketType 1 2 // bucketType 1 2
this.downloading = true
let bucketType = null let bucketType = null
if (this.documentId) { if (this.documentId) {
bucketType = 1 bucketType = 1
@ -184,8 +186,10 @@ export default {
} }
fetch(url, fetchOptions).then(res => res.blob()).then(blob => { fetch(url, fetchOptions).then(res => res.blob()).then(blob => {
downloadFile(blob, row.file_name.split('.')[0], row.file_type) downloadFile(blob, row.file_name.split('.')[0], row.file_type)
this.downloading = false
}).catch(() => { }).catch(() => {
this.$message({ message: '下载文件失败', type: 'error', offset: 8 }) this.$message({ message: '下载文件失败', type: 'error', offset: 8 })
this.downloading = false
}) })
}, },
selectFile(item) { selectFile(item) {

Loading…
Cancel
Save