diff --git a/examples/docs/date-picker.md b/examples/docs/date-picker.md index 06097e21a..04473a696 100644 --- a/examples/docs/date-picker.md +++ b/examples/docs/date-picker.md @@ -50,7 +50,14 @@ picker.$emit('pick', [start, end]); } }] - } + }, + value1: '', + value2: '', + value3: '', + value4: '', + value5: '', + value6: '', + value7: '' }; } }; @@ -63,12 +70,14 @@ 以『日』为基本单位 ```html @@ -79,6 +88,7 @@ 以『周』为基本单位 @@ -86,6 +96,7 @@ ```html @@ -97,12 +108,14 @@ 以『月』为基本单位 ```html @@ -113,12 +126,14 @@ 以『年』为基本单位 ```html @@ -129,6 +144,7 @@ 左侧区域可配置快捷选项,例如『今天』、『昨天』等 @@ -136,6 +152,7 @@ ```html @@ -166,7 +183,8 @@ picker.$emit('pick', date); } }] - } + }, + value: '' }; } }; @@ -180,6 +198,7 @@ 在一个选择器中选择 @@ -187,6 +206,7 @@ ```html @@ -198,6 +218,7 @@ 左侧区域可配置快捷选项,例如『最近一周』、『最近一个月』等 ```html ``` @@ -88,6 +108,7 @@
@@ -95,6 +116,7 @@ ```html @@ -106,22 +128,26 @@
```html @@ -150,7 +176,8 @@ picker.$emit('pick', date); } }] - } + }, + value: new Date() }; } }; @@ -163,6 +190,7 @@
@@ -171,6 +199,7 @@ ```html @@ -228,10 +260,12 @@ ```html @@ -243,6 +277,7 @@
@@ -251,6 +286,7 @@ ```html @@ -263,6 +299,7 @@
@@ -333,11 +374,13 @@ ```html @@ -350,10 +393,12 @@
@@ -361,10 +406,12 @@ ```html @@ -374,10 +421,12 @@
@@ -385,10 +434,12 @@ ```html @@ -398,10 +449,12 @@
@@ -409,10 +462,12 @@ ```html diff --git a/examples/docs/time-picker.md b/examples/docs/time-picker.md index 6b7d58033..654e618bc 100644 --- a/examples/docs/time-picker.md +++ b/examples/docs/time-picker.md @@ -8,9 +8,9 @@ ## 固定时间点 提供几个固定的时间点供用户选择。 -
```html ``` @@ -51,13 +52,14 @@ ### 通用 - 手动输入规则
```html ``` @@ -66,6 +68,7 @@
@@ -193,6 +197,7 @@ ```html ``` @@ -201,6 +206,11 @@ export default { data() { return { + value1: '', + value2: '', + value3: '', + value4: '', + value5: '', startTime: '', endTime: '', startTime2: '', diff --git a/package.json b/package.json index 034f16084..412dc35d2 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,9 @@ "purecss": "^0.6.0", "q": "^1.4.1", "uppercamelcase": "^1.1.0", + "vue": "^2.0.0-beta.7", + "vue-loader": "^9.3.2", "vue": "^2.0.0-beta.8", - "vue-loader": "^9.2.3", "vue-markdown-loader": "^0.4.0", "vue-popup": "^0.2.1", "vue-router": "^2.0.0-beta.2" diff --git a/packages/date-picker/package.json b/packages/date-picker/package.json index d863212b9..8ce932f2b 100644 --- a/packages/date-picker/package.json +++ b/packages/date-picker/package.json @@ -12,10 +12,9 @@ "author": "long.zhang@ele.me", "license": "MIT", "dependencies": { - "wind-dom": "0.0.3", - "vue-clickoutside": "*" + "wind-dom": "0.0.3" }, "devDependencies": { - "vue": "^1.0.0" + "vue": "^2.0.0-beta.7" } } diff --git a/packages/date-picker/src/basic/date-table.vue b/packages/date-picker/src/basic/date-table.vue index de4a0cf13..92a13a24e 100644 --- a/packages/date-picker/src/basic/date-table.vue +++ b/packages/date-picker/src/basic/date-table.vue @@ -392,24 +392,30 @@ if (clickNormalCell && this.selectionMode === 'range') { if (this.minDate && this.maxDate) { - this.minDate = new Date(newDate.getTime()); - this.maxDate = null; + const minDate = new Date(newDate.getTime()); + const maxDate = null; + + this.$emit('pick', { minDate, maxDate }, false); this.rangeState.selecting = true; this.markRange(this.minDate); } else if (this.minDate && !this.maxDate) { if (newDate >= this.minDate) { - this.maxDate = new Date(newDate.getTime()); + const maxDate = new Date(newDate.getTime()); this.rangeState.selecting = false; this.$emit('pick', { minDate: this.minDate, - maxDate: this.maxDate + maxDate }); } else { - this.minDate = new Date(newDate.getTime()); + const minDate = new Date(newDate.getTime()); + + this.$emit('pick', { minDate, maxDate: this.maxDate }, false); } } else if (!this.minDate) { - this.minDate = new Date(newDate.getTime()); + const minDate = new Date(newDate.getTime()); + + this.$emit('pick', { minDate, maxDate: this.maxDate }, false); this.rangeState.selecting = true; this.markRange(this.minDate); } @@ -420,11 +426,11 @@ } else if (selectionMode === 'week') { var weekNumber = getWeekNumber(newDate); - this.value = newDate.getFullYear() + 'w' + weekNumber; + const value = newDate.getFullYear() + 'w' + weekNumber; this.$emit('pick', { year: newDate.getFullYear(), week: weekNumber, - value: this.value, + value: value, date: newDate }); } diff --git a/packages/date-picker/src/basic/month-table.vue b/packages/date-picker/src/basic/month-table.vue index 7e0fef950..befa42cca 100644 --- a/packages/date-picker/src/basic/month-table.vue +++ b/packages/date-picker/src/basic/month-table.vue @@ -65,7 +65,7 @@ if (target.tagName !== 'A') return; const column = target.parentNode.cellIndex; const row = target.parentNode.parentNode.rowIndex; - const month = this.month = row * 4 + column; + const month = row * 4 + column; this.$emit('pick', month); } diff --git a/packages/date-picker/src/basic/time-spinner.vue b/packages/date-picker/src/basic/time-spinner.vue index 51dcc3f5c..1a98fd07b 100644 --- a/packages/date-picker/src/basic/time-spinner.vue +++ b/packages/date-picker/src/basic/time-spinner.vue @@ -1,43 +1,46 @@ @@ -64,33 +67,32 @@ showSeconds: { type: Boolean, default: true - }, - - selectableRange: {} + } }, watch: { - hours(newVal, oldVal) { + hoursPrivate(newVal, oldVal) { if (!(newVal >= 0 && newVal <= 23)) { - this.hours = oldVal; + this.hoursPrivate = oldVal; } - this.$els.hour.scrollTop = Math.max(0, (this.hours - 2.5) * 32 + 80); + this.$refs.hour.scrollTop = Math.max(0, (this.hoursPrivate - 2.5) * 32 + 80); + this.$emit('change', { hours: newVal }); }, - minutes(newVal, oldVal) { + minutesPrivate(newVal, oldVal) { if (!(newVal >= 0 && newVal <= 59)) { - this.minutes = oldVal; + this.minutesPrivate = oldVal; } - this.$els.minute.scrollTop = Math.max(0, (this.minutes - 2.5) * 32 + 80); + this.$refs.minute.scrollTop = Math.max(0, (this.minutesPrivate - 2.5) * 32 + 80); this.$emit('change', { minutes: newVal }); }, - seconds(newVal, oldVal) { + secondsPrivate(newVal, oldVal) { if (!(newVal >= 0 && newVal <= 59)) { - this.seconds = oldVal; + this.secondsPrivate = oldVal; } - this.$els.second.scrollTop = Math.max(0, (this.seconds - 2.5) * 32 + 80); + this.$refs.second.scrollTop = Math.max(0, (this.secondsPrivate - 2.5) * 32 + 80); this.$emit('change', { seconds: newVal }); } }, @@ -101,9 +103,18 @@ } }, + data() { + return { + hoursPrivate: 0, + minutesPrivate: 0, + secondsPrivate: 0, + selectableRange: [] + }; + }, + methods: { focusEditor(type) { - const editor = this.$els[type + 'Editor']; + const editor = this.$refs[type + 'Editor']; if (editor) { editor.focus(); } @@ -114,7 +125,7 @@ return; } - this[type] = value.value >= 0 ? value.value : value; + this[type + 'Private'] = value.value >= 0 ? value.value : value; this.emitSelectRange(type); }, @@ -130,9 +141,9 @@ }, ajustScrollTop() { - this.$els.hour.scrollTop = Math.max(0, (this.hours - 2.5) * 32 + 80); - this.$els.minute.scrollTop = Math.max(0, (this.minutes - 2.5) * 32 + 80); - this.$els.second.scrollTop = Math.max(0, (this.seconds - 2.5) * 32 + 80); + this.$refs.hour.scrollTop = Math.max(0, (this.hours - 2.5) * 32 + 80); + this.$refs.minute.scrollTop = Math.max(0, (this.minutes - 2.5) * 32 + 80); + this.$refs.second.scrollTop = Math.max(0, (this.seconds - 2.5) * 32 + 80); } } }; diff --git a/packages/date-picker/src/basic/year-table.vue b/packages/date-picker/src/basic/year-table.vue index d454bd653..beca05ee0 100644 --- a/packages/date-picker/src/basic/year-table.vue +++ b/packages/date-picker/src/basic/year-table.vue @@ -59,17 +59,17 @@ methods: { nextTenYear() { - this.year += 10; + this.$emit('pick', this.year + 10, false); }, prevTenYear() { - this.year -= 10; + this.$emit('pick', this.year - 10, false); }, handleYearTableClick(event) { const target = event.target; if (target.tagName === 'A') { - const year = this.year = parseInt(target.textContent || target.innerText, 10); + const year = parseInt(target.textContent || target.innerText, 10); this.$emit('pick', year); } } diff --git a/packages/date-picker/src/panel/date-range.vue b/packages/date-picker/src/panel/date-range.vue index 33ba27e40..5c7c2ade9 100644 --- a/packages/date-picker/src/panel/date-range.vue +++ b/packages/date-picker/src/panel/date-range.vue @@ -1,161 +1,128 @@