Эх сурвалжийг харах

编辑试卷只卷库提示

xiatian 2 сар өмнө
parent
commit
a5bd9e2878

+ 140 - 31
src/modules/questions/views/EditPaper.vue

@@ -1266,10 +1266,39 @@ export default {
         }
       }
       if (count == 0) {
-        this.$alert(
-          "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
-          "提示",
-          {
+        if (this.paper.paperType == "GENERATE") {
+          this.$alert(
+            "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
+            "提示",
+            {
+              dangerouslyUseHTMLString: true,
+              confirmButtonText: "确定",
+              callback: (action) => {
+                if (action == "confirm") {
+                  this.loading = true;
+                  this.$httpWithMsg
+                    .delete(
+                      QUESTION_API +
+                        "/paperDetail/" +
+                        this.paperId +
+                        "/" +
+                        paperDetailsId
+                    )
+                    .then(() => {
+                      this.initPaper();
+                      this.loading = true;
+                      this.$notify({
+                        message: "删除成功",
+                        type: "success",
+                      });
+                    })
+                    .finally(() => (this.loading = false));
+                }
+              },
+            }
+          );
+        } else {
+          this.$alert("您确定删除吗?", "提示", {
             dangerouslyUseHTMLString: true,
             confirmButtonText: "确定",
             callback: (action) => {
@@ -1294,8 +1323,8 @@ export default {
                   .finally(() => (this.loading = false));
               }
             },
-          }
-        );
+          });
+        }
       } else {
         this.$alert("大题下还有小题,不可删除!", "提示", {
           confirmButtonText: "确定",
@@ -1789,10 +1818,37 @@ export default {
       }
     },
     deleteQues01(paperDetailUnitId) {
-      this.$alert(
-        "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
-        "提示",
-        {
+      if (this.paper.paperType == "GENERATE") {
+        this.$alert(
+          "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
+          "提示",
+          {
+            dangerouslyUseHTMLString: true,
+            confirmButtonText: "确定",
+            callback: (action) => {
+              if (action == "confirm") {
+                this.loading = true;
+                this.$httpWithMsg
+                  .delete(
+                    QUESTION_API + "/paperDetailUnit/" + paperDetailUnitId
+                  )
+                  .then(() => {
+                    this.initPaper();
+                    this.getreduplicateQuestions();
+                    this.reduplicateGroup = [];
+                    this.loading = true;
+                    this.$notify({
+                      message: "删除成功",
+                      type: "success",
+                    });
+                  })
+                  .finally(() => (this.loading = false));
+              }
+            },
+          }
+        );
+      } else {
+        this.$alert("您确定删除吗?", "提示", {
           dangerouslyUseHTMLString: true,
           confirmButtonText: "确定",
           callback: (action) => {
@@ -1813,14 +1869,45 @@ export default {
                 .finally(() => (this.loading = false));
             }
           },
-        }
-      );
+        });
+      }
     },
     deleteQues02(questionId, paperDetailUnitId) {
-      this.$alert(
-        "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
-        "提示",
-        {
+      if (this.paper.paperType == "GENERATE") {
+        this.$alert(
+          "您确定删除吗?</br><span style='color:red'>保存后请注意检查试卷总分</span>",
+          "提示",
+          {
+            dangerouslyUseHTMLString: true,
+            confirmButtonText: "确定",
+            callback: (action) => {
+              if (action == "confirm") {
+                this.loading = true;
+                this.$httpWithMsg
+                  .delete(
+                    QUESTION_API +
+                      "/paper/deleteQuestion/" +
+                      paperDetailUnitId +
+                      "/" +
+                      questionId
+                  )
+                  .then(() => {
+                    this.initPaper();
+                    this.getreduplicateQuestions();
+                    this.reduplicateGroup = [];
+                    this.loading = true;
+                    this.$notify({
+                      message: "保存成功",
+                      type: "success",
+                    });
+                  })
+                  .finally(() => (this.loading = false));
+              }
+            },
+          }
+        );
+      } else {
+        this.$alert("您确定删除吗?", "提示", {
           dangerouslyUseHTMLString: true,
           confirmButtonText: "确定",
           callback: (action) => {
@@ -1847,8 +1934,8 @@ export default {
                 .finally(() => (this.loading = false));
             }
           },
-        }
-      );
+        });
+      }
     },
     //获取重复试题
     getreduplicateQuestions() {
@@ -1912,18 +1999,40 @@ export default {
     },
     //保存试卷
     savePaper() {
-      this.$confirm(
-        "<span style='color:red'>当前试卷总分为" +
-          this.paper.totalScore +
-          ",是否保存?</span>",
-        "提示",
-        {
-          dangerouslyUseHTMLString: true,
-          confirmButtonText: "是",
-          cancelButtonText: "否",
-          type: "warning",
-        }
-      ).then(() => {
+      if (this.paper.paperType == "GENERATE") {
+        this.$confirm(
+          "<span style='color:red'>当前试卷总分为" +
+            this.paper.totalScore +
+            ",是否保存?</span>",
+          "提示",
+          {
+            dangerouslyUseHTMLString: true,
+            confirmButtonText: "是",
+            cancelButtonText: "否",
+            type: "warning",
+          }
+        ).then(() => {
+          this.loading = true;
+          this.$http
+            .put(QUESTION_API + "/paper", this.paper)
+            .then(() => {
+              this.$notify({
+                message: "保存成功",
+                type: "success",
+              });
+              this.loading = false;
+              this.initPaper();
+            })
+            .catch((error) => {
+              this.loading = false;
+              this.$notify({
+                type: "error",
+                message: error.response.data.desc,
+              });
+            })
+            .finally(() => (this.loading = false));
+        });
+      } else {
         this.loading = true;
         this.$http
           .put(QUESTION_API + "/paper", this.paper)
@@ -1943,7 +2052,7 @@ export default {
             });
           })
           .finally(() => (this.loading = false));
-      });
+      }
     },
     //删除试卷
     deletePaper(id) {