DatePicker: fix setMonth, fixed #3923 (#3935)

pull/3948/head
cinwell.li 2017-04-01 10:55:48 +08:00 committed by baiyaaaaa
parent f6661e2acf
commit eac95e99c4
3 changed files with 5 additions and 10 deletions

View File

@ -312,8 +312,7 @@
const target = new Date(type === 'min' ? this.minDate : this.maxDate);
if (target) {
target.setFullYear(parsedValue.getFullYear());
target.setMonth(parsedValue.getMonth());
target.setDate(parsedValue.getDate());
target.setMonth(parsedValue.getMonth(), parsedValue.getDate());
}
}
},
@ -331,8 +330,7 @@
const target = new Date(type === 'min' ? this.minDate : this.maxDate);
if (target) {
target.setFullYear(parsedValue.getFullYear());
target.setMonth(parsedValue.getMonth());
target.setDate(parsedValue.getDate());
target.setMonth(parsedValue.getMonth(), parsedValue.getDate());
}
if (type === 'min') {
if (target < this.maxDate) {

View File

@ -293,8 +293,7 @@
this.$emit('pick', new Date(value.getTime()));
}
this.date.setFullYear(value.getFullYear());
this.date.setMonth(value.getMonth());
this.date.setDate(value.getDate());
this.date.setMonth(value.getMonth(), value.getDate());
} else if (this.selectionMode === 'week') {
this.week = value.week;
this.$emit('pick', value.date);

View File

@ -151,11 +151,9 @@
handleChange() {
if (this.minTime > this.maxTime) return;
MIN_TIME.setFullYear(this.minTime.getFullYear());
MIN_TIME.setMonth(this.minTime.getMonth());
MIN_TIME.setDate(this.minTime.getDate());
MIN_TIME.setMonth(this.minTime.getMonth(), this.minTime.getDate());
MAX_TIME.setFullYear(this.maxTime.getFullYear());
MAX_TIME.setMonth(this.maxTime.getMonth());
MAX_TIME.setDate(this.maxTime.getDate());
MAX_TIME.setMonth(this.maxTime.getMonth(), this.maxTime.getDate());
this.$refs.minSpinner.selectableRange = [[MIN_TIME, this.maxTime]];
this.$refs.maxSpinner.selectableRange = [[this.minTime, MAX_TIME]];
this.handleConfirm(true);