DatePicker: picker interaction (#6090)

* DatePicker: fix picker interaction

* DatePicker: fix picker interaction

* fix

* DatePicker: fix picker interaction
pull/6325/head
Dreamacro 2017-08-05 16:35:42 +08:00 committed by 杨奕
parent 7a84a3e44a
commit 5d097a0a4a
2 changed files with 16 additions and 5 deletions

View File

@ -81,6 +81,11 @@
selectableRange(val) { selectableRange(val) {
this.$refs.spinner.selectableRange = val; this.$refs.spinner.selectableRange = val;
},
date(val) {
this.currentDate = val;
this.reinitDate();
} }
}, },
@ -157,13 +162,17 @@
const index = list.indexOf(this.selectionRange[0]); const index = list.indexOf(this.selectionRange[0]);
const next = (index + step + list.length) % list.length; const next = (index + step + list.length) % list.length;
this.$refs.spinner.emitSelectRange(mapping[next]); this.$refs.spinner.emitSelectRange(mapping[next]);
},
reinitDate() {
this.hours = this.currentDate.getHours();
this.minutes = this.currentDate.getMinutes();
this.seconds = this.currentDate.getSeconds();
} }
}, },
created() { created() {
this.hours = this.currentDate.getHours(); this.reinitDate();
this.minutes = this.currentDate.getMinutes();
this.seconds = this.currentDate.getSeconds();
}, },
mounted() { mounted() {

View File

@ -34,6 +34,7 @@ import Popper from 'element-ui/src/utils/vue-popper';
import Emitter from 'element-ui/src/mixins/emitter'; import Emitter from 'element-ui/src/mixins/emitter';
import Focus from 'element-ui/src/mixins/focus'; import Focus from 'element-ui/src/mixins/focus';
import ElInput from 'element-ui/packages/input'; import ElInput from 'element-ui/packages/input';
import merge from 'element-ui/src/utils/merge';
const NewPopper = { const NewPopper = {
props: { props: {
@ -449,8 +450,9 @@ export default {
}, },
mountPicker() { mountPicker() {
this.panel.defaultValue = this.defaultValue || this.currentValue; const defaultValue = this.defaultValue || this.currentValue;
this.picker = new Vue(this.panel).$mount(); const panel = merge({}, this.panel, { defaultValue });
this.picker = new Vue(panel).$mount();
this.picker.popperClass = this.popperClass; this.picker.popperClass = this.popperClass;
this.popperElm = this.picker.$el; this.popperElm = this.picker.$el;
this.picker.width = this.reference.getBoundingClientRect().width; this.picker.width = this.reference.getBoundingClientRect().width;