fix: 待办跳转修复 — 1)actionUrl从/contracts改为/roster(无此路由) 2)Roster页面读取employee参数自动搜索并打开员工详情 3)更新数据库281条已有riskItem的actionUrl
This commit is contained in:
@@ -167,7 +167,7 @@ export async function detectContractRisks(orgId: string) {
|
|||||||
level: 'HIGH',
|
level: 'HIGH',
|
||||||
title: `${emp.name}入职${Math.round(days / 30)}个月未签合同,已视为无固定期限`,
|
title: `${emp.name}入职${Math.round(days / 30)}个月未签合同,已视为无固定期限`,
|
||||||
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},超过1年未签订书面合同,法律上已视为无固定期限劳动合同。`,
|
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},超过1年未签订书面合同,法律上已视为无固定期限劳动合同。`,
|
||||||
actionUrl: `/contracts?employee=${encodeURIComponent(emp.name)}`,
|
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||||
})
|
})
|
||||||
} else if (days > 30) {
|
} else if (days > 30) {
|
||||||
risks.push({
|
risks.push({
|
||||||
@@ -176,7 +176,7 @@ export async function detectContractRisks(orgId: string) {
|
|||||||
level: 'HIGH',
|
level: 'HIGH',
|
||||||
title: `${emp.name}入职${Math.round(days / 30)}个月未签合同`,
|
title: `${emp.name}入职${Math.round(days / 30)}个月未签合同`,
|
||||||
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},超过30天未签订书面合同,需尽快补签。`,
|
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},超过30天未签订书面合同,需尽快补签。`,
|
||||||
actionUrl: `/contracts?employee=${encodeURIComponent(emp.name)}`,
|
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
risks.push({
|
risks.push({
|
||||||
@@ -185,7 +185,7 @@ export async function detectContractRisks(orgId: string) {
|
|||||||
level: 'LOW',
|
level: 'LOW',
|
||||||
title: `${emp.name}入职${Math.round(days / 30)}个月,尚未签合同`,
|
title: `${emp.name}入职${Math.round(days / 30)}个月,尚未签合同`,
|
||||||
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},30天内需签订书面合同。`,
|
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},30天内需签订书面合同。`,
|
||||||
actionUrl: `/contracts?employee=${encodeURIComponent(emp.name)}`,
|
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -200,7 +200,7 @@ export async function detectContractRisks(orgId: string) {
|
|||||||
level: 'HIGH',
|
level: 'HIGH',
|
||||||
title: `${emp.name}的合同已到期${Math.abs(daysToExpire)}天未续签`,
|
title: `${emp.name}的合同已到期${Math.abs(daysToExpire)}天未续签`,
|
||||||
description: `合同到期日 ${latestContract.endDate.toISOString().slice(0, 10)},已过期未续签。`,
|
description: `合同到期日 ${latestContract.endDate.toISOString().slice(0, 10)},已过期未续签。`,
|
||||||
actionUrl: `/contracts?employee=${encodeURIComponent(emp.name)}`,
|
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||||
})
|
})
|
||||||
} else if (daysToExpire <= 30) {
|
} else if (daysToExpire <= 30) {
|
||||||
risks.push({
|
risks.push({
|
||||||
@@ -209,7 +209,7 @@ export async function detectContractRisks(orgId: string) {
|
|||||||
level: 'MEDIUM',
|
level: 'MEDIUM',
|
||||||
title: `${emp.name}的合同即将到期(${daysToExpire}天)`,
|
title: `${emp.name}的合同即将到期(${daysToExpire}天)`,
|
||||||
description: `合同到期日 ${latestContract.endDate.toISOString().slice(0, 10)},需提前准备续签或终止。`,
|
description: `合同到期日 ${latestContract.endDate.toISOString().slice(0, 10)},需提前准备续签或终止。`,
|
||||||
actionUrl: `/contracts?employee=${encodeURIComponent(emp.name)}`,
|
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ export async function detectContractRisks(orgId: string) {
|
|||||||
level: 'MEDIUM',
|
level: 'MEDIUM',
|
||||||
title: `${emp.name}试用期${latestContract.probationMonths}个月可能不合法`,
|
title: `${emp.name}试用期${latestContract.probationMonths}个月可能不合法`,
|
||||||
description: `${contractMonths}个月合同试用期最多${maxProbation}个月,当前${latestContract.probationMonths}个月超出法定上限。`,
|
description: `${contractMonths}个月合同试用期最多${maxProbation}个月,当前${latestContract.probationMonths}个月超出法定上限。`,
|
||||||
actionUrl: `/contracts?employee=${encodeURIComponent(emp.name)}`,
|
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useState, useMemo } from 'react'
|
import { useState, useMemo, useEffect } from 'react'
|
||||||
|
import { useSearchParams } from 'react-router-dom'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useConfirm } from '../hooks/useConfirm'
|
import { useConfirm } from '../hooks/useConfirm'
|
||||||
@@ -20,6 +21,7 @@ import { ImportSettings } from './Settings'
|
|||||||
export default function Roster() {
|
export default function Roster() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const confirm = useConfirm()
|
const confirm = useConfirm()
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
const [selectedId, setSelectedId] = useState<string | null>(null)
|
const [selectedId, setSelectedId] = useState<string | null>(null)
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
const debouncedSearch = useDebouncedValue(search, 300)
|
const debouncedSearch = useDebouncedValue(search, 300)
|
||||||
@@ -67,6 +69,18 @@ export default function Roster() {
|
|||||||
})
|
})
|
||||||
const pagination = rosterData?.pagination || { page, pageSize, total: 0, totalPages: 0 }
|
const pagination = rosterData?.pagination || { page, pageSize, total: 0, totalPages: 0 }
|
||||||
|
|
||||||
|
// 从 URL query 参数自动定位员工(从待办跳转时)
|
||||||
|
useEffect(() => {
|
||||||
|
const emp = searchParams.get('employee')
|
||||||
|
if (emp) {
|
||||||
|
setSearch(emp)
|
||||||
|
// 搜索结果加载后自动打开第一个匹配的员工
|
||||||
|
if (!isLoading && employees.length > 0 && !selectedId) {
|
||||||
|
setSelectedId(employees[0].id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [searchParams, isLoading, employees, selectedId])
|
||||||
|
|
||||||
const addMutation = useMutation({
|
const addMutation = useMutation({
|
||||||
mutationFn: (data: any) => api.post('/employees', data),
|
mutationFn: (data: any) => api.post('/employees', data),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user