🐛(component): update
This commit is contained in:
parent
85b14ba7e4
commit
8d19e433a7
@ -133,15 +133,26 @@ class Tree {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
treeForeach (tree: any, func: Function) {
|
||||||
|
tree.forEach((data: any) => {
|
||||||
|
data.children && this.treeForeach(data.children, func) // 遍历子树
|
||||||
|
func(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
setChildrenChecked(checked: boolean, nodes: TreeData[]) {
|
setChildrenChecked(checked: boolean, nodes: TreeData[]) {
|
||||||
|
var ableCount = 0;
|
||||||
|
var checkCount = 0;
|
||||||
const len = nodes.length;
|
const len = nodes.length;
|
||||||
/**
|
this.treeForeach(nodes ,(node: any) => {
|
||||||
* 判断所有子项, 如果存在选中项, 并且全选, 取消所有选中
|
if(!node.isDisabled) {
|
||||||
*
|
ableCount = ableCount + 1;
|
||||||
* 如果存在选中项, 未全部选着, 选中全部
|
if(node.isChecked) {
|
||||||
*
|
checkCount = checkCount + 1;
|
||||||
* 如果不存在选中项, 选中全部可选
|
}
|
||||||
*/
|
}
|
||||||
|
})
|
||||||
|
checkCount < ableCount ? checked = true : checked = false;
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
if(!nodes[i].isDisabled || (nodes[i].isDisabled && nodes[i].children.length > 0)) {
|
if(!nodes[i].isDisabled || (nodes[i].isDisabled && nodes[i].children.length > 0)) {
|
||||||
nodes[i].isChecked = checked;
|
nodes[i].isChecked = checked;
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
rel="nofollow"
|
rel="nofollow"
|
||||||
class="site-star"
|
class="site-star"
|
||||||
>
|
>
|
||||||
<i class="layui-icon"></i> Star <cite id="getStars">1514</cite>
|
<i class="layui-icon"></i> Star <cite id="getStars">1576</cite>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="https://gitee.com/layui-vue"
|
href="https://gitee.com/layui-vue"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user