/** 树节点搜索：匹配当前节点或任一祖先节点名称 */
export function matchTreeNodeName(value: string, data: any, node: any): boolean {
    if (!value) return true
    if (!data?.name) return false
    if (data.name.indexOf(value) !== -1) return true

    const level = node.level
    if (level === 1) return false

    let parentData = node.parent
    for (let i = 0; i < level - 1; i++) {
        if (parentData?.data?.name?.indexOf(value) !== -1) return true
        parentData = parentData.parent
    }
    return false
}

export function createTreeFilterNode() {
    return (value: string, data: any, node: any): boolean => matchTreeNodeName(value, data, node)
}
