|
|
@@ -4,30 +4,44 @@ import Taro from '@tarojs/taro'
|
|
|
import { useQuery } from '@tanstack/react-query'
|
|
|
import YongrenTabBarLayout from '@/layouts/yongren-tab-bar-layout'
|
|
|
import PageContainer from '@/components/ui/page-container'
|
|
|
-import { enterpriseDisabilityClient, orderClient, salaryClient, fileClient } from '@/api'
|
|
|
+import { enterpriseDisabilityClient } from '@/api'
|
|
|
import { useRequireAuth } from '@/hooks/useRequireAuth'
|
|
|
import './index.css'
|
|
|
|
|
|
-// 类型定义
|
|
|
+// 类型定义 - 匹配企业专用人才详情API的CompanyPersonDetailSchema
|
|
|
interface TalentDetailData {
|
|
|
- id: number
|
|
|
+ personId: number
|
|
|
name: string
|
|
|
gender: string
|
|
|
- idCard?: string
|
|
|
- disabilityId?: string
|
|
|
- disabilityType?: string
|
|
|
- disabilityLevel?: string
|
|
|
- idAddress?: string
|
|
|
- phone?: string
|
|
|
- province?: string
|
|
|
- city?: string
|
|
|
- age?: number
|
|
|
- status?: '在职' | '待入职' | '离职'
|
|
|
- joinDate?: string
|
|
|
- salary?: number
|
|
|
- companyId?: number
|
|
|
+ idCard: string
|
|
|
+ disabilityType: string
|
|
|
+ disabilityLevel: string
|
|
|
birthDate?: string
|
|
|
- specificDisability?: string
|
|
|
+ phone?: string
|
|
|
+ jobStatus: string
|
|
|
+ bankCards: Array<{
|
|
|
+ cardId: number
|
|
|
+ bankName: string
|
|
|
+ cardNumber: string
|
|
|
+ isDefault: boolean
|
|
|
+ }>
|
|
|
+ photos: Array<{
|
|
|
+ fileId: number
|
|
|
+ fileName: string
|
|
|
+ fileUrl: string
|
|
|
+ }>
|
|
|
+ // 兼容字段
|
|
|
+ id?: number // 兼容旧代码,映射personId
|
|
|
+ status?: string // 兼容旧代码,映射jobStatus
|
|
|
+ age?: number // 根据birthDate计算
|
|
|
+ idAddress?: string // 可能来自其他API
|
|
|
+ province?: string // 可能来自其他API
|
|
|
+ city?: string // 可能来自其他API
|
|
|
+ joinDate?: string // 可能来自工作信息API
|
|
|
+ salary?: number // 可能来自薪资信息API
|
|
|
+ companyId?: number // 可能来自其他API
|
|
|
+ disabilityId?: string // 可能来自其他API
|
|
|
+ specificDisability?: string // 可能来自其他API
|
|
|
[key: string]: any
|
|
|
}
|
|
|
|
|
|
@@ -64,6 +78,47 @@ interface FileData {
|
|
|
[key: string]: any
|
|
|
}
|
|
|
|
|
|
+// 企业专用API响应类型
|
|
|
+interface WorkHistoryItem {
|
|
|
+ 订单ID: number
|
|
|
+ 订单名称: string | null
|
|
|
+ 入职日期: string | null
|
|
|
+ 实际入职日期: string | null
|
|
|
+ 离职日期: string | null
|
|
|
+ 工作状态: string
|
|
|
+ 个人薪资: number
|
|
|
+}
|
|
|
+
|
|
|
+interface WorkHistoryResponse {
|
|
|
+ 工作历史: WorkHistoryItem[]
|
|
|
+}
|
|
|
+
|
|
|
+interface SalaryHistoryItem {
|
|
|
+ 月份: string | null
|
|
|
+ 基本工资: number
|
|
|
+ 补贴: number
|
|
|
+ 扣款: number
|
|
|
+ 实发工资: number
|
|
|
+}
|
|
|
+
|
|
|
+interface SalaryHistoryResponse {
|
|
|
+ 薪资历史: SalaryHistoryItem[]
|
|
|
+}
|
|
|
+
|
|
|
+interface CreditInfoItem {
|
|
|
+ 文件ID: string
|
|
|
+ 文件URL: string | null
|
|
|
+ 上传时间: string | null
|
|
|
+ 文件类型: string | null
|
|
|
+ 银行卡号: string | null
|
|
|
+ 持卡人姓名: string | null
|
|
|
+ 银行名称: number | null
|
|
|
+}
|
|
|
+
|
|
|
+interface CreditInfoResponse {
|
|
|
+ 征信信息: CreditInfoItem[]
|
|
|
+}
|
|
|
+
|
|
|
const YongrenTalentDetailPage: React.FC = () => {
|
|
|
const { isLoggedIn } = useRequireAuth()
|
|
|
const router = Taro.useRouter()
|
|
|
@@ -74,95 +129,145 @@ const YongrenTalentDetailPage: React.FC = () => {
|
|
|
queryKey: ['talentDetail', talentId],
|
|
|
queryFn: async () => {
|
|
|
if (!talentId) throw new Error('无效的人才ID')
|
|
|
- const response = await enterpriseDisabilityClient['{id}'].$get({
|
|
|
+ const response = await enterpriseDisabilityClient[':id'].$get({
|
|
|
param: { id: talentId.toString() }
|
|
|
})
|
|
|
if (response.status !== 200) {
|
|
|
throw new Error('获取人才详情失败')
|
|
|
}
|
|
|
const data = await response.json() as TalentDetailData
|
|
|
- return data
|
|
|
+ // 添加兼容字段映射
|
|
|
+ return {
|
|
|
+ ...data,
|
|
|
+ id: data.personId, // 映射id字段
|
|
|
+ status: data.jobStatus, // 映射status字段
|
|
|
+ // 计算年龄
|
|
|
+ age: data.birthDate ? Math.floor((Date.now() - new Date(data.birthDate).getTime()) / (1000 * 60 * 60 * 24 * 365.25)) : undefined
|
|
|
+ }
|
|
|
},
|
|
|
enabled: isLoggedIn && talentId > 0
|
|
|
})
|
|
|
|
|
|
- // 获取工作信息
|
|
|
+ // 获取工作信息 - 使用企业专用工作历史API
|
|
|
const { data: workInfo, isLoading: workLoading } = useQuery({
|
|
|
queryKey: ['workInfo', talentId],
|
|
|
queryFn: async () => {
|
|
|
if (!talentId) throw new Error('无效的人才ID')
|
|
|
- // 根据API规范,路径为:/api/v1/order/person/{person_id}
|
|
|
- const response = await orderClient['person/{person_id}'].$get({
|
|
|
- param: { person_id: talentId.toString() }
|
|
|
+ // 使用企业专用工作历史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 WorkInfoData
|
|
|
}
|
|
|
- const data = await response.json() as WorkInfoData
|
|
|
- return data
|
|
|
+ const data = await response.json() as WorkHistoryResponse
|
|
|
+ // 企业专用工作历史API返回的是工作历史列表,取最新的一条作为当前工作信息
|
|
|
+ const workHistory = data?.工作历史 || []
|
|
|
+ if (workHistory.length === 0) {
|
|
|
+ return {} as WorkInfoData
|
|
|
+ }
|
|
|
+ // 取最新的一条工作记录(按入职日期降序)
|
|
|
+ const latestWork = workHistory[0]
|
|
|
+ return {
|
|
|
+ id: latestWork.订单ID || talentId,
|
|
|
+ orderId: latestWork.订单ID,
|
|
|
+ position: latestWork.订单名称 || undefined,
|
|
|
+ department: undefined, // 企业专用API没有部门字段
|
|
|
+ startDate: latestWork.入职日期 || undefined,
|
|
|
+ endDate: latestWork.离职日期 || undefined,
|
|
|
+ status: latestWork.工作状态,
|
|
|
+ companyId: undefined // 企业专用API没有公司ID字段
|
|
|
+ } as WorkInfoData
|
|
|
},
|
|
|
enabled: isLoggedIn && talentId > 0
|
|
|
})
|
|
|
|
|
|
- // 获取薪资信息
|
|
|
+ // 获取薪资信息 - 使用企业专用薪资历史API
|
|
|
const { data: salaryInfo, isLoading: salaryLoading } = useQuery({
|
|
|
queryKey: ['salaryInfo', talentId],
|
|
|
queryFn: async () => {
|
|
|
if (!talentId) throw new Error('无效的人才ID')
|
|
|
- // 根据API规范,路径为:/api/v1/salary/person/{person_id}
|
|
|
- const response = await salaryClient['person/{person_id}'].$get({
|
|
|
- param: { person_id: talentId.toString() }
|
|
|
+ // 使用企业专用薪资历史API:/api/v1/yongren/disability-person/{id}/salary-history
|
|
|
+ const response = await enterpriseDisabilityClient[':id']['salary-history'].$get({
|
|
|
+ param: { id: talentId.toString() }
|
|
|
})
|
|
|
if (response.status !== 200) {
|
|
|
// 可能没有薪资信息,返回空对象
|
|
|
return {} as SalaryData
|
|
|
}
|
|
|
- const data = await response.json() as SalaryData
|
|
|
- return data
|
|
|
+ const data = await response.json() as SalaryHistoryResponse
|
|
|
+ // 企业专用薪资历史API返回结构:{ 薪资历史: [...] }
|
|
|
+ const salaryHistory = data?.薪资历史 || []
|
|
|
+ if (salaryHistory.length === 0) {
|
|
|
+ return {} as SalaryData
|
|
|
+ }
|
|
|
+ // 取最新的一条薪资记录(按月份降序)
|
|
|
+ const latestSalary = salaryHistory[0]
|
|
|
+ return {
|
|
|
+ id: talentId,
|
|
|
+ personId: talentId,
|
|
|
+ amount: latestSalary.实发工资 || latestSalary.基本工资,
|
|
|
+ paymentDate: latestSalary.月份 || undefined,
|
|
|
+ type: '月薪', // 默认类型
|
|
|
+ period: '月度' // 默认周期
|
|
|
+ } as SalaryData
|
|
|
},
|
|
|
enabled: isLoggedIn && talentId > 0
|
|
|
})
|
|
|
|
|
|
- // 获取薪资历史记录
|
|
|
+ // 获取薪资历史记录 - 使用企业专用薪资历史API
|
|
|
const { data: salaryHistory, isLoading: historyLoading } = useQuery({
|
|
|
queryKey: ['salaryHistory', talentId],
|
|
|
queryFn: async () => {
|
|
|
if (!talentId) throw new Error('无效的人才ID')
|
|
|
- // 根据API规范,路径为:/api/v1/salary/history/{person_id}
|
|
|
- const response = await salaryClient['history/{person_id}'].$get({
|
|
|
- param: { person_id: talentId.toString() },
|
|
|
- query: {
|
|
|
- start_date: '2024-01-01', // 默认开始日期
|
|
|
- end_date: new Date().toISOString().split('T')[0] // 今天
|
|
|
- }
|
|
|
+ // 使用企业专用薪资历史API:/api/v1/yongren/disability-person/{id}/salary-history
|
|
|
+ const response = await enterpriseDisabilityClient[':id']['salary-history'].$get({
|
|
|
+ param: { id: talentId.toString() }
|
|
|
})
|
|
|
if (response.status !== 200) {
|
|
|
return [] as SalaryData[]
|
|
|
}
|
|
|
- const result = await response.json() as any
|
|
|
- return (result?.data || []) as SalaryData[]
|
|
|
+ const data = await response.json() as SalaryHistoryResponse
|
|
|
+ // 企业专用薪资历史API返回结构:{ 薪资历史: [...] }
|
|
|
+ const salaryHistoryData = data?.薪资历史 || []
|
|
|
+ // 转换为SalaryData数组
|
|
|
+ return salaryHistoryData.map((item: SalaryHistoryItem, index: number) => ({
|
|
|
+ id: index + 1,
|
|
|
+ personId: talentId,
|
|
|
+ amount: item.实发工资 || item.基本工资,
|
|
|
+ paymentDate: item.月份 || undefined,
|
|
|
+ type: '月薪', // 默认类型
|
|
|
+ period: '月度' // 默认周期
|
|
|
+ })) as SalaryData[]
|
|
|
},
|
|
|
enabled: isLoggedIn && talentId > 0
|
|
|
})
|
|
|
|
|
|
- // 获取个人征信文件
|
|
|
+ // 获取个人征信文件 - 使用企业专用征信信息API
|
|
|
const { data: creditFiles, isLoading: filesLoading } = useQuery({
|
|
|
queryKey: ['creditFiles', talentId],
|
|
|
queryFn: async () => {
|
|
|
if (!talentId) throw new Error('无效的人才ID')
|
|
|
- // 根据API规范,路径为:/api/v1/file/list
|
|
|
- const response = await fileClient.$get({
|
|
|
- query: {
|
|
|
- relation_type: 'disabled_person',
|
|
|
- relation_id: talentId.toString()
|
|
|
- } as any // 类型断言,因为TypeScript类型定义可能不完整
|
|
|
+ // 使用企业专用征信信息API:/api/v1/yongren/disability-person/{id}/credit-info
|
|
|
+ const response = await enterpriseDisabilityClient[':id']['credit-info'].$get({
|
|
|
+ param: { id: talentId.toString() }
|
|
|
})
|
|
|
if (response.status !== 200) {
|
|
|
return [] as FileData[]
|
|
|
}
|
|
|
- const result = await response.json() as any
|
|
|
- return (result?.data || []) as FileData[]
|
|
|
+ const data = await response.json() as CreditInfoResponse
|
|
|
+ // 企业专用征信信息API返回结构:{ 征信信息: [...] }
|
|
|
+ const creditInfoList = data?.征信信息 || []
|
|
|
+ // 转换为FileData数组
|
|
|
+ return creditInfoList.map((item: CreditInfoItem) => ({
|
|
|
+ id: item.文件ID || '',
|
|
|
+ name: item.银行卡号 ? `银行卡 ${item.银行卡号}` : item.持卡人姓名 ? `征信文件 - ${item.持卡人姓名}` : '征信文件',
|
|
|
+ url: item.文件URL || undefined,
|
|
|
+ size: undefined, // 征信信息API不返回文件大小
|
|
|
+ type: item.文件类型 || undefined,
|
|
|
+ createdAt: item.上传时间 || undefined
|
|
|
+ })) as FileData[]
|
|
|
},
|
|
|
enabled: isLoggedIn && talentId > 0
|
|
|
})
|