Table tree support selectAll func

This commit is contained in:
梁灏 2020-01-08 09:37:34 +08:00
parent ec1f67fa7e
commit 3c9452ef2a
2 changed files with 35 additions and 12 deletions

View file

@ -10,6 +10,8 @@
@on-row-dblclick="ordc"
@on-select="os"
@on-select-cancel="osc"
@on-select-all="osa"
@on-select-all-cancel="osac"
ref="selection"
:columns="columns4"
:data="data1"
@ -46,7 +48,8 @@
{
title: 'Age',
// key: 'age',
slot: 'age'
slot: 'age',
sortable: true
},
{
title: 'Date',
@ -73,7 +76,7 @@
address: 'London No. 1 Lake Park',
date: '2016-10-01',
_showChildren: true,
_disabled: true,
_disabled: false,
children: [
{
id: '10100',
@ -117,7 +120,8 @@
name: '第九',
age: 23,
address: '9梵蒂冈人太热疼我',
date: '2016-10-07'
date: '2016-10-07',
_disabled: true
},
{
id: '10102101101',
@ -138,7 +142,7 @@
age: 30,
address: 'Sydney No. 1 Lake Park',
date: '2016-10-02',
_disabled: true,
_disabled: false,
},
{
id: '103',
@ -217,12 +221,18 @@
// console.log(index);
},
os (s, r) {
console.log(s);
console.log(r);
// console.log(s);
// console.log(r);
},
osc (s, r) {
console.log(s);
console.log(r);
},
osa (s) {
console.log(s);
},
osac (s) {
console.log(s);
}
}
}

View file

@ -851,11 +851,13 @@
// }
// });
for(const data of this.rebuildData){
if(this.objData[data._index]._isDisabled){
continue;
}else{
this.objData[data._index]._isChecked = status;
for (const data of this.rebuildData) {
const objData = this.objData[data._index];
if (!objData._isDisabled) {
objData._isChecked = status;
}
if (data.children && data.children.length) {
this.selectAllChildren(objData, status);
}
}
const selection = this.getSelection();
@ -866,7 +868,18 @@
}
this.$emit('on-selection-change', selection);
},
selectAllChildren (data, status) {
if (data.children && data.children.length) {
data.children.map(item => {
if (!item._isDisabled) {
item._isChecked = status;
}
if (item.children && item.children.length) {
this.selectAllChildren(item, status);
}
});
}
},
fixedHeader () {
if (this.height || this.maxHeight) {
this.$nextTick(() => {