OrganizationIdTree.vue
1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<template>
<div class="bg-white m-4 mr-0 overflow-hidden">
<BasicTree
v-if="treeData.length > 0"
title="组织列表"
toolbar
search
:clickRowToExpand="false"
:treeData="treeData"
:replaceFields="{ key: 'id', title: 'name' }"
v-model:expandedKeys="expandedKeys"
v-model:selectedKeys="selectedKeys"
@select="handleSelect"
:defaultExpandAll="true"
/>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
import { BasicTree, TreeItem } from '/@/components/Tree';
import { getOrganizationList } from '/@/api/system/system';
export default defineComponent({
name: 'OrganizationIdTree',
components: { BasicTree },
emits: ['select'],
setup(_, { emit }) {
const getTreeRef: any = ref(null);
const treeData = ref<TreeItem[]>([]);
const selectedKeys = ref<string[]>();
const expandedKeys = ref<string[]>();
async function fetch() {
treeData.value = (await getOrganizationList()) as unknown as TreeItem[];
}
function handleSelect(keys) {
emit('select', keys[0]);
}
function resetOrganization() {
selectedKeys.value = [];
}
onMounted(() => {
fetch();
});
return {
treeData,
handleSelect,
resetOrganization,
selectedKeys,
expandedKeys,
getTreeRef,
};
},
});
</script>