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