Commit 3cf5fd94 authored by liyangworld's avatar liyangworld Committed by 杨奕

date-picker : fix disabledDate bug 。

未改之前,设置禁用日期后,年和月的禁用状态不准。因为只选取了年和月的某一天进行判断。修改为年和月的每一天都进行判断。
parent be6cc780
......@@ -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;
......
......@@ -62,11 +62,28 @@
methods: {
getCellStyle(year) {
const style = {};
const date = new Date(this.date);
var date = new Date(0);
date.setFullYear(year);
style.disabled = typeof this.disabledDate === 'function' &&
this.disabledDate(date);
date.setHours(0);
var nextYear = new Date(date);
nextYear.setFullYear(year + 1);
var flag = false;
if (typeof this.disabledDate === 'function') {
while (date < nextYear) {
if (this.disabledDate(date)) {
date = new Date(date.getTime() + 8.64e7);
} else {
break;
}
}
if ((date - nextYear) === 0) flag = true;
}
style.disabled = flag;
style.current = Number(this.year) === year;
return style;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment