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 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) => {
}
// 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) {
message.error('账期日期不在当前月的范围内')
return

Loading…
Cancel
Save