Industrial-image-management.../src/hooks/app/usePost.ts

29 lines
676 B
TypeScript
Raw Normal View History

2025-07-30 09:13:52 +08:00
import { listPost } from '@/apis/system/post'
import type { PostVO } from '@/apis/system/type'
export function usePost() {
const postList = ref<{ label: string; value: string }[]>([])
const loading = ref(false)
// 获取岗位列表
const getPostList = async () => {
try {
loading.value = true
const { data } = await listPost()
postList.value = (data || []).map((post: PostVO) => ({
label: post.postName,
value: post.postId,
}))
} catch (error) {
console.error('获取岗位列表失败:', error)
} finally {
loading.value = false
}
}
return {
postList,
loading,
getPostList
}
}