Commit db9985a94e8ab93db94be2d7c3c792474032e127

Authored by 梁灏
1 parent 964582b3

update TimePicker

update TimePicker
Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
src/components/date-picker/panel/time-range.vue
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 41
42 import Mixin from './mixin'; 42 import Mixin from './mixin';
43 43
44 - import { initTimeDate, toDate } from '../util'; 44 + import { initTimeDate, toDate, formatDate } from '../util';
45 45
46 const prefixCls = 'ivu-picker-panel'; 46 const prefixCls = 'ivu-picker-panel';
47 const timePrefixCls = 'ivu-time-picker'; 47 const timePrefixCls = 'ivu-time-picker';
@@ -120,6 +120,8 @@ @@ -120,6 +120,8 @@
120 this.secondsEnd = ''; 120 this.secondsEnd = '';
121 }, 121 },
122 handleChange (date, dateEnd, emit = true) { 122 handleChange (date, dateEnd, emit = true) {
  123 + const oldDateEnd = new Date(this.dateEnd);
  124 +
123 if (date.hours !== undefined) { 125 if (date.hours !== undefined) {
124 this.date.setHours(date.hours); 126 this.date.setHours(date.hours);
125 this.hours = this.date.getHours(); 127 this.hours = this.date.getHours();
@@ -151,6 +153,11 @@ @@ -151,6 +153,11 @@
151 this.hoursEnd = this.dateEnd.getHours(); 153 this.hoursEnd = this.dateEnd.getHours();
152 this.minutesEnd = this.dateEnd.getMinutes(); 154 this.minutesEnd = this.dateEnd.getMinutes();
153 this.secondsEnd = this.dateEnd.getSeconds(); 155 this.secondsEnd = this.dateEnd.getSeconds();
  156 +
  157 + const format = 'yyyy-MM-dd HH:mm:ss';
  158 + if (formatDate(oldDateEnd, format) !== formatDate(this.dateEnd, format)) {
  159 + if (emit) this.$emit('on-pick', [this.date, this.dateEnd], true);
  160 + }
154 }); 161 });
155 } else { 162 } else {
156 if (emit) this.$emit('on-pick', [this.date, this.dateEnd], true); 163 if (emit) this.$emit('on-pick', [this.date, this.dateEnd], true);