2
0
Эх сурвалжийг харах

feat(talent-detail): 添加完整工作历史查询功能

- 在人才详情页添加获取完整工作历史的查询
- 使用企业专用工作历史API:/api/v1/yongren/disability-person/{id}/work-history
- 按入职日期降序排序工作历史记录
- 更新加载状态包含新查询

🤖 Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 4 долоо хоног өмнө
parent
commit
d6aa97a0f2

+ 27 - 1
mini-ui-packages/yongren-talent-management-ui/src/pages/TalentDetail/TalentDetail.tsx

@@ -140,6 +140,32 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
     enabled: isLoggedIn && talentId > 0
   })
 
+  // 获取完整工作历史 - 用于时间线展示
+  const { data: workHistoryFull, isLoading: workHistoryLoading } = useQuery({
+    queryKey: ['workHistoryFull', talentId],
+    queryFn: async () => {
+      if (!talentId) throw new Error('无效的人才ID')
+      // 使用企业专用工作历史API:/api/v1/yongren/disability-person/{id}/work-history
+      const response = await enterpriseDisabilityClient[':id']['work-history'].$get({
+        param: { id: talentId.toString() }
+      })
+      if (response.status !== 200) {
+        // 可能没有工作信息,返回空数组
+        return [] as WorkHistoryItem[]
+      }
+      const data = await response.json() as WorkHistoryResponse
+      // 企业专用工作历史API返回的是工作历史列表
+      const workHistory = data?.工作历史 || []
+      // 按入职日期降序排序(最新的在前)
+      return workHistory.sort((a, b) => {
+        const dateA = a.入职日期 ? new Date(a.入职日期).getTime() : 0
+        const dateB = b.入职日期 ? new Date(b.入职日期).getTime() : 0
+        return dateB - dateA
+      })
+    },
+    enabled: isLoggedIn && talentId > 0
+  })
+
   // 获取薪资信息 - 使用企业专用薪资历史API
   const { data: salaryInfo, isLoading: salaryLoading } = useQuery({
     queryKey: ['salaryInfo', talentId],
@@ -236,7 +262,7 @@ const TalentDetail: React.FC<TalentDetailProps> = () => {
     })
   }, [])
 
-  const isLoading = talentLoading || workLoading || salaryLoading || filesLoading || historyLoading
+  const isLoading = talentLoading || workLoading || salaryLoading || filesLoading || historyLoading || workHistoryLoading
   const hasError = talentError
 
   // 获取头像颜色