|
|
@@ -153,6 +153,12 @@ export class Tree<T extends TreeRaw = TreeRaw> {
|
|
|
this.reGenData();
|
|
|
}
|
|
|
|
|
|
+ // 根据字段值查找节点
|
|
|
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
+ findByField(field: string, value: any): TreeNode<T> | null {
|
|
|
+ return this.data.find(item => item[field] === value) || null;
|
|
|
+ }
|
|
|
+
|
|
|
// 查找ID节点
|
|
|
find(ID: string): TreeNode<T> | null {
|
|
|
return this.IDMap[ID] || null;
|