Browse Source

离线上传按钮禁止重复点击

Michael Wang 4 years ago
parent
commit
7042825a5c
1 changed files with 28 additions and 9 deletions
  1. 28 9
      src/features/OfflineExam/OfflineExamUpload.vue

+ 28 - 9
src/features/OfflineExam/OfflineExamUpload.vue

@@ -68,6 +68,7 @@
         class="qm-primary-button"
         style="width: 40%; margin-right: 20px"
         :disabled="uploadFileList.length === 0"
+        :loading="uploading"
         @click="uploadFiles"
       >
         确认上传
@@ -120,6 +121,7 @@ export default {
       fileType: null,
       loadingStatus: false,
       uploadFileList: [],
+      uploading: false,
       // uploadFileFormat: [],
       // uploadFileAccept: "",
     };
@@ -429,6 +431,7 @@ export default {
           return false;
         }
       }
+      this.uploading = true;
 
       let params = new FormData();
       params.append("examRecordDataId", this.course.examRecordDataId);
@@ -462,18 +465,34 @@ export default {
       // }
       // params.append("fileMd5Array", summaries);
 
-      this.$Message.info({
+      const upMsg = this.$Message.info({
         content: "上传中...",
-        duration: 5,
+        duration: 30,
         closable: true,
       });
-      await this.$http.post(
-        "/api/branch_ecs_oe_admin/offlineExam/batchSubmitPaper",
-        params,
-        { headers: { "Content-Type": "multipart/form-data" } }
-      );
-      // console.log(res);
-      this.$Message.destroy();
+      try {
+        await this.$http.post(
+          "/api/branch_ecs_oe_admin/offlineExam/batchSubmitPaper",
+          params,
+          { headers: { "Content-Type": "multipart/form-data" } }
+        );
+      } catch (error) {
+        this.logger({
+          action: "离线考试附件没有正常上传",
+          detail: error,
+          errorJSON: JSON.stringify(error, (key, value) =>
+            key === "token" ? "" : value
+          ),
+          errorName: error.name,
+          errorMessage: error.message,
+          errorStack: error.stack,
+        });
+        throw error;
+      } finally {
+        this.uploading = false;
+        // this.$Message.destroy();
+        upMsg();
+      }
       this.$Message.success({
         content: "上传成功",
         duration: 5,