Browse Source

查询统计报表导出修改

zhangjie 1 year ago
parent
commit
c2e28296b4
1 changed files with 32 additions and 19 deletions
  1. 32 19
      src/views/exam/exam-plan-kw-hz.vue

+ 32 - 19
src/views/exam/exam-plan-kw-hz.vue

@@ -71,7 +71,11 @@
               <Button @click="doQuery" type="primary" icon="md-search"
                 >查询</Button
               >
-              <Button @click="exportData" type="primary" icon="md-document"
+              <Button
+                @click="exportData"
+                :loading="loading"
+                type="primary"
+                icon="md-document"
                 >导出统计报表</Button
               >
             </FormItem>
@@ -670,6 +674,7 @@ export default {
         cheat: [],
         repeat: [],
       },
+      loading: false,
     };
   },
   created() {
@@ -753,6 +758,8 @@ export default {
         });
         return false;
       }
+      if (this.loading) return;
+      this.loading = true;
       let url =
         baseUrl +
         "/system/kwhz/export?examCode=" +
@@ -764,24 +771,30 @@ export default {
         url: url, // 请求地址
         data: {}, // 参数
         responseType: "blob", // 表明返回服务器返回的数据类型
-      }).then((res) => {
-        // 处理返回的文件流
-        let content = res.data;
-        let blob = new Blob([content]);
-        let fileName = "考务数据汇总.xlsx";
-        if ("download" in document.createElement("a")) {
-          let elink = document.createElement("a");
-          elink.download = fileName;
-          elink.style.display = "none";
-          elink.href = URL.createObjectURL(blob);
-          document.body.appendChild(elink);
-          elink.click();
-          URL.revokeObjectURL(elink.href); // 释放URL 对象
-          document.body.removeChild(elink);
-        } else {
-          navigator.msSaveBlob(blob, fileName);
-        }
-      });
+        timeout: 30 * 60 * 1000,
+      })
+        .then((res) => {
+          this.loading = false;
+          // 处理返回的文件流
+          let content = res.data;
+          let blob = new Blob([content]);
+          let fileName = "考务数据汇总.xlsx";
+          if ("download" in document.createElement("a")) {
+            let elink = document.createElement("a");
+            elink.download = fileName;
+            elink.style.display = "none";
+            elink.href = URL.createObjectURL(blob);
+            document.body.appendChild(elink);
+            elink.click();
+            URL.revokeObjectURL(elink.href); // 释放URL 对象
+            document.body.removeChild(elink);
+          } else {
+            navigator.msSaveBlob(blob, fileName);
+          }
+        })
+        .catch(() => {
+          this.loading = false;
+        });
     },
     loadSituation() {
       this.list.situation.list = [];