Procházet zdrojové kódy

DatePicker: picker interaction (#6090)

* DatePicker: fix picker interaction

* DatePicker: fix picker interaction

* fix

* DatePicker: fix picker interaction
Dreamacro před 8 roky
rodič
revize
5d097a0a4a

+ 12 - 3
packages/date-picker/src/panel/time.vue

@@ -81,6 +81,11 @@
 
       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 next = (index + step + list.length) % list.length;
         this.$refs.spinner.emitSelectRange(mapping[next]);
+      },
+
+      reinitDate() {
+        this.hours = this.currentDate.getHours();
+        this.minutes = this.currentDate.getMinutes();
+        this.seconds = this.currentDate.getSeconds();
       }
     },
 
     created() {
-      this.hours = this.currentDate.getHours();
-      this.minutes = this.currentDate.getMinutes();
-      this.seconds = this.currentDate.getSeconds();
+      this.reinitDate();
     },
 
     mounted() {

+ 4 - 2
packages/date-picker/src/picker.vue

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