From 30b96c334bf080ece9bdeac1a1b65f0e62bf9f87 Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期一, 24 三月 2025 09:49:58 +0800 Subject: [PATCH] 下载,预览 --- src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue b/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue index 0f43503..41174ef 100644 --- a/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue +++ b/src/views/CNAS/process/method/standardMethodsChange/component/calibrationsFileDia.vue @@ -103,16 +103,28 @@ }, // 涓嬭浇 upload (row) { - let url = ''; - if(row.type==1){ - url = this.javaApi+'/img/'+row.fileUrl - file.downloadIamge(url,row.fileName) - }else{ - url = this.javaApi+'/word/'+row.fileUrl - const link = document.createElement('a'); - link.href = url; - link.download = row.fileName; - link.click(); + const fileName = row.fileName; + const fileUrl = row.fileUrl; + try { + const response = axios({ + method: 'get', + url: `${Vue.prototype.javaApi}/common/downloadMinio`, + params: { + fileUrl, + fileName + }, + responseType: 'blob', + headers: { Authorization: 'Bearer ' + getToken() } + }); + + if (blobValidate(response.data)) { + saveAs(new Blob([response.data]), fileName); + Message.success("涓嬭浇鎴愬姛"); + } else { + this.printErrMsg(response.data); + } + } catch (error) { + Message.error("涓嬭浇澶辫触锛�" + error.message); } }, } -- Gitblit v1.9.3