From c733b4fc98e348f4f60f71a291c3acfa6d7d4ce9 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 24 四月 2025 10:38:59 +0800
Subject: [PATCH] 网分仪调整

---
 src/plugins/download.js |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/plugins/download.js b/src/plugins/download.js
index 62b21b8..44698da 100644
--- a/src/plugins/download.js
+++ b/src/plugins/download.js
@@ -4,6 +4,7 @@
 import { getToken } from "@/utils/auth";
 import errorCode from "@/utils/errorCode";
 import { blobValidate } from "@/utils/ruoyi";
+import Vue from "vue";
 
 const baseURL = process.env.VUE_APP_BASE_API;
 let downloadLoadingInstance;
@@ -80,22 +81,28 @@
         downloadLoadingInstance.close();
       });
   },
-  saveAs(text, name, opts) {
-    if (typeof text === "string") {
-      // 璺緞涓嬭浇
-      saveAs(text, name, opts);
-      Message.success("鏁版嵁瀵煎嚭鎴愬姛");
-    } else {
-      // 娴佷笅杞�
-      blobToText(text)
-        .then((result) => {
-          Message.error(result.msg);
-        })
-        .catch(() => {
-          saveAs(text, name, opts);
-          Message.success("鏁版嵁瀵煎嚭鎴愬姛");
-        });
-    }
+  async saveAs(fileUrl, fileName) {
+      try {
+          const response = await 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);
+      }
   },
   async printErrMsg(data) {
     const resText = await data.text();
@@ -113,7 +120,7 @@
     fileReader.onload = function () {
       try {
         const result = JSON.parse(this.result);
-        if (result && result["code"] === 500) {
+        if (result && result["code"] !== 200) {
           resolve(result);
         } else {
           reject();

--
Gitblit v1.9.3