ViewUIPlus icon indicating copy to clipboard operation
ViewUIPlus copied to clipboard

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

Open liangfriend opened this issue 8 months ago • 0 comments

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;
            }
        }

liangfriend avatar Apr 30 '25 03:04 liangfriend