lex-xin 11 hónapja
szülő
commit
5a948ffaa0

+ 34 - 9
src/views/teamDetail/componentClass/student-list.vue

@@ -33,7 +33,8 @@
       style
       :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
       tooltip-effect="dark"
-      @selection-change="handleSelectionChange"
+      @select="onTableSelect"
+      @select-all="onTableSelectALL"
       max-height="300px"
     >
       <el-table-column
@@ -103,7 +104,7 @@ export default {
         search: "",
         subjectId: null,
       },
-      selectList: this.chioseList
+      selectList: this.chioseList || []
     };
   },
  async mounted() {
@@ -149,18 +150,42 @@ export default {
         }
       });
     },
-    handleSelectionChange(val) {
-       if(this.loading) return
-      this.selectList = val;
+    // handleSelectionChange(val) {
+    //    if(this.loading) return
+    //   this.selectList = val;
+    // },
+    // onTableSelect(rows, row) {
+    //   let idList = this.selectList.map((group) => {
+    //     return group.userId;
+    //   });
+    //   if (idList.indexOf(row.userId) != -1) {
+    //     this.selectList.splice(idList.indexOf(row.userId), 1);
+    //     if (this.selectList.length <= 0) {
+    //       this.clearCom();
+    //     }
+    //   }
+    // },
+    onTableSelectALL(val) {
+      this.selectList = val
     },
     onTableSelect(rows, row) {
       let idList = this.selectList.map((group) => {
         return group.userId;
       });
-      if (idList.indexOf(row.userId) != -1) {
-        this.selectList.splice(idList.indexOf(row.userId), 1);
-        if (this.selectList.length <= 0) {
-          this.clearCom();
+
+
+      let inIdList = rows.map((group) => {
+        return group.userId;
+      });
+      const isAdd = inIdList.indexOf(row.userId) === -1 ? false : true
+
+      if(isAdd) {
+        if(idList.indexOf(row.userId) === -1) {
+          this.selectList.push(row)
+        }
+      } else {
+        if(idList.indexOf(row.userId) !== -1) {
+          this.selectList.splice(idList.indexOf(row.userId), 1)
         }
       }
     },

+ 27 - 7
src/views/teamDetail/components/modals/view-student-list.vue

@@ -48,6 +48,7 @@
       tooltip-effect="dark"
       @selection-change="handleSelectionChange"
       @select="onTableSelect"
+      @select-all="onTableSelectALL"
       max-height="300px"
       @sort-change="sortChang"
     >
@@ -223,7 +224,7 @@ export default {
         id: 'classroom',
         name: '课堂课'
       }],
-      selectList: this.chioseList,
+      selectList: this.chioseList || [],
       loading: false,
     };
   },
@@ -296,17 +297,36 @@ export default {
       this.getList()
     },
     handleSelectionChange(val) {
-      if(this.loading) return
-      this.selectList = val;
+    //   if(this.loading) {
+    //     return
+    //   }
+    //   // console.log(val, 'val', val2)
+    //   // let idList = val.map((group) => {
+    //   //   return group.userId;
+    //   // });
+    //   this.selectList = val;
+    },
+    onTableSelectALL(val) {
+      this.selectList = val
     },
     onTableSelect(rows, row) {
       let idList = this.selectList.map((group) => {
         return group.userId;
       });
-      if (idList.indexOf(row.userId) != -1) {
-        this.selectList.splice(idList.indexOf(row.userId), 1);
-        if (this.selectList.length <= 0) {
-          this.clearCom();
+
+
+      let inIdList = rows.map((group) => {
+        return group.userId;
+      });
+      const isAdd = inIdList.indexOf(row.userId) === -1 ? false : true
+
+      if(isAdd) {
+        if(idList.indexOf(row.userId) === -1) {
+          this.selectList.push(row)
+        }
+      } else {
+        if(idList.indexOf(row.userId) !== -1) {
+          this.selectList.splice(idList.indexOf(row.userId), 1)
         }
       }
     },