Files
wms-ui/src/hooks/app/useBranch.ts
2026-02-26 17:31:18 +08:00

23 lines
680 B
TypeScript

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