|
@@ -23,7 +23,8 @@
|
|
|
:placeholder="t('el.datepicker.selectDate')"
|
|
|
:value="visibleDate"
|
|
|
size="small"
|
|
|
- @change.native="handleVisibleDateChange" />
|
|
|
+ @input="val => userInputDate = val"
|
|
|
+ @change="handleVisibleDateChange" />
|
|
|
</span>
|
|
|
<span class="el-date-picker__editor-wrap">
|
|
|
<el-input
|
|
@@ -32,7 +33,8 @@
|
|
|
:placeholder="t('el.datepicker.selectTime')"
|
|
|
:value="visibleTime"
|
|
|
size="small"
|
|
|
- @change.native="handleVisibleTimeChange" />
|
|
|
+ @input="val => userInputTime = val"
|
|
|
+ @change="handleVisibleTimeChange" />
|
|
|
<time-picker
|
|
|
ref="timepicker"
|
|
|
:time-arrow-control="arrowControl"
|
|
@@ -227,13 +229,11 @@
|
|
|
emit(value, ...args) {
|
|
|
if (!value) {
|
|
|
this.$emit('pick', value, ...args);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.showTime) {
|
|
|
- this.$emit('pick', clearMilliseconds(value), ...args);
|
|
|
} else {
|
|
|
- this.$emit('pick', clearTime(value), ...args);
|
|
|
+ this.$emit('pick', this.showTime ? clearMilliseconds(value) : clearTime(value), ...args);
|
|
|
}
|
|
|
+ this.userInputDate = null;
|
|
|
+ this.userInputTime = null;
|
|
|
},
|
|
|
|
|
|
// resetDate() {
|
|
@@ -374,8 +374,8 @@
|
|
|
event.stopPropagation();
|
|
|
event.preventDefault();
|
|
|
}
|
|
|
- if (keyCode === 13) { // Enter
|
|
|
- this.$emit('pick', this.date, false);
|
|
|
+ if (keyCode === 13 && this.userInputDate === null && this.userInputTime === null) { // Enter
|
|
|
+ this.emit(this.date, false);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -411,25 +411,27 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- handleVisibleTimeChange(event) {
|
|
|
- const time = parseDate(event.target.value, this.timeFormat);
|
|
|
+ handleVisibleTimeChange(value) {
|
|
|
+ const time = parseDate(value, this.timeFormat);
|
|
|
if (time) {
|
|
|
this.date = modifyDate(time, this.year, this.month, this.monthDate);
|
|
|
+ this.userInputTime = null;
|
|
|
this.$refs.timepicker.value = this.date;
|
|
|
this.timePickerVisible = false;
|
|
|
- this.$emit('pick', this.date, true);
|
|
|
+ this.emit(this.date, true);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- handleVisibleDateChange(event) {
|
|
|
- const date = parseDate(event.target.value, this.dateFormat);
|
|
|
+ handleVisibleDateChange(value) {
|
|
|
+ const date = parseDate(value, this.dateFormat);
|
|
|
if (date) {
|
|
|
if (typeof this.disabledDate === 'function' && this.disabledDate(date)) {
|
|
|
return;
|
|
|
}
|
|
|
this.date = modifyTime(date, this.date.getHours(), this.date.getMinutes(), this.date.getSeconds());
|
|
|
+ this.userInputDate = null;
|
|
|
this.resetView();
|
|
|
- this.$emit('pick', this.date, true);
|
|
|
+ this.emit(this.date, true);
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -462,7 +464,9 @@
|
|
|
showWeekNumber: false,
|
|
|
timePickerVisible: false,
|
|
|
format: '',
|
|
|
- arrowControl: false
|
|
|
+ arrowControl: false,
|
|
|
+ userInputDate: null,
|
|
|
+ userInputTime: null
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -488,13 +492,19 @@
|
|
|
},
|
|
|
|
|
|
visibleTime() {
|
|
|
- const date = this.value || this.defaultValue;
|
|
|
- return date ? formatDate(date, this.timeFormat) : '';
|
|
|
+ if (this.userInputTime !== null) {
|
|
|
+ return this.userInputTime;
|
|
|
+ } else {
|
|
|
+ return formatDate(this.value || this.defaultValue, this.timeFormat);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
visibleDate() {
|
|
|
- const date = this.value || this.defaultValue;
|
|
|
- return date ? formatDate(date, this.dateFormat) : '';
|
|
|
+ if (this.userInputDate !== null) {
|
|
|
+ return this.userInputDate;
|
|
|
+ } else {
|
|
|
+ return formatDate(this.value || this.defaultValue, this.dateFormat);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
yearLabel() {
|