From f6ab3f9129b37579eb52c5acdde690520c891c66 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Wed, 7 Dec 2022 17:19:48 +0800 Subject: [PATCH] =?UTF-8?q?laydate=E4=BF=AE=E5=A4=8D=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=80=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E7=82=B9=E5=87=BB=E5=8F=B3=E9=9D=A2=E6=9D=BF=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=80=89=E6=8B=A9=E7=BB=93=E6=9D=9F=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E9=9D=A2=E6=9D=BF=E9=87=8D=E6=96=B0=E7=BB=98?= =?UTF-8?q?=E5=88=B6=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 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index d3e283ee..fcd3fec2 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -1697,7 +1697,8 @@ if(td.hasClass(DISABLED)) return; var that = this - ,options = that.config; + ,options = that.config + ,panelIndex = index; // 记录点击的是哪一个面板的 if (that.rangeLinked) { if (that.endState || !that.startDate) { @@ -1762,7 +1763,7 @@ if (that.endState && that.autoCalendarModel.auto) { isChange = that.autoCalendarModel(); } - if (that.rangeLinked && that.endState && that.newDate(that.startDate) > that.newDate(that.endDate)) { + if ((isChange || that.rangeLinked && that.endState) && that.newDate(that.startDate) > that.newDate(that.endDate)) { var isSameDate = that.startDate.year === that.endDate.year && that.startDate.month === that.endDate.month && that.startDate.date === that.endDate.date; // 判断是否反选 var startDate = that.startDate; @@ -1777,7 +1778,21 @@ } isChange && (options.dateTime = lay.extend({}, that.startDate)); } - that.calendar(null, that.rangeLinked ? null : index, isChange || that.rangeLinked ? 'init' : null).done(null, 'change'); + if (that.rangeLinked) { + var dateTimeTemp = lay.extend({}, dateTime); + if (panelIndex && !index && !isChange) { // 处理可能出现的联动面板中点击右面板但是判定为开始日期这个时候点击头部的切换上下月第一次没有反应的问题 + // 选择了右面板但是判断之后作为开始时间 + var YM = that.getAsYM(dateTime.year, dateTime.month, 'sub'); + lay.extend(options.dateTime, { + year: YM[0] + ,month: YM[1] + }); + } + that.calendar(dateTimeTemp, panelIndex, isChange ? 'init' : null); + } else { + that.calendar(null, index, isChange ? 'init' : null); + } + that.endState && that.done(null, 'change'); } else if(options.position === 'static'){ //直接嵌套的选中 that.calendar().done().done(null, 'change'); //同时执行 done 和 change 回调 } else if(options.type === 'date'){