You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
874 B
38 lines
874 B
2 years ago
|
<template>
|
||
|
<div class="m-4 mr-0 overflow-hidden bg-white">
|
||
|
<BasicTree
|
||
|
title="部门列表"
|
||
|
toolbar
|
||
|
search
|
||
|
treeWrapperClassName="h-[calc(100%-35px)] overflow-auto"
|
||
|
:clickRowToExpand="false"
|
||
|
:treeData="treeData"
|
||
|
:fieldNames="{ key: 'id', title: 'name' }"
|
||
|
@select="handleSelect"
|
||
|
/>
|
||
|
</div>
|
||
|
</template>
|
||
|
<script lang="ts" setup name="DeptTree">
|
||
|
import { onMounted, ref } from 'vue'
|
||
|
|
||
|
import { BasicTree, TreeItem } from '@/components/Tree'
|
||
|
import { listSimpleDeptApi } from '@/api/system/dept'
|
||
|
import { handleTree } from '@/utils/tree'
|
||
|
|
||
|
const emit = defineEmits(['select'])
|
||
|
const treeData = ref<TreeItem[]>([])
|
||
|
|
||
|
async function fetch() {
|
||
|
const res = await listSimpleDeptApi()
|
||
|
treeData.value = handleTree(res, 'id')
|
||
|
}
|
||
|
|
||
|
function handleSelect(keys) {
|
||
|
emit('select', keys[0])
|
||
|
}
|
||
|
|
||
|
onMounted(() => {
|
||
|
fetch()
|
||
|
})
|
||
|
</script>
|