Procházet zdrojové kódy

Merge branch 'hotfix/zhouweilu' of SEEC-II-FrontEnd-Team/SEEC-II-FrontEnd into master

ZhouWeilu před 7 roky
rodič
revize
8de5dcb026

+ 30 - 22
src/components/AssignmentCRUD/CreateAssignment/index.vue

@@ -232,7 +232,6 @@ export default {
       errorMassage: null,
       isServerError: false,
       submitting: false,
-
       // 转圈圈
       loadingSearchQuestions: false,
       loadingCreateAssignment: false
@@ -318,30 +317,39 @@ export default {
           // 代码作业
           this.myPromise = postCodeAssignment(param, this.courseId);
         }
-        this.myPromise.then(res => {
-          //创建成功
-          this.isCreateModalActive = false;
-          if (res.code === 0) {
-            if (this.assignType === 1) {
-              this.$router.push({
-                path: `${this.prefix}/review?documentHwId=${res.data.id}`
+        this.myPromise
+          .then(res => {
+            //创建成功
+            this.isCreateModalActive = false;
+            this.submitting = false;
+            if (res.code === 0) {
+              if (this.assignType === 1) {
+                this.$router.push({
+                  path: `${this.prefix}/review?documentHwId=${res.data.id}`
+                });
+              }
+              this.$emit("sendCreatedAssignment", res.data);
+              this.loadingCreateAssignment = false;
+            } else {
+              //创建失败
+              this.isCreateModalActive = false;
+              this.loadingCreateAssignment = false;
+
+              this.$dialog.alert({
+                title: "创建失败",
+                message: res.message,
+                type: "is-danger",
+                hasIcon: true
               });
             }
-            this.$emit("sendCreatedAssignment", res.data);
-            this.loadingCreateAssignment = false;
-          } else {
-            //创建失败
-            this.isCreateModalActive = false;
-            this.loadingCreateAssignment = false;
-            this.$dialog.alert({
-              title: "创建失败",
-              message: res.message,
-              type: "is-danger",
-              hasIcon: true
+          })
+          .catch(e => {
+            this.submitting = false;
+            this.$toast.open({
+              message: e.message || "服务器未知错误",
+              type: "is-danger"
             });
-          }
-        });
-        this.submitting = false;
+          });
       }
     },
     getDifficultyType(level) {