From 2fba280516b52f5c39886769f4c5241e8d4b9ddf Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Mon, 12 Dec 2022 12:20:57 +0800 Subject: [PATCH] =?UTF-8?q?laydate=E4=BF=AE=E5=A4=8D=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=97=A5=E5=8E=86=E9=9D=A2=E6=9D=BF=E5=A4=B4=E9=83=A8=E7=9A=84?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=9C=88=E4=B8=8A=E4=B8=8B=E5=B9=B4=E6=88=96?= =?UTF-8?q?=E8=80=85=E9=80=89=E6=8B=A9=E5=B9=B4=E6=9C=88=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=97=A5=E5=8E=86=E7=9B=B4=E6=8E=A5=E7=A1=AE=E8=AE=A4=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E8=B7=B3=E8=BD=AC=E5=88=B0=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=9A=84=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 | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 73f8f297..68566abf 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -977,7 +977,7 @@ that.startDate = that.startDate || value && lay.extend({}, options.dateTime); // 有默认值才初始化startDate that.autoCalendarModel.auto && that.autoCalendarModel(); - that.endState = !that.rangeLinked || !!(that.startDate && that.endDate); // 初始化选中范围状态 + that.endState = !options.range || !that.rangeLinked || !!(that.startDate && that.endDate); // 初始化选中范围状态 fn && fn(); return that; @@ -1401,7 +1401,6 @@ } } else { that.checkDate('limit').calendar(dateTime, index, 'init'); // 重新渲染一下两个面板 - that.rangeLinked || that.choose(lay(elemCont).find('td.layui-this'), index); that.closeList(); } @@ -1415,8 +1414,8 @@ that.setValue(that.parse()).done().remove(); } } - - that.done(null, 'change'); + + (that.autoCalendarModel.auto && !that.rangeLinked) ? that.choose(lay(elemCont).find('td.layui-this'), index) : (that.endState && that.done(null, 'change')); lay(that.footer).find('.'+ ELEM_TIME_BTN).removeClass(DISABLED); }); } else { //时间选择面板 - 选择事件 @@ -1946,8 +1945,8 @@ } else { dateTime.year--; that.checkDate('limit').calendar(null, index); - that.choose(lay(elemCont).find('td.layui-this'), index); - that.done(null, 'change'); + // 面板自动切换的模式下重新判定是否发生模式转换等细节处理 + that.autoCalendarModel.auto ? that.choose(lay(elemCont).find('td.layui-this'), index) : that.done(null, 'change'); } } ,prevMonth: function(){ @@ -1962,8 +1961,7 @@ that.checkDate('limit').calendar(null, null, 'init'); if (!that.rangeLinked) { - that.choose(lay(elemCont).find('td.layui-this'), index); - that.done(null, 'change'); + that.autoCalendarModel.auto ? that.choose(lay(elemCont).find('td.layui-this'), index) : that.done(null, 'change'); } } ,nextMonth: function(){ @@ -1978,8 +1976,7 @@ that.checkDate('limit').calendar(null, null, 'init'); if (!that.rangeLinked) { - that.choose(lay(elemCont).find('td.layui-this'), index); - that.done(null, 'change'); + that.autoCalendarModel.auto ? that.choose(lay(elemCont).find('td.layui-this'), index) : that.done(null, 'change'); } } ,nextYear: function(){ @@ -1990,8 +1987,7 @@ } else { dateTime.year++; that.checkDate('limit').calendar(null, index); - that.choose(lay(elemCont).find('td.layui-this'), index); - that.done(null, 'change'); + that.autoCalendarModel.auto ? that.choose(lay(elemCont).find('td.layui-this'), index) : that.done(null, 'change'); } } };