From d9e2c610cf5b755cb87a866962353109cfb8da07 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Sat, 1 Aug 2026 08:24:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BE=85=E5=8A=9E=E6=97=B6=E9=95=BF?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=BB=9F=E4=B8=80=20=E2=80=94=20=E4=B8=8D?= =?UTF-8?q?=E8=B6=B330=E5=A4=A9=E7=94=A8=E5=A4=A9=EF=BC=8C=E8=B6=85?= =?UTF-8?q?=E8=BF=8730=E5=A4=A9=E7=94=A8=E6=9C=88+=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/services/risk.service.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/src/services/risk.service.ts b/backend/src/services/risk.service.ts index 1e8da3f..127e8b2 100644 --- a/backend/src/services/risk.service.ts +++ b/backend/src/services/risk.service.ts @@ -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)}`, })