Prechádzať zdrojové kódy

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

Michael Wang 4 rokov pred
rodič
commit
c758b14f71

+ 26 - 8
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);
@@ -464,16 +467,31 @@ export default {
 
       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();
+      }
       this.$Message.success({
         content: "上传成功",
         duration: 5,