Commit 9fb3d5fcb8dee16882f244e263d8ecd6c245f9fe

Authored by fengtao
1 parent 980b4447

fix:refractor:优化所有组织管理结构,自动展开父级

... ... @@ -7,6 +7,7 @@
7 7 search
8 8 :clickRowToExpand="false"
9 9 :treeData="treeData"
  10 + :expandedKeys="treeExpandData"
10 11 :replaceFields="{ key: 'id', title: 'name' }"
11 12 :selectedKeys="selectedKeys"
12 13 @select="handleSelect"
... ... @@ -20,17 +21,25 @@
20 21 const emit = defineEmits(['select']);
21 22 const treeData = ref<TreeItem[]>([]);
22 23 const selectedKeys = ref<string[]>();
23   -
  24 + const treeExpandData = ref([]);
  25 + //获取所有父级id
  26 + function findForAllId(data = [], arr = []) {
  27 + for (const item of data) {
  28 + arr.push(item.id);
  29 + }
  30 + return arr;
  31 + }
24 32 function handleSelect(keys) {
25 33 emit('select', keys[0]);
26 34 }
27   -
28 35 function resetOrganization() {
29 36 selectedKeys.value = [];
30 37 }
31   -
32 38 onMounted(async () => {
33 39 treeData.value = (await getOrganizationList()) as unknown as TreeItem[];
  40 + const getAllIds = findForAllId(treeData.value as any, []);
  41 + //设置要展开的id
  42 + treeExpandData.value = getAllIds;
34 43 });
35 44 defineExpose({
36 45 resetOrganization,
... ...