23 lines
669 B
TypeScript
23 lines
669 B
TypeScript
import { ref } from 'vue'
|
|
import type { TreeNodeData } from '@arco-design/web-vue'
|
|
import { listSpaceTree } from '@/apis'
|
|
|
|
/** 部门模块 */
|
|
export function space(options?: { onSuccess?: () => void }) {
|
|
const loading = ref(false)
|
|
const spaceList = ref<TreeNodeData[]>([])
|
|
|
|
const getSpaceList = async (name?: string) => {
|
|
try {
|
|
loading.value = true
|
|
const res = await listSpaceTree({ description: name })
|
|
spaceList.value = res.data
|
|
// eslint-disable-next-line ts/no-unused-expressions
|
|
options?.onSuccess && options.onSuccess()
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
return { spaceList, getSpaceList, loading }
|
|
}
|