瀏覽代碼

fix:命题任务选择学生问题

zhangjie 2 年之前
父節點
當前提交
68d6272624

+ 1 - 1
src/modules/exam/components/ApplyContent.vue

@@ -898,7 +898,7 @@ export default {
     toEditCard(attachment) {
       this.curAttachment = { ...attachment };
       this.$ls.set("prepareTcPCard", {
-        cardId: this.curTaskApply.cardId,
+        cardId: attachment.cardId,
         examTaskId: this.curTaskApply.examTaskId,
         courseCode: this.curTaskApply.courseCode,
         courseName: this.curTaskApply.courseName,

+ 1 - 1
src/modules/exam/components/ModifyTaskPaper.vue

@@ -438,7 +438,7 @@ export default {
     toEditCard(attachment) {
       this.curAttachment = { ...attachment };
       this.$ls.set("prepareTcPCard", {
-        cardId: this.curTaskApply.cardId,
+        cardId: attachment.cardId,
         examTaskId: this.curTaskApply.examTaskId,
         courseCode: this.curTaskApply.courseCode,
         courseName: this.curTaskApply.courseName,

+ 18 - 5
src/modules/exam/components/createExamAndPrintTask/ModifyExamStudent.vue

@@ -125,6 +125,7 @@ export default {
       this.dataTree[datas.examObjectType] = this.parseStudentData(data);
     },
     parseStudentData(data) {
+      const disabledStdIds = this.disabledIds.map(item => item.split("_")[1]);
       return data.map(item => {
         let nitem = {
           id: item.clazzId,
@@ -138,7 +139,7 @@ export default {
         nitem.children = item.studentInfoList.map(elem => {
           return {
             ...elem,
-            disabled: this.disabledIds.includes(elem.id),
+            disabled: disabledStdIds.includes(elem.studentId),
             isUser: true,
             id: `${item.clazzId}_${elem.studentId}`,
             label: elem.studentName,
@@ -160,14 +161,17 @@ export default {
         await this.getStudents();
       }
       this.userTree = this.dataTree[val];
-      this.updateUserTreeDisableInfo();
+      this.updateUserTreeDisableInfo(this.disabledIds);
     },
     clearTypeData(type = "BASIC_CLAZZ_STUDENT") {
       this.dataTree[type] = [];
     },
     checkChange() {
       // console.log("check click");
-      let selectedKeys = this.$refs.UserTree.getCheckedKeys(true);
+      const selectedKeys = this.$refs.UserTree.getCheckedKeys(true);
+      const disabledIds = [...selectedKeys, ...this.disabledIds];
+      const disabledStdIds = disabledIds.map(item => item.split("_")[1]);
+
       let selectedUsers = [];
       this.userTree.forEach(item => {
         const children = item.children.filter(elem =>
@@ -179,6 +183,13 @@ export default {
             children
           });
         }
+        // 同一个学生只允许选择一次
+        item.children.forEach(elem => {
+          elem.disabled =
+            !selectedKeys.includes(elem.id) &&
+            disabledStdIds.includes(elem.studentId);
+        });
+        item.disabled = !item.children.some(elem => !elem.disabled);
       });
       this.selectedUsers = selectedUsers;
     },
@@ -202,10 +213,12 @@ export default {
 
       this.selectMenu(this.examObjectType);
     },
-    updateUserTreeDisableInfo() {
+    updateUserTreeDisableInfo(disabledIds) {
+      const disabledStdIds = disabledIds.map(item => item.split("_")[1]);
+
       this.userTree.forEach(item => {
         item.children.forEach(elem => {
-          elem.disabled = this.disabledIds.includes(elem.id);
+          elem.disabled = disabledStdIds.includes(elem.studentId);
         });
         item.disabled = !item.children.some(elem => !elem.disabled);
       });