30 lines
677 B
TypeScript
30 lines
677 B
TypeScript
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,
|
|
}
|
|
}
|