@@ -110,17 +110,23 @@ export class CalendarHeaderComponent {
110
110
const availValue = (
111
111
side === Side . Left ? this . _minAvail : this . _maxAvail
112
112
) ?. clone ( ) ;
113
- if ( ! availValue ) {
114
- return true ;
113
+ /**
114
+ * 对于 range-picker
115
+ * 左侧部分 minAvail = minDate, maxAvail = min(maxData, rightAnchor),从而左侧部分的按钮,仅在小于右侧部分时显示
116
+ * 右侧部分 maxAvail = maxDate, minAvail = max(minData, leftAnchor),从而左侧部分的按钮,仅在小于右侧部分时显示
117
+ */
118
+ if ( side === Side . Left ) {
119
+ return type === DateNavRange . Month
120
+ ? ! this . anchor . subtract ( 1 , 'month' ) . isBefore ( availValue , 'month' )
121
+ : type === DateNavRange . Year
122
+ ? ! this . anchor . subtract ( 1 , 'year' ) . isBefore ( availValue , 'year' )
123
+ : false ;
115
124
}
116
- // 对于年的判别,2014-5-1至2015-6-1日,仍当展示按钮
117
- const constrainDate = [ DateNavRange . Month , DateNavRange . Year ] . includes ( type )
118
- ? availValue . add ( side === Side . Left ? 1 : - 1 , type as 'month' | 'year' )
119
- : availValue ;
120
- return (
121
- this . compareNavValue ( type , constrainDate , this . anchor ) ===
122
- ( side === Side . Left ? - 1 : 1 )
123
- ) ;
125
+ return type === DateNavRange . Month
126
+ ? ! this . anchor . add ( 1 , 'month' ) . isAfter ( availValue , 'month' )
127
+ : type === DateNavRange . Year
128
+ ? ! this . anchor . add ( 1 , 'year' ) . isAfter ( availValue , 'year' )
129
+ : false ;
124
130
}
125
131
126
132
// @return isBetween|isEqual:0, isBefore:-1,isAfter:1
0 commit comments