mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-23 00:30:35 +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;
|
this.innerCalendar = calendarDate;
|
||||||
},
|
},
|
||||||
|
isDisabled(date) {
|
||||||
|
return this.disabledDate(new Date(date), this.innerValue);
|
||||||
|
},
|
||||||
emitDate(date, type) {
|
emitDate(date, type) {
|
||||||
if (!this.disabledDate(new Date(date))) {
|
if (!this.isDisabled(date)) {
|
||||||
this.$emit('select', date, type);
|
this.$emit('select', date, type);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -325,7 +328,7 @@ export default {
|
|||||||
return classes.concat(this.getClasses(cellDate, this.innerValue, classes.join(' ')));
|
return classes.concat(this.getClasses(cellDate, this.innerValue, classes.join(' ')));
|
||||||
},
|
},
|
||||||
getStateClass(cellDate) {
|
getStateClass(cellDate) {
|
||||||
if (this.disabledDate(new Date(cellDate))) {
|
if (this.isDisabled(cellDate)) {
|
||||||
return 'disabled';
|
return 'disabled';
|
||||||
}
|
}
|
||||||
if (this.innerValue.some(v => v.getTime() === cellDate.getTime())) {
|
if (this.innerValue.some(v => v.getTime() === cellDate.getTime())) {
|
||||||
|
|||||||
@@ -133,9 +133,12 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
isDisabled(date) {
|
||||||
|
return this.disabledTime(new Date(date), this.innerValue);
|
||||||
|
},
|
||||||
handleSelect(value, type) {
|
handleSelect(value, type) {
|
||||||
const date = new Date(value);
|
const date = new Date(value);
|
||||||
if (!this.disabledTime(new Date(value))) {
|
if (!this.isDisabled(value)) {
|
||||||
this.$emit('select', date, type);
|
this.$emit('select', date, type);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -144,7 +147,7 @@ export default {
|
|||||||
},
|
},
|
||||||
getClasses(value) {
|
getClasses(value) {
|
||||||
const cellDate = new Date(value);
|
const cellDate = new Date(value);
|
||||||
if (this.disabledTime(new Date(value))) {
|
if (this.isDisabled(value)) {
|
||||||
return 'disabled';
|
return 'disabled';
|
||||||
}
|
}
|
||||||
if (cellDate.getTime() === this.innerValue.getTime()) {
|
if (cellDate.getTime() === this.innerValue.getTime()) {
|
||||||
|
|||||||
@@ -49,10 +49,13 @@ export default {
|
|||||||
this.emitChange(type, 1);
|
this.emitChange(type, 1);
|
||||||
},
|
},
|
||||||
disabledStartTime(date) {
|
disabledStartTime(date) {
|
||||||
return this.disabledTime(date, 0);
|
return this.disabledTime(date, [this.startValue, this.endValue], 0);
|
||||||
},
|
},
|
||||||
disabledEndTime(date) {
|
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() {
|
render() {
|
||||||
|
|||||||
Reference in New Issue
Block a user