Skip to content

date-picker设置range模式有执行prevYear,结果只有rightYear更新了 #410

Open
@liangfriend

Description

@liangfriend

changePanelDate(panel, type, increment, updateOtherPanel = true){
const current = new Date(this[${panel}PanelDate]);
// 我不知道为什么这里要加一个if语句,把panel === 'left'也改成+increment就功能正常了
if (panel === 'left') {
current[set${type}](currentget${type}, 0);
} else {
current[set${type}](currentget${type} + increment);
}
this[${panel}PanelDate] = current;

            if (!updateOtherPanel) return;

            if (this.splitPanels){
                // change other panel if dates overlap
                const otherPanel = panel === 'left' ? 'right' : 'left';
                if (panel === 'left' && this.leftPanelDate >= this.rightPanelDate){
                    this.changePanelDate(otherPanel, type, 1);
                }
                if (panel === 'right' && this.rightPanelDate <= this.leftPanelDate){
                    this.changePanelDate(otherPanel, type, -1);
                }
            } else {
                // keep the panels together
                const otherPanel = panel === 'left' ? 'right' : 'left';
                const currentDate = this[`${otherPanel}PanelDate`];
                const temp = new Date(currentDate);
              console.log('chicken',currentDate,temp[`set${type}`](temp[`get${type}`]())
                if (type === 'Month') {
                    const nextMonthLastDate = new Date(
                        temp.getFullYear(), temp.getMonth() + increment + 1, 0
                    ).getDate();
                    temp.setDate(Math.min(nextMonthLastDate, temp.getDate()));
                }

                temp[`set${type}`](temp[`get${type}`]() + increment);
                this[`${otherPanel}PanelDate`] = temp;
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions