From aa3d3ad8fdb71c9cdbc05ae46270cbcddff0a6f1 Mon Sep 17 00:00:00 2001
From: wjt <1797368093@qq.com>
Date: 星期二, 18 六月 2024 16:56:10 +0800
Subject: [PATCH] t调整菜单

---
 src/utils/request.ts |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/src/utils/request.ts b/src/utils/request.ts
index fd457f9..932820b 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -165,7 +165,42 @@
       downloadLoadingInstance.close();
     });
 }
-
+// 閫氱敤涓嬭浇鏂规硶
+export function downloadGet(url: string, params: any, filename: string, config: any, isSaveFile = false) {
+  downloadLoadingInstance = ElLoading.service({ text: "姝e湪涓嬭浇鏁版嵁锛岃绋嶅��", background: "rgba(0, 0, 0, 0.7)" });
+  return service
+    .get(url, { params }, {
+      transformRequest: [
+        (params) => {
+          return tansParams(params);
+        },
+      ],
+      headers: { "Content-Type": "application/x-www-form-urlencoded" },
+      responseType: "blob",
+      ...config,
+    })
+    .then(async (data) => {
+      const isBlob = blobValidate(data);
+      if (isBlob && isSaveFile) {
+        const blob = new Blob([data]);
+        saveAs(blob, filename);
+      } else {
+        if(!isSaveFile) {
+        } else {
+          const resText = await data.text();
+          const rspObj = JSON.parse(resText);
+          const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode["default"];
+          ElMessage.error(errMsg);
+        }
+      }
+      downloadLoadingInstance.close();
+    })
+    .catch((r) => {
+      console.error(r);
+      ElMessage.error("涓嬭浇鏂囦欢鍑虹幇閿欒锛岃鑱旂郴绠$悊鍛橈紒");
+      downloadLoadingInstance.close();
+    });
+}
 const request = <T = any>(_config: AxiosRequestConfig<any>): Promise<T> => {
   return service(_config) as Promise<T>;
 };

--
Gitblit v1.9.1