Browse Source

fix: 默认两个卷型调整

zhangjie 2 months ago
parent
commit
8959e5dbe7
1 changed files with 37 additions and 41 deletions
  1. 37 41
      src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

+ 37 - 41
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -630,14 +630,6 @@ export default {
       );
     },
   },
-  watch: {
-    "examTask.examId": function (val, oldval) {
-      if (val !== oldval) this.examAndRoomChange();
-    },
-    "examTask.teachingRoomId": function (val, oldval) {
-      if (val !== oldval) this.examAndRoomChange();
-    },
-  },
   mounted() {
     this.initData();
   },
@@ -725,9 +717,7 @@ export default {
       ).catch(() => {});
       if (result !== "confirm") return;
 
-      this.paperAttachments = [];
-      this.addAtachment();
-
+      this.initPaperAttachments();
       this.curTab = tab;
     },
     async getCardList() {
@@ -794,8 +784,12 @@ export default {
       // this.clearTaskData();
 
       this.examTask.courseId = "";
+      this.examTask.courseName = "";
       this.getCourses();
-      this.courseChange();
+
+      this.paperAttachments = [];
+      this.addAtachment();
+      this.examAndRoomChange();
     },
     courseChange(val) {
       if (val) {
@@ -805,15 +799,17 @@ export default {
       } else {
         this.examTask.courseName = "";
       }
-      this.clearTaskData();
+      this.cards = [];
+      this.getCardList();
+      this.initPaperAttachments();
       this.updateTaskInfo({ infoExamTask: this.examTask });
     },
-    clearTaskData() {
+    initPaperAttachments() {
       this.paperAttachments = [];
       this.addAtachment();
-
-      this.cards = [];
-      this.getCardList();
+      if (this.examTask.twoPaperEnable) {
+        this.addAtachment();
+      }
     },
     updateExamTaskDetail() {
       this.paperAttachments.forEach((paperAttachment) => {
@@ -847,32 +843,32 @@ export default {
       this.updateTaskInfo({ infoExamTask: this.examTask });
 
       const { examId, teachingRoomId } = this.examTask;
-      if (examId && teachingRoomId) {
-        const examPrintPlan = await examConfigByExamIdOrgId({
-          examId,
-          orgId: teachingRoomId,
-        });
-        this.examTask.cardRuleId = examPrintPlan.cardRuleId;
-        this.examTask.review = examPrintPlan.review;
-        this.examTask.includePaper =
-          examPrintPlan.printContent.indexOf("PAPER") !== -1;
-        this.examTask.twoPaperEnable = examPrintPlan.twoPaperEnable;
-        // 如果启用二卷,且当前没有二卷,则添加二卷
-        if (examPrintPlan.twoPaperEnable && !this.paperAttachments.length < 2) {
-          this.addAtachment();
-        }
-        this.updateExamTaskDetail();
+      if (!examId || !teachingRoomId) return;
 
-        this.updateTaskInfo({
-          infoExamPrintPlan: Object.assign(
-            {},
-            this.infoExamPrintPlan,
-            examPrintPlan
-          ),
-          infoExamTask: this.examTask,
-          infoExamTaskDetail: this.examTaskDetail,
-        });
+      const examPrintPlan = await examConfigByExamIdOrgId({
+        examId,
+        orgId: teachingRoomId,
+      });
+      this.examTask.cardRuleId = examPrintPlan.cardRuleId;
+      this.examTask.review = examPrintPlan.review;
+      this.examTask.includePaper =
+        examPrintPlan.printContent.indexOf("PAPER") !== -1;
+      this.examTask.twoPaperEnable = examPrintPlan.twoPaperEnable;
+      // 如果启用二卷,且当前没有二卷,则添加二卷
+      if (examPrintPlan.twoPaperEnable && !this.paperAttachments.length < 2) {
+        this.addAtachment();
       }
+      this.updateExamTaskDetail();
+
+      this.updateTaskInfo({
+        infoExamPrintPlan: Object.assign(
+          {},
+          this.infoExamPrintPlan,
+          examPrintPlan
+        ),
+        infoExamTask: this.examTask,
+        infoExamTaskDetail: this.examTaskDetail,
+      });
     },
     async cardChange(attachment) {
       const card = this.cards.find((item) => item.id === attachment.cardId);