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