vue element UI表格树全选不选择二级以下
可能也有别的小伙伴跟我遇到同样的bug,可惜百度了一圈也没找到合适的解决办法,所以就自己改造了下跟各位分享,暂时已经满足我们这个产品的需求,还可以根据场景进一步更新,话不多说直接上代码
需求:
1点击全选时 一级和以下全部为选中或非选中状态
2点击父节点子节点全部为选中或非选中状态
<el-table
v-loading="loading"
:data="tableData"
row-key="treeId"
height="100%"
border
:class="'mytables'"
ref="multipleTable"
default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
:header-cell-style="{'background-color': '#F6F6F6','font-weight':'600','color': '#333','height':'20px'}"
@selection-change="handleSelectionChange"//注意这里
>
<el-table-column type="selection" width="55">
<template slot-scope="scope">//改造后的
<el-checkbox v-model="scope.row.checks" @change="toselect(scope.row)"></el-checkbox>
</template>
</el-table-column>