From 964582b3996bb2e86517196a297714d25e91ff2e Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Thu, 29 Dec 2016 09:54:29 +0800 Subject: [PATCH] update TimePicker --- src/components/date-picker/panel/time-range.vue | 12 +++++++++++- test/routers/date.vue | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/date-picker/panel/time-range.vue b/src/components/date-picker/panel/time-range.vue index 8c1d75d..13a87ff 100644 --- a/src/components/date-picker/panel/time-range.vue +++ b/src/components/date-picker/panel/time-range.vue @@ -144,7 +144,17 @@ this.dateEnd.setSeconds(dateEnd.seconds); this.secondsEnd = this.dateEnd.getSeconds(); } - if (emit) this.$emit('on-pick', [this.date, this.dateEnd], true); + // judge endTime > startTime? + if (this.dateEnd < this.date) { + this.$nextTick(() => { + this.dateEnd = new Date(this.date); + this.hoursEnd = this.dateEnd.getHours(); + this.minutesEnd = this.dateEnd.getMinutes(); + this.secondsEnd = this.dateEnd.getSeconds(); + }); + } else { + if (emit) this.$emit('on-pick', [this.date, this.dateEnd], true); + } }, handleStartChange (date) { this.handleChange(date, {}); diff --git a/test/routers/date.vue b/test/routers/date.vue index 4fa6e96..5ef62d7 100644 --- a/test/routers/date.vue +++ b/test/routers/date.vue @@ -51,7 +51,7 @@ methods: { c (s) { -// console.log(1,s); + console.log(s); // this.value2 = s; }, ok () { -- libgit2 0.21.4