From da4742560e9389bbca2afebc1c3329e287614987 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Sun, 24 Jul 2022 23:34:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dlaydate=E5=87=A0=E4=B8=AA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/laydate.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 72f2ec8a..bfa37af6 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -302,9 +302,9 @@ year: tDate.getFullYear() ,month: tDate.getMonth() ,date: tDate.getDate() - ,hours: '23' - ,minutes: '59' - ,seconds: '59' + ,hours: i ? 23 : 0 + ,minutes: i ? 59 : 0 + ,seconds: i ? 59 : 0 }).getTime() ,STAMP = 86400000 //代表一天的毫秒数 ,thisDate = new Date( @@ -774,16 +774,20 @@ //如果当前日期不在设定的最大小日期区间,则自动纠正在可选区域 //校验主面板是否在可选日期区间 + var minMaxError; if(that.getDateTime(dateTime) > that.getDateTime(options.max)){ //若超出最大日期 dateTime = options.dateTime = lay.extend({}, options.max); + minMaxError = true; } else if(that.getDateTime(dateTime) < that.getDateTime(options.min)){ //若少于最小日期 dateTime = options.dateTime = lay.extend({}, options.min); + minMaxError = true; } //校验右侧面板是否在可选日期区间 if(options.range){ if(that.getDateTime(that.endDate) < that.getDateTime(options.min) || that.getDateTime(that.endDate) > that.getDateTime(options.max)){ that.endDate = lay.extend({}, options.max); + minMaxError = true; } // 有时间范围的情况下初始化startTime和endTime that.startTime = { @@ -797,7 +801,10 @@ seconds: that.endDate.seconds, } } - + + //初始值不在最大最小范围内 + minMaxError && that.setValue(that.parse()).hint('初始值' + lang.invalidDate + lang.formatError[1]); + fn && fn(); return that; };