|
|
@ -70,7 +70,7 @@ |
|
|
|
import { http } from '/nerv-lib/util'; |
|
|
|
|
|
|
|
//搜索存储 拼凑树的搜索类型 |
|
|
|
const dataList: TreeProps['treeData'] = []; |
|
|
|
let dataList: TreeProps['treeData'] = []; |
|
|
|
const generateList = (data: TreeProps['treeData']) => { |
|
|
|
for (let i = 0; i < data.length; i++) { |
|
|
|
const node = data[i]; |
|
|
@ -80,23 +80,28 @@ |
|
|
|
generateList(node.children); |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(dataList, '数据'); |
|
|
|
}; |
|
|
|
const getParentKey = ( |
|
|
|
key: string | number, |
|
|
|
tree: TreeProps['treeData'], |
|
|
|
): string | number | undefined => { |
|
|
|
let parentKey; |
|
|
|
for (let i = 0; i < tree.length; i++) { |
|
|
|
const node = tree[i]; |
|
|
|
parents: (string | number)[] = [], |
|
|
|
): (string | number)[] | undefined => { |
|
|
|
for (const node of tree) { |
|
|
|
if (node.children) { |
|
|
|
if (node.children.some((item) => item.key === key)) { |
|
|
|
parentKey = node.key; |
|
|
|
} else if (getParentKey(key, node.children)) { |
|
|
|
parentKey = getParentKey(key, node.children); |
|
|
|
// 找到目标节点的直接父节点 |
|
|
|
return [...parents, node.key]; |
|
|
|
} |
|
|
|
|
|
|
|
// 递归检查子节点的子节点 |
|
|
|
const result = getParentKey(key, node.children, [...parents, node.key]); |
|
|
|
if (result) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return parentKey; |
|
|
|
return undefined; |
|
|
|
}; |
|
|
|
export default defineComponent({ |
|
|
|
setup(props, { emit }) { |
|
|
@ -172,6 +177,7 @@ |
|
|
|
getDepartList({ orgId: orgId.value }).then((res) => { |
|
|
|
deptTreeData.value = res; |
|
|
|
selectedKeys.value = [orgId.value]; |
|
|
|
dataList = []; |
|
|
|
generateList(deptTreeData.value); |
|
|
|
}); |
|
|
|
}; |
|
|
@ -304,7 +310,12 @@ |
|
|
|
return null; |
|
|
|
}) |
|
|
|
.filter((item, i, self) => item && self.indexOf(item) === i); |
|
|
|
expandedKeys.value = expanded; |
|
|
|
console.log(expanded, '数据1111'); |
|
|
|
let selctky = []; |
|
|
|
expanded.forEach((item) => { |
|
|
|
selctky.push(...item); |
|
|
|
}); |
|
|
|
expandedKeys.value = selctky; |
|
|
|
searchValue.value = value; |
|
|
|
autoExpandParent.value = true; |
|
|
|
}); |
|
|
|