From d3be4d813f6745f245d36a07ea705b4db169d273 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期三, 06 十二月 2023 17:21:28 +0800
Subject: [PATCH] 后端返回数据流格式,前端无法捕获到错误信息

---
 Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
index b164fb7..80377c8 100644
--- a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
+++ b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
@@ -578,19 +578,25 @@
       exportGroupCodeExcel({
         codeClassifyOid: this.codeClassifyOid,
       }).then(res => {
-        console.log(res)
-        if (res) {
-          func.downloadFileByBlobHandler(res);
-          this.$message.success('涓嬭浇鎴愬姛锛岃鏌ョ湅锛�');
-          this.isLoading = false;
-        }
-      }).catch(error => {
-        console.log(error)
-        if (error) {
-          this.$message.error('璇锋煡鐪嬩笅杞界殑閿欒鏂囦欢锛�');
-        }
-        this.isLoading = false;
-      })
+        let reader = new FileReader();
+        reader.readAsText(res.data)
+        reader.onload =  (result) =>{
+          try {
+            let resData = JSON.parse(result.target.result);  // 瑙f瀽瀵硅薄鎴愬姛
+            if (!resData.success) {
+              console.log("resData",resData)
+              this.$message.error(resData.msg);
+              this.isLoading = false;
+            }
+          } catch (err) {
+            // console.log("err",err)// 瑙f瀽鎴愬璞″け璐ワ紝璇存槑鏄甯哥殑鏂囦欢娴�
+            func.downloadFileByBlobHandler(res);
+            this.$message.success('涓嬭浇鎴愬姛锛岃鏌ョ湅锛�');
+            this.isLoading = false;
+          }
+        };
+
+      });
     },
     //鏍囧噯鐢宠
     codeApplyHandler() {

--
Gitblit v1.9.3