Tree: add includeHalfChecked flag to getCheckedNodes (#12014)

This commit is contained in:
hetech
2018-07-25 17:42:53 +08:00
committed by Jikkai Xiao
parent 1cc45b83d8
commit 3ed724492f
6 changed files with 11 additions and 10 deletions

View File

@@ -153,13 +153,13 @@ export default class TreeStore {
delete this.nodesMap[node.key];
}
getCheckedNodes(leafOnly = false) {
getCheckedNodes(leafOnly = false, includeHalfChecked = false) {
const checkedNodes = [];
const traverse = function(node) {
const childNodes = node.root ? node.root.childNodes : node.childNodes;
childNodes.forEach((child) => {
if (child.checked && (!leafOnly || (leafOnly && child.isLeaf))) {
if ((child.checked || (includeHalfChecked && child.indeterminate)) && (!leafOnly || (leafOnly && child.isLeaf))) {
checkedNodes.push(child.data);
}