<template>
//row-key 和ref 要必須寫
<el-table
v-loading="load"
element-loading-text="加載數據中"
ref="theTable"
:data="tableList"
style="width: 100%"
:row-key="add"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
:header-cell-style="{ background: '#eef1f6', color: '#606266' }"
></el-table>
......
</template>
method:{
//篩選
screenclick() {
//點擊篩選的時候 讓篩選出來的數據展開
this.forArr(this.tableList, false);
this.getList();
},
// 重置
Resetdata() {
this.textval = "";
//重置的時候 讓數據全部收起
this.forArr(this.tableList, false);
this.getList();
},
//列表展開和收起
forArr(arr, isExpand) {
arr.forEach(i => {
this.$refs.theTable.toggleRowExpansion(i, isExpand);
if (i.children) {
this.forArr(i.children, isExpand);
}
});
},
}