update Table tree
This commit is contained in:
parent
40f055f904
commit
6118c2c8d1
2 changed files with 28 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div style="margin: 100px;">
|
<div style="margin: 100px;">
|
||||||
<Table border ref="selection" :columns="columns4" :data="data1" row-key></Table>
|
<Table disabled-hover border ref="selection" :columns="columns4" :data="data1" row-key></Table>
|
||||||
<Button @click="handleSelectAll(true)">Set all selected</Button>
|
<Button @click="handleSelectAll(true)">Set all selected</Button>
|
||||||
<Button @click="handleSelectAll(false)">Cancel all selected</Button>
|
<Button @click="handleSelectAll(false)">Cancel all selected</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -95,10 +95,6 @@
|
||||||
rowExpanded (_index) {
|
rowExpanded (_index) {
|
||||||
return this.objData[_index] && this.objData[_index]._isExpanded;
|
return this.objData[_index] && this.objData[_index]._isExpanded;
|
||||||
},
|
},
|
||||||
// todo
|
|
||||||
rowShowChildren (_index) {
|
|
||||||
return this.objData[_index] && this.objData[_index]._isShowChildren;
|
|
||||||
},
|
|
||||||
handleMouseIn (_index, event) {
|
handleMouseIn (_index, event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.$parent.handleMouseIn(_index);
|
this.$parent.handleMouseIn(_index);
|
||||||
|
@ -144,6 +140,32 @@
|
||||||
const result = this.getSpan(row, column, rowIndex, columnIndex);
|
const result = this.getSpan(row, column, rowIndex, columnIndex);
|
||||||
return !(('rowspan' in result && result.rowspan === 0) || ('colspan' in result && result.colspan === 0));
|
return !(('rowspan' in result && result.rowspan === 0) || ('colspan' in result && result.colspan === 0));
|
||||||
},
|
},
|
||||||
|
isTrShow (rowKey) {
|
||||||
|
let status = true;
|
||||||
|
this.data.forEach(row => {
|
||||||
|
const showChildren = row._isShowChildren;
|
||||||
|
if (row._rowKey === rowKey) {
|
||||||
|
status = status && showChildren;
|
||||||
|
} else if (row.children && row.children.length) {
|
||||||
|
status = this.getTrStatus(rowKey, row, status && showChildren);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return status;
|
||||||
|
},
|
||||||
|
getTrStatus (rowKey, data, parentStatus) {
|
||||||
|
let status = parentStatus;
|
||||||
|
if (data.children && data.children.length) {
|
||||||
|
data.children.forEach(row => {
|
||||||
|
const showChildren = row._isShowChildren;
|
||||||
|
if (row._rowKey === rowKey) {
|
||||||
|
status = status && showChildren;
|
||||||
|
} else if (row.children && row.children.length) {
|
||||||
|
status = this.getTrStatus(rowKey, row, status && showChildren);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
},
|
||||||
getChildNode (h, data, nodes, level = 1) {
|
getChildNode (h, data, nodes, level = 1) {
|
||||||
if (data.children && data.children.length) {
|
if (data.children && data.children.length) {
|
||||||
data.children.forEach((row, index) => {
|
data.children.forEach((row, index) => {
|
||||||
|
@ -178,8 +200,7 @@
|
||||||
|
|
||||||
// 判断节点是否展开
|
// 判断节点是否展开
|
||||||
const trStyle = {};
|
const trStyle = {};
|
||||||
// todo
|
if (!this.isTrShow(data._rowKey)) trStyle.display = 'none';
|
||||||
if (!this.rowShowChildren(row._index)) trStyle.display = 'none';
|
|
||||||
|
|
||||||
const $tableTr = h(TableTr, {
|
const $tableTr = h(TableTr, {
|
||||||
props: {
|
props: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue