mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-05 22:32:25 +03:00
feat: add the second parameter to disabled-date (#385)
This commit is contained in:
@@ -221,8 +221,11 @@ export default {
|
||||
}
|
||||
this.innerCalendar = calendarDate;
|
||||
},
|
||||
isDisabled(date) {
|
||||
return this.disabledDate(new Date(date), this.innerValue);
|
||||
},
|
||||
emitDate(date, type) {
|
||||
if (!this.disabledDate(new Date(date))) {
|
||||
if (!this.isDisabled(date)) {
|
||||
this.$emit('select', date, type);
|
||||
}
|
||||
},
|
||||
@@ -325,7 +328,7 @@ export default {
|
||||
return classes.concat(this.getClasses(cellDate, this.innerValue, classes.join(' ')));
|
||||
},
|
||||
getStateClass(cellDate) {
|
||||
if (this.disabledDate(new Date(cellDate))) {
|
||||
if (this.isDisabled(cellDate)) {
|
||||
return 'disabled';
|
||||
}
|
||||
if (this.innerValue.some(v => v.getTime() === cellDate.getTime())) {
|
||||
|
||||
@@ -133,9 +133,12 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
isDisabled(date) {
|
||||
return this.disabledTime(new Date(date), this.innerValue);
|
||||
},
|
||||
handleSelect(value, type) {
|
||||
const date = new Date(value);
|
||||
if (!this.disabledTime(new Date(value))) {
|
||||
if (!this.isDisabled(value)) {
|
||||
this.$emit('select', date, type);
|
||||
}
|
||||
},
|
||||
@@ -144,7 +147,7 @@ export default {
|
||||
},
|
||||
getClasses(value) {
|
||||
const cellDate = new Date(value);
|
||||
if (this.disabledTime(new Date(value))) {
|
||||
if (this.isDisabled(value)) {
|
||||
return 'disabled';
|
||||
}
|
||||
if (cellDate.getTime() === this.innerValue.getTime()) {
|
||||
|
||||
@@ -49,10 +49,13 @@ export default {
|
||||
this.emitChange(type, 1);
|
||||
},
|
||||
disabledStartTime(date) {
|
||||
return this.disabledTime(date, 0);
|
||||
return this.disabledTime(date, [this.startValue, this.endValue], 0);
|
||||
},
|
||||
disabledEndTime(date) {
|
||||
return date.getTime() < this.startValue.getTime() || this.disabledTime(date, 1);
|
||||
return (
|
||||
date.getTime() < this.startValue.getTime() ||
|
||||
this.disabledTime(date, [this.startValue, this.endValue], 1)
|
||||
);
|
||||
},
|
||||
},
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user