Browse Source

fix:修改树查询问题

temp
zhaohy 3 months ago
parent
commit
f21e8d48a6
  1. 31
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/notificationManagement/linkPeople/index.vue

31
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/notificationManagement/linkPeople/index.vue

@ -70,7 +70,7 @@
import { http } from '/nerv-lib/util'; import { http } from '/nerv-lib/util';
// //
const dataList: TreeProps['treeData'] = []; let dataList: TreeProps['treeData'] = [];
const generateList = (data: TreeProps['treeData']) => { const generateList = (data: TreeProps['treeData']) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const node = data[i]; const node = data[i];
@ -80,23 +80,28 @@
generateList(node.children); generateList(node.children);
} }
} }
console.log(dataList, '数据');
}; };
const getParentKey = ( const getParentKey = (
key: string | number, key: string | number,
tree: TreeProps['treeData'], tree: TreeProps['treeData'],
): string | number | undefined => { parents: (string | number)[] = [],
let parentKey; ): (string | number)[] | undefined => {
for (let i = 0; i < tree.length; i++) { for (const node of tree) {
const node = tree[i];
if (node.children) { if (node.children) {
if (node.children.some((item) => item.key === key)) { if (node.children.some((item) => item.key === key)) {
parentKey = node.key; //
} else if (getParentKey(key, node.children)) { return [...parents, node.key];
parentKey = getParentKey(key, node.children);
} }
//
const result = getParentKey(key, node.children, [...parents, node.key]);
if (result) {
return result;
} }
} }
return parentKey; }
return undefined;
}; };
export default defineComponent({ export default defineComponent({
setup(props, { emit }) { setup(props, { emit }) {
@ -172,6 +177,7 @@
getDepartList({ orgId: orgId.value }).then((res) => { getDepartList({ orgId: orgId.value }).then((res) => {
deptTreeData.value = res; deptTreeData.value = res;
selectedKeys.value = [orgId.value]; selectedKeys.value = [orgId.value];
dataList = [];
generateList(deptTreeData.value); generateList(deptTreeData.value);
}); });
}; };
@ -304,7 +310,12 @@
return null; return null;
}) })
.filter((item, i, self) => item && self.indexOf(item) === i); .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; searchValue.value = value;
autoExpandParent.value = true; autoExpandParent.value = true;
}); });

Loading…
Cancel
Save