|
@@ -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)
|
|
|
}
|
|
|
}
|
|
|
},
|