Browse Source

[SBBJ-911] 数字校验

master
zengqinyuan 2 months ago
parent
commit
5ac8ef4dac
  1. 22
      src/views/eam/basic/accountPeriod/index.vue

22
src/views/eam/basic/accountPeriod/index.vue

@ -181,13 +181,13 @@ const formsSuccess = async (formType, data) => {
} }
} }
const year = data.year; const year = data.year
const month = data.month; const month = data.month
const day = data.day; const day = data.day
const hour = data.hour; const hour = data.hour
const minute = data.minute; const minute = data.minute
if (!/^\d+$/.test(year)) { if (!/^\d+$/.test(year) && year <= 2147483647) {
message.error('账期年值为大于等于0的整数') message.error('账期年值为大于等于0且小于2147483647的整数')
return return
} }
if (!/^(1[0-2]|[1-9])$/.test(month)) { if (!/^(1[0-2]|[1-9])$/.test(month)) {
@ -200,15 +200,15 @@ const formsSuccess = async (formType, data) => {
} }
// Date01 // Date01
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) { if (!isCorrectMonth || !isDayInRange) {
message.error('账期日期不在当前月的范围内') message.error('账期日期不在当前月的范围内')
return return

Loading…
Cancel
Save