报告查询一键下载

This commit is contained in:
hayu 2025-12-10 18:40:30 +08:00
parent 02ecad4289
commit f18a9b53c1
1 changed files with 7 additions and 3 deletions

View File

@ -1047,18 +1047,23 @@ export default {
return total; return total;
}, },
/** 流式下载方法 - 使用原始的request方式 */
/** 流式下载方法 - 使用原始的request方式 */ /** 流式下载方法 - 使用原始的request方式 */
async streamDownload(payload) { async streamDownload(payload) {
try { try {
this.progressText = '正在连接服务器...'; this.progressText = '正在连接服务器...';
// 使request
const response = await request({ const response = await request({
url: '/material/bm_report/downloadBulkStream', url: '/material/bm_report/downloadBulkStream',
method: 'POST', method: 'POST',
data: payload, data: payload,
responseType: 'blob', responseType: 'blob',
timeout: 0, timeout: 0,
headers: {
encryptRequest: false,
checkIntegrity: false,
encryptResponse: false
},
onDownloadProgress: (progressEvent) => { onDownloadProgress: (progressEvent) => {
this.handleDownloadProgress(progressEvent); this.handleDownloadProgress(progressEvent);
} }
@ -1074,11 +1079,9 @@ export default {
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
//
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
document.body.removeChild(a); document.body.removeChild(a);
//
this.handleDownloadComplete(); this.handleDownloadComplete();
} catch (error) { } catch (error) {
@ -1093,6 +1096,7 @@ export default {
} }
}, },
/** 处理下载进度 */ /** 处理下载进度 */
handleDownloadProgress(progressEvent) { handleDownloadProgress(progressEvent) {
if (progressEvent.total) { if (progressEvent.total) {