// 递归查找树结构数据
function getIsNode(nodes: any, code: string) {let found = false;function search(nodes: any) {nodes.forEach((node: any) => {if (node.code === code) { //code相等,视为找到,将found设置为truefound = true;}// 否则查找子节点if (node.children && node.children.length > 0) {search(node.children);}});}search(nodes);return found;}
// sortchooseList的元素不在dataSort数组中就过滤掉
sortchooseList = sortchooseList.filter((a: any) => getIsNode(dataSort, a.field || a.code));
dataSort树结构类似下图: