mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2026-01-16 22:57:16 +08:00
first commit
This commit is contained in:
21
src/hooks/app/useDept.ts
Normal file
21
src/hooks/app/useDept.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ref } from 'vue'
|
||||
import { listDeptTree } from '@/apis'
|
||||
import type { TreeNodeData } from '@arco-design/web-vue'
|
||||
|
||||
/** 部门模块 */
|
||||
export function useDept(options?: { onSuccess?: () => void }) {
|
||||
const loading = ref(false)
|
||||
const deptList = ref<TreeNodeData[]>([])
|
||||
|
||||
const getDeptList = async (name?: string) => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await listDeptTree({ description: name })
|
||||
deptList.value = res.data
|
||||
options?.onSuccess && options.onSuccess()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
return { deptList, getDeptList, loading }
|
||||
}
|
||||
Reference in New Issue
Block a user