import { TreeSelect } from "antd"; import { getTreeNodePaths, processTreeDataByLevel } from "../../../utils"; /** * 基础下拉树组件(不建议直接使用此组件,二次继承使用) */ function BasicSelectTree(props) { const { onSelect, onGetNodePaths, onGetNodePathsIsIncludeOneself = true, placeholder = "", treeData = [], nameKey = "name", idKey = "id", childrenKey = "childrenList", level, ...restProps } = props; // 根据 level 处理树数据 const processedTreeData = level ? processTreeDataByLevel({ data: treeData, level, childrenKey, currentLevel: 1, }) : treeData; const handleSelect = (value, node, extra) => { if (value.length > 0) { const parentNodes = getTreeNodePaths({ data: treeData, targetId: value, idKey, childrenKey, isIncludeOneself: onGetNodePathsIsIncludeOneself, }); onGetNodePaths?.(parentNodes); } onSelect?.(value, node, extra); }; return ( ); } BasicSelectTree.displayName = "BasicSelectTree"; export default BasicSelectTree;