From 5ac8ef4dac22d3c08404657840e06e8ca6e7e03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E5=BA=86=E6=BA=90?= Date: Thu, 17 Apr 2025 10:33:39 +0800 Subject: [PATCH] =?UTF-8?q?[SBBJ-911]=20=E6=95=B0=E5=AD=97=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/eam/basic/accountPeriod/index.vue | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/views/eam/basic/accountPeriod/index.vue b/src/views/eam/basic/accountPeriod/index.vue index 92d497a..722fb32 100644 --- a/src/views/eam/basic/accountPeriod/index.vue +++ b/src/views/eam/basic/accountPeriod/index.vue @@ -181,13 +181,13 @@ const formsSuccess = async (formType, data) => { } } - const year = data.year; - const month = data.month; - const day = data.day; - const hour = data.hour; - const minute = data.minute; - if (!/^\d+$/.test(year)) { - message.error('账期年值为大于等于0的整数') + const year = data.year + const month = data.month + const day = data.day + const hour = data.hour + const minute = data.minute + if (!/^\d+$/.test(year) && year <= 2147483647) { + message.error('账期年值为大于等于0且小于2147483647的整数') return } if (!/^(1[0-2]|[1-9])$/.test(month)) { @@ -200,15 +200,15 @@ const formsSuccess = async (formType, data) => { } // 创建一个Date对象,注意月份是从0开始的,所以需要减1 - const date = new Date(year, month - 1, day); + const date = new Date(year, month - 1, day) // 获取该月的总天数 - const totalDaysInMonth = new Date(year, month, 0).getDate(); + const totalDaysInMonth = new Date(year, month, 0).getDate() // 检查年月是否正确 - const isCorrectMonth = date.getMonth() === (month - 1); + const isCorrectMonth = date.getMonth() === month - 1 // 检查天数是否在有效范围内 - const isDayInRange = day >= 1 && day <= totalDaysInMonth; + const isDayInRange = day >= 1 && day <= totalDaysInMonth if (!isCorrectMonth || !isDayInRange) { message.error('账期日期不在当前月的范围内') return