fix: 待办时长格式统一 — 不足30天用天,超过30天用月+天
This commit is contained in:
@@ -145,6 +145,16 @@ function calcPriority(
|
||||
return 'LOW'
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时长:不足30天用"X天",超过30天用"X个月Y天"
|
||||
*/
|
||||
function formatDuration(days: number): string {
|
||||
if (days < 30) return `${days}天`
|
||||
const months = Math.floor(days / 30)
|
||||
const remainDays = days % 30
|
||||
return remainDays === 0 ? `${months}个月` : `${months}个月${remainDays}天`
|
||||
}
|
||||
|
||||
export async function detectContractRisks(orgId: string) {
|
||||
const today = new Date()
|
||||
today.setHours(0, 0, 0, 0)
|
||||
@@ -165,7 +175,7 @@ export async function detectContractRisks(orgId: string) {
|
||||
employeeId: emp.id,
|
||||
type: 'CONTRACT',
|
||||
level: 'HIGH',
|
||||
title: `${emp.name}入职${Math.round(days / 30)}个月未签合同,已视为无固定期限`,
|
||||
title: `${emp.name}入职${formatDuration(days)}未签合同,已视为无固定期限`,
|
||||
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},超过1年未签订书面合同,法律上已视为无固定期限劳动合同。`,
|
||||
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||
})
|
||||
@@ -174,7 +184,7 @@ export async function detectContractRisks(orgId: string) {
|
||||
employeeId: emp.id,
|
||||
type: 'CONTRACT',
|
||||
level: 'HIGH',
|
||||
title: `${emp.name}入职${Math.round(days / 30)}个月未签合同`,
|
||||
title: `${emp.name}入职${formatDuration(days)}未签合同`,
|
||||
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},超过30天未签订书面合同,需尽快补签。`,
|
||||
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||
})
|
||||
@@ -183,7 +193,7 @@ export async function detectContractRisks(orgId: string) {
|
||||
employeeId: emp.id,
|
||||
type: 'CONTRACT',
|
||||
level: 'LOW',
|
||||
title: `${emp.name}入职${Math.round(days / 30)}个月,尚未签合同`,
|
||||
title: `${emp.name}入职${formatDuration(days)},尚未签合同`,
|
||||
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},30天内需签订书面合同。`,
|
||||
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||
})
|
||||
@@ -266,7 +276,7 @@ export async function detectOnboardingRisks(orgId: string) {
|
||||
employeeId: emp.id,
|
||||
type: 'ONBOARDING',
|
||||
level: daysSinceHire > 30 ? 'HIGH' : 'MEDIUM',
|
||||
title: `${emp.name}入职手续未完成${daysSinceHire > 30 ? `(已超${Math.round(daysSinceHire / 30)}个月)` : ''}`,
|
||||
title: `${emp.name}入职手续未完成${daysSinceHire > 30 ? `(已超${formatDuration(Math.round(daysSinceHire))})` : ''}`,
|
||||
description: `入职日期 ${emp.hireDate.toISOString().slice(0, 10)},尚未签订劳动合同,请尽快完成入职手续。`,
|
||||
actionUrl: `/roster?employee=${encodeURIComponent(emp.name)}`,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user