From c3f8bae626cb555db6d55077eaa59d10fd6e07ee Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期四, 14 十一月 2024 12:09:56 +0800
Subject: [PATCH] Merge branch 'master' of http://42.193.1.25:9521/r/~qirong/qyspzw-ui

---
 src/plugins/download.ts |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/src/plugins/download.ts b/src/plugins/download.ts
index ef66b3a..2cdfa50 100644
--- a/src/plugins/download.ts
+++ b/src/plugins/download.ts
@@ -61,5 +61,29 @@
     const rspObj = JSON.parse(resText);
     const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'];
     ElMessage.error(errMsg);
-  }
+  },
+  async ossDown(ossId: string | number,pawd:string) {
+    const url = baseURL + '/resource/oss/download/' + ossId +'/' + pawd;
+    downloadLoadingInstance = ElLoading.service({ text: '姝e湪涓嬭浇鏁版嵁锛岃绋嶅��', background: 'rgba(0, 0, 0, 0.7)' });
+    try {
+      const res = await axios({
+        method: 'get',
+        url: url,
+        responseType: 'blob',
+        headers: globalHeaders()
+      });
+      const isBlob = blobValidate(res.data);
+      if (isBlob) {
+        const blob = new Blob([res.data], { type: 'application/octet-stream' });
+        FileSaver.saveAs(blob, decodeURIComponent(res.headers['download-filename'] as string));
+      } else {
+        this.printErrMsg(res.data);
+      }
+      downloadLoadingInstance.close();
+    } catch (r) {
+      console.error(r);
+      ElMessage.error('涓嬭浇鏂囦欢鍑虹幇閿欒锛岃鑱旂郴绠$悊鍛橈紒');
+      downloadLoadingInstance.close();
+    }
+  },
 };

--
Gitblit v1.8.0