From c66ea290eb2f9faa4688fce154433d08cb8da942 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Mon, 17 Aug 2026 12:48:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AD=BE=E7=BD=B2=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=99=9A=E4=BA=8E=E5=BD=93=E5=89=8D=E6=97=A5?= =?UTF-8?q?=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端 /sign-date 和 /paper-sign 均增加校验,签署日期晚于今天则报错。 前端日期选择器增加 max 属性限制为今天。 --- backend/src/routes/esign.routes.ts | 14 ++++++++++++++ frontend/src/pages/ESign.tsx | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/esign.routes.ts b/backend/src/routes/esign.routes.ts index e8c8b8a..9805088 100644 --- a/backend/src/routes/esign.routes.ts +++ b/backend/src/routes/esign.routes.ts @@ -221,6 +221,12 @@ router.post('/sign-date', async (req: AuthRequest, res: Response, next: NextFunc if (isNaN(parsedDate.getTime())) { return res.status(400).json({ success: false, error: { code: 'VALIDATION_ERROR', message: '签署日期格式无效' } }) } + // 签署日期不能晚于当前日期 + const today = new Date() + today.setHours(23, 59, 59, 999) + if (parsedDate > today) { + return res.status(400).json({ success: false, error: { code: 'VALIDATION_ERROR', message: '签署日期不能晚于当前日期' } }) + } // 更新合同签署日期 await prisma.laborContract.update({ where: { id: contractId }, @@ -623,6 +629,14 @@ router.post('/paper-sign', authMiddleware, async (req: AuthRequest, res: Respons return res.status(404).json({ success: false, error: { code: 'NOT_FOUND', message: '员工不存在' } }) } + // 签署日期不能晚于当前日期 + const signDate = new Date(data.signedAt) + const todayEnd = new Date() + todayEnd.setHours(23, 59, 59, 999) + if (signDate > todayEnd) { + return res.status(400).json({ success: false, error: { code: 'VALIDATION_ERROR', message: '签署日期不能晚于当前日期' } }) + } + // 创建签署记录(线下手签直接为 COMPLETED 状态) const record = await prisma.eSignRecord.create({ data: { diff --git a/frontend/src/pages/ESign.tsx b/frontend/src/pages/ESign.tsx index 89604b4..e151f1c 100644 --- a/frontend/src/pages/ESign.tsx +++ b/frontend/src/pages/ESign.tsx @@ -528,7 +528,7 @@ function PaperSignModal({ onClose, onSuccess, initialEmployeeId, initialScene, i
- setForm({ ...form, signedAt: e.target.value })} /> + setForm({ ...form, signedAt: e.target.value })} />
@@ -935,6 +935,7 @@ function PendingTab({ pendingList, loading, onRemind, remindLoading, remindData, <> setSignDateValue(e.target.value)} className="h-7 px-2 text-xs border rounded"