Procházet zdrojové kódy

Merge branch 'iteration-20240909' into 11/24SAAS

lex-xin před 11 měsíci
rodič
revize
403668ea1c

+ 58 - 8
src/views/teamDetail/componentClass/student-list.vue

@@ -33,7 +33,9 @@
       style
       :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
       tooltip-effect="dark"
-      @selection-change="handleSelectionChange"
+      @handleSelectionChange="handleSelectionChange"
+      @select="onTableSelect"
+      @select-all="onTableSelectALL"
       max-height="300px"
     >
       <el-table-column
@@ -103,7 +105,7 @@ export default {
         search: "",
         subjectId: null,
       },
-      selectList: this.chioseList
+      selectList: this.chioseList || []
     };
   },
  async mounted() {
@@ -150,17 +152,65 @@ export default {
       });
     },
     handleSelectionChange(val) {
-       if(this.loading) return
-      this.selectList = val;
+      console.log(val, 'handleSelectionChange')
+    },
+    onTableSelectALL(val) {
+      const list = this.list || []
+
+      if(val.length > 0) {
+        const sIds = this.selectList.map((item) => {
+          return item.userId
+        })
+        val.forEach((item) => {
+          if(sIds.indexOf(item.userId) == -1) {
+            this.selectList.push(item)
+          }
+        })
+      } else {
+        const ids = list.map((item) => {
+          return item.userId
+        })
+
+        const sIds = this.selectList.map((item) => {
+          return item.userId
+        })
+
+        const removeIds = []
+        ids.forEach((item) => {
+          if(sIds.indexOf(item) !== -1) {
+            removeIds.push(item)
+          }
+        })
+
+        console.log(ids, sIds, 'sids', removeIds)
+        const temp = []
+        this.selectList.forEach((item) => {
+          if(removeIds.indexOf(item.userId) === -1) {
+            temp.push(item)
+          }
+        })
+
+        this.selectList = temp
+      }
     },
     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)
         }
       }
     },

+ 66 - 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,75 @@ 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) {
+      const list = this.list || []
+
+
+      if(val.length > 0) {
+        const sIds = this.selectList.map((item) => {
+          return item.userId
+        })
+        val.forEach((item) => {
+          if(sIds.indexOf(item.userId) == -1) {
+            this.selectList.push(item)
+          }
+        })
+        
+      } else {
+        const ids = list.map((item) => {
+          return item.userId
+        })
+
+        const sIds = this.selectList.map((item) => {
+          return item.userId
+        })
+
+        const removeIds = []
+        ids.forEach((item) => {
+          if(sIds.indexOf(item) !== -1) {
+            removeIds.push(item)
+          }
+        })
+
+        console.log(ids, sIds, 'sids', removeIds)
+        const temp = []
+        this.selectList.forEach((item) => {
+          if(removeIds.indexOf(item.userId) === -1) {
+            temp.push(item)
+          }
+        })
+
+        this.selectList = temp
+      }
+      // 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)
         }
       }
     },