Commit d35ae010 authored by wacky6.AriesMBP's avatar wacky6.AriesMBP Committed by 杨奕

DatePicker: support default-value for date-range

parent 4576c72e
...@@ -153,6 +153,14 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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);
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment