mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-16 11:44:01 +08:00
date-picker : fix disabledDate bug 。
未改之前,设置禁用日期后,年和月的禁用状态不准。因为只选取了年和月的某一天进行判断。修改为年和月的每一天都进行判断。
This commit is contained in:
@@ -63,11 +63,29 @@
|
||||
methods: {
|
||||
getCellStyle(month) {
|
||||
const style = {};
|
||||
const date = new Date(this.date);
|
||||
|
||||
var year = this.date.getFullYear();
|
||||
var date = new Date(0);
|
||||
date.setFullYear(year);
|
||||
date.setMonth(month);
|
||||
style.disabled = typeof this.disabledDate === 'function' &&
|
||||
this.disabledDate(date);
|
||||
date.setHours(0);
|
||||
var nextMonth = new Date(date);
|
||||
nextMonth.setMonth(month + 1);
|
||||
|
||||
var flag = false;
|
||||
if (typeof this.disabledDate === 'function') {
|
||||
|
||||
while (date < nextMonth) {
|
||||
if (this.disabledDate(date)) {
|
||||
date = new Date(date.getTime() + 8.64e7);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((date - nextMonth) === 0) flag = true;
|
||||
}
|
||||
|
||||
style.disabled = flag;
|
||||
style.current = this.month === month;
|
||||
|
||||
return style;
|
||||
|
||||
Reference in New Issue
Block a user