|
@@ -37,27 +37,69 @@ const YongrenDashboardPage: React.FC = () => {
|
|
|
useRequireAuth()
|
|
useRequireAuth()
|
|
|
|
|
|
|
|
// 获取企业概览数据
|
|
// 获取企业概览数据
|
|
|
- const { data: overview, isLoading: overviewLoading } = useQuery({
|
|
|
|
|
|
|
+ const { data: overview, isLoading: _overviewLoading } = useQuery({
|
|
|
queryKey: ['enterpriseOverview'],
|
|
queryKey: ['enterpriseOverview'],
|
|
|
queryFn: async () => {
|
|
queryFn: async () => {
|
|
|
- const response = await enterpriseCompanyClient.overview.get()
|
|
|
|
|
|
|
+ const response = await enterpriseCompanyClient.overview.$get()
|
|
|
if (response.status !== 200) {
|
|
if (response.status !== 200) {
|
|
|
throw new Error('获取企业概览数据失败')
|
|
throw new Error('获取企业概览数据失败')
|
|
|
}
|
|
}
|
|
|
- return await response.json() as OverviewData
|
|
|
|
|
|
|
+ const data = await response.json()
|
|
|
|
|
+ // 转换为OverviewData接口
|
|
|
|
|
+ return {
|
|
|
|
|
+ totalEmployees: data.在职人员数,
|
|
|
|
|
+ pendingAssignments: data.进行中订单数,
|
|
|
|
|
+ monthlyOrders: data.已完成订单数,
|
|
|
|
|
+ companyName: data.companyName || '企业名称'
|
|
|
|
|
+ } as OverviewData
|
|
|
},
|
|
},
|
|
|
refetchOnWindowFocus: false
|
|
refetchOnWindowFocus: false
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ // 将API人才数据转换为前端AllocationData接口
|
|
|
|
|
+ const convertTalentToAllocation = (talent: any): AllocationData => {
|
|
|
|
|
+ // 根据personId生成稳定的颜色
|
|
|
|
|
+ const colors: Array<'blue' | 'green' | 'purple' | 'orange'> = ['blue', 'green', 'purple', 'orange']
|
|
|
|
|
+ const colorIndex = talent.personId ? talent.personId % colors.length : 0
|
|
|
|
|
+ const avatarColor = colors[colorIndex]
|
|
|
|
|
+
|
|
|
|
|
+ // 工作状态映射:working -> 在职, on_leave -> 待入职, left -> 离职
|
|
|
|
|
+ const statusMap: Record<string, '在职' | '待入职' | '离职'> = {
|
|
|
|
|
+ 'working': '在职',
|
|
|
|
|
+ 'on_leave': '待入职',
|
|
|
|
|
+ 'left': '离职'
|
|
|
|
|
+ }
|
|
|
|
|
+ const status = statusMap[talent.workStatus] || '在职'
|
|
|
|
|
+
|
|
|
|
|
+ // 格式化日期
|
|
|
|
|
+ const joinDate = talent.joinDate ? new Date(talent.joinDate).toLocaleDateString('zh-CN') : '未知'
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: talent.personId?.toString() || '0',
|
|
|
|
|
+ name: talent.personName || '未知姓名',
|
|
|
|
|
+ avatarColor,
|
|
|
|
|
+ disabilityType: '肢体残疾', // 暂时使用默认值,后续可从其他API获取
|
|
|
|
|
+ disabilityLevel: '三级', // 暂时使用默认值
|
|
|
|
|
+ status,
|
|
|
|
|
+ joinDate,
|
|
|
|
|
+ salary: 4500, // 暂时使用默认薪资
|
|
|
|
|
+ progress: 75 // 暂时使用默认进度
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 获取近期分配人才列表
|
|
// 获取近期分配人才列表
|
|
|
const { data: allocations, isLoading: allocationsLoading } = useQuery({
|
|
const { data: allocations, isLoading: allocationsLoading } = useQuery({
|
|
|
queryKey: ['recentAllocations'],
|
|
queryKey: ['recentAllocations'],
|
|
|
queryFn: async () => {
|
|
queryFn: async () => {
|
|
|
- const response = await enterpriseCompanyClient.allocations.recent.get()
|
|
|
|
|
|
|
+ const response = await enterpriseCompanyClient.allocations.recent.$get({
|
|
|
|
|
+ query: { limit: 5 } // 获取5条记录,dashboard只显示前2条
|
|
|
|
|
+ })
|
|
|
if (response.status !== 200) {
|
|
if (response.status !== 200) {
|
|
|
throw new Error('获取分配人才列表失败')
|
|
throw new Error('获取分配人才列表失败')
|
|
|
}
|
|
}
|
|
|
- return await response.json() as AllocationData[]
|
|
|
|
|
|
|
+ const data = await response.json()
|
|
|
|
|
+ // 转换数据格式
|
|
|
|
|
+ return data.人才列表.map(convertTalentToAllocation)
|
|
|
},
|
|
},
|
|
|
refetchOnWindowFocus: false
|
|
refetchOnWindowFocus: false
|
|
|
})
|
|
})
|
|
@@ -82,7 +124,7 @@ const YongrenDashboardPage: React.FC = () => {
|
|
|
})
|
|
})
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
- const isLoading = overviewLoading || allocationsLoading
|
|
|
|
|
|
|
+ // const isLoading = overviewLoading || allocationsLoading // 未使用
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<YongrenTabBarLayout activeKey="dashboard">
|
|
<YongrenTabBarLayout activeKey="dashboard">
|
|
@@ -99,7 +141,7 @@ const YongrenDashboardPage: React.FC = () => {
|
|
|
<View>
|
|
<View>
|
|
|
<Text className="text-sm opacity-80">欢迎回来</Text>
|
|
<Text className="text-sm opacity-80">欢迎回来</Text>
|
|
|
<Text className="text-xl font-bold">
|
|
<Text className="text-xl font-bold">
|
|
|
- {overview?.companyName || user?.companyName || '企业名称'}
|
|
|
|
|
|
|
+ {overview?.companyName || user?.name || '企业名称'}
|
|
|
</Text>
|
|
</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className="w-12 h-12 rounded-full bg-white/20 flex items-center justify-center">
|
|
<View className="w-12 h-12 rounded-full bg-white/20 flex items-center justify-center">
|