资料下载--批量下载

This commit is contained in:
zhaoxiao
2021-10-08 16:43:49 +08:00
parent 521c2a58a8
commit 1cc0878821
2 changed files with 32 additions and 19 deletions
+13 -8
View File
@@ -112,7 +112,8 @@ export default {
}
],
url: {
list: '/project/payWorkingGroupDistributionRecord/listForFile'
list: '/project/payWorkingGroupDistributionRecord/listForFile',
exportXlsUrl: '/project/payWorkingGroupDistributionRecord/zipFile'
}
}
},
@@ -133,15 +134,19 @@ export default {
this.$message.warn('请至少选择一个文件')
return
}
// 获取文件名称
let fileName = ''
if (!fileName || typeof fileName != 'string') {
fileName = '导出文件'
}
// 获取文件名称
let firstFile = this.dataSource.filter(tt => tt.fileId === this.selectedRowKeys[0])
fileName = `${firstFile[0].fileName}等${this.selectedRowKeys.length}个文件.zip`
let fileIdStr = this.selectedRowKeys.join(',')
batchDownloadFile({ ids: fileIdStr }).then(res => {
// 调用a标签下载文件的方法
downloadFileByA(res, fileName)
})
fileName = `${firstFile[0].fileName}等${this.selectedRowKeys.length}个文件`
let param = this.getQueryParams()
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
param['ids'] = this.selectedRowKeys.join(',')
}
console.log('导出参数', param)
downloadFile(this.url.exportXlsUrl, fileName + '.zip', param)
}
}
}
@@ -17,18 +17,23 @@
</a-col>
</a-row>
</a-col>
<a-col>
<a-row>
<a-col :span="3">项目资料:</a-col>
<a-col :span="18">
<a-spin :spinning="fileLoading">
<a-col>
<a-row>
<a-col :span="3">项目资料:</a-col>
<a-col :span="18">
<span v-for="(item, index) in fileList" :key="index">
<div class="file-name" @click="handlePreview(item)">{{ item.name }}</div>
</span>
</a-col>
</a-row>
</a-col>
</a-col>
</a-row>
</a-col>
</a-spin>
</a-row>
</a-spin>
<template slot="footer">
<a-button key="back" @click="handleCancel">关闭</a-button>
</template>
</j-modal>
</template>
@@ -48,6 +53,7 @@ export default {
width: 800,
visible: false,
loading: false,
fileLoading: false, // 文件区域的加载效果
fileList: [],
committeeId: '',
committeeDetail: {}
@@ -90,6 +96,7 @@ export default {
* 获取文件信息
* */
async initFileList(fileIdsArr) {
this.fileLoading = true
if (fileIdsArr.length > 0) {
let fileList = []
for (let i = 0; i < fileIdsArr.length; i++) {
@@ -101,20 +108,21 @@ export default {
} else {
this.fileList = []
}
this.fileLoading = false
},
handleCancel() {
this.committeeDetail = {}
this.fileList = []
this.visible = false
},
handlePreview(file) {
console.log(file)
if (file && file.id) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
const fileFullUrl = `${ window._CONFIG['domianWebSocketURL'] }/sys/common/download/${ file.id }?token=${ Vue.ls.get(ACCESS_TOKEN) }&fullfilename=${ file.name }`
let url = `${ window._CONFIG['onlinePreviewDomainURL'] }?url=${ encodeURIComponent(Base64.encode(fileFullUrl)) }`
// let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url)
}
},
}
}
}
</script>