Merge pull request #5887 from KumJungMin/fix/range-picker-month
fix(DatePicker): highlight range of month in monthModepull/5981/head
commit
8416ec6bfc
|
@ -717,17 +717,29 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
isMonthSelected(month) {
|
isMonthSelected(month) {
|
||||||
if (this.isComparable()) {
|
if (!this.isComparable()) return false;
|
||||||
let value = this.isRangeSelection() ? this.modelValue[0] : this.modelValue;
|
|
||||||
|
|
||||||
if (this.isMultipleSelection()) {
|
if (this.isMultipleSelection()) {
|
||||||
return value.some((currentValue) => currentValue.getMonth() === month && currentValue.getFullYear() === this.currentYear);
|
return this.modelValue.some((v) => v.getMonth() === month && v.getFullYear() === this.currentYear);
|
||||||
} else {
|
} else if (this.isRangeSelection()) {
|
||||||
return value.getMonth() === month && value.getFullYear() === this.currentYear;
|
const [start, end] = this.modelValue;
|
||||||
}
|
const startYear = start ? start.getFullYear() : null;
|
||||||
}
|
const endYear = end ? end.getFullYear() : null;
|
||||||
|
const startMonth = start ? start.getMonth() : null;
|
||||||
|
const endMonth = end ? end.getMonth() : null;
|
||||||
|
|
||||||
return false;
|
if (!end) {
|
||||||
|
return startYear === this.currentYear && startMonth === month;
|
||||||
|
} else {
|
||||||
|
const currentDate = new Date(this.currentYear, month, 1);
|
||||||
|
const startDate = new Date(startYear, startMonth, 1);
|
||||||
|
const endDate = new Date(endYear, endMonth, 1);
|
||||||
|
|
||||||
|
return currentDate >= startDate && currentDate <= endDate;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return this.modelValue.getMonth() === month && this.modelValue.getFullYear() === this.currentYear;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isYearSelected(year) {
|
isYearSelected(year) {
|
||||||
if (this.isComparable()) {
|
if (this.isComparable()) {
|
||||||
|
|
Loading…
Reference in New Issue