lex-xin 11 ماه پیش
والد
کامیت
3d74dc8002
2فایلهای تغییر یافته به همراه81 افزوده شده و 17 حذف شده
  1. 41 16
      src/views/teamDetail/componentClass/student-list.vue
  2. 40 1
      src/views/teamDetail/components/modals/view-student-list.vue

+ 41 - 16
src/views/teamDetail/componentClass/student-list.vue

@@ -33,6 +33,7 @@
       style
       :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
       tooltip-effect="dark"
+      @handleSelectionChange="handleSelectionChange"
       @select="onTableSelect"
       @select-all="onTableSelectALL"
       max-height="300px"
@@ -150,23 +151,47 @@ export default {
         }
       });
     },
-    // 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();
-    //     }
-    //   }
-    // },
+    handleSelectionChange(val) {
+      console.log(val, 'handleSelectionChange')
+    },
     onTableSelectALL(val) {
-      this.selectList = 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) => {

+ 40 - 1
src/views/teamDetail/components/modals/view-student-list.vue

@@ -307,7 +307,46 @@ export default {
     //   this.selectList = val;
     },
     onTableSelectALL(val) {
-      this.selectList = 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) => {