mirror of https://github.com/ElemeFE/element
DatePicker: support default-value for date-range
parent
4576c72ef8
commit
d35ae01042
|
@ -153,6 +153,14 @@
|
||||||
import DateTable from '../basic/date-table';
|
import DateTable from '../basic/date-table';
|
||||||
import ElInput from 'element-ui/packages/input';
|
import ElInput from 'element-ui/packages/input';
|
||||||
|
|
||||||
|
const calcDefaultValue = defaultValue => {
|
||||||
|
if (Array.isArray(defaultValue)) {
|
||||||
|
return new Date(defaultValue[0]);
|
||||||
|
} else {
|
||||||
|
return new Date(defaultValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [Locale],
|
mixins: [Locale],
|
||||||
|
|
||||||
|
@ -221,7 +229,7 @@
|
||||||
popperClass: '',
|
popperClass: '',
|
||||||
minPickerWidth: 0,
|
minPickerWidth: 0,
|
||||||
maxPickerWidth: 0,
|
maxPickerWidth: 0,
|
||||||
date: new Date(),
|
date: this.$options.defaultValue ? calcDefaultValue(this.$options.defaultValue) : new Date(),
|
||||||
minDate: '',
|
minDate: '',
|
||||||
maxDate: '',
|
maxDate: '',
|
||||||
rangeState: {
|
rangeState: {
|
||||||
|
@ -297,6 +305,7 @@
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.minDate = null;
|
this.minDate = null;
|
||||||
this.maxDate = null;
|
this.maxDate = null;
|
||||||
|
this.date = this.$options.defaultValue ? calcDefaultValue(this.$options.defaultValue) : new Date();
|
||||||
this.handleConfirm(false);
|
this.handleConfirm(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue