From c46f385a83c9bca751bed6a7d764d4a88dee3573 Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Thu, 15 Dec 2016 20:16:58 +0800 Subject: [PATCH] update DatePicker --- src/components/date-picker/base/date-table.vue | 36 ++++++++++++++++++++++++++++++++++-- src/components/date-picker/base/month-table.vue | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ src/components/date-picker/base/year-table.vue | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ src/components/date-picker/panel/date.vue | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------- src/components/date-picker/picker.vue | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- src/components/date-picker/picker/date-picker.js | 4 +--- src/components/input/input.vue | 14 +++++++++----- src/styles/components/date-picker.less | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/routers/date.vue | 27 +++++++++++++++++++++++---- 9 files changed, 565 insertions(+), 56 deletions(-) diff --git a/src/components/date-picker/base/date-table.vue b/src/components/date-picker/base/date-table.vue index 07beb3e..ee83b6b 100644 --- a/src/components/date-picker/base/date-table.vue +++ b/src/components/date-picker/base/date-table.vue @@ -6,7 +6,7 @@
- {{ cell.text }} + {{ cell.text }} \ No newline at end of file diff --git a/src/components/date-picker/base/year-table.vue b/src/components/date-picker/base/year-table.vue index 3e04a67..47b551e 100644 --- a/src/components/date-picker/base/year-table.vue +++ b/src/components/date-picker/base/year-table.vue @@ -1,13 +1,75 @@ \ No newline at end of file diff --git a/src/components/date-picker/panel/date.vue b/src/components/date-picker/panel/date.vue index fd971d2..e1c5bd2 100644 --- a/src/components/date-picker/panel/date.vue +++ b/src/components/date-picker/panel/date.vue @@ -10,25 +10,25 @@
+ @click="prevYear"> + v-show="currentView === 'date'"> {{ }} + @click="showYearPicker">{{ yearLabel }} {{ }} + v-show="currentView === 'date'">{{ month + 1 + '月' }} + - + v-show="currentView === 'date'">
+ :disabled-date="disabledDate" + @on-pick="handleDatePick"> + v-ref:year-table + v-show="currentView === 'year'" + :year="year" + :date="date" + :disabled-date="disabledDate" + @on-pick="handleYearPick"> + v-ref:month-table + v-show="currentView === 'month'" + :month="month" + :date="date" + :disabled-date="disabledDate" + @on-pick="handleMonthPick">
\ No newline at end of file diff --git a/src/components/date-picker/picker.vue b/src/components/date-picker/picker.vue index 34f39e7..dc3dfb9 100644 --- a/src/components/date-picker/picker.vue +++ b/src/components/date-picker/picker.vue @@ -1,9 +1,7 @@ @@ -52,7 +54,7 @@ value: { type: [String, Number], default: '', - twoWay: true +// twoWay: true }, size: { validator (value) { @@ -139,6 +141,9 @@ handleBlur () { this.$emit('on-blur'); }, + handleChange () { + this.$emit('on-change', this.value); + }, resizeTextarea () { const autosize = this.autosize; if (!autosize || this.type !== 'textarea') { @@ -152,11 +157,10 @@ } }, watch: { - value (val) { + value () { this.$nextTick(() => { this.resizeTextarea(); }); - this.$emit('on-change', val); } }, ready () { diff --git a/src/styles/components/date-picker.less b/src/styles/components/date-picker.less index ff8adb0..2015a10 100644 --- a/src/styles/components/date-picker.less +++ b/src/styles/components/date-picker.less @@ -1,9 +1,11 @@ @date-picker-prefix-cls: ~"@{css-prefix}date-picker"; +@picker-prefix-cls: ~"@{css-prefix}picker"; .@{date-picker-prefix-cls} { position: relative; .@{select-dropdown-prefix-cls} { width: auto; + padding: 0; overflow: visible; max-height: none; } @@ -100,4 +102,75 @@ } } } + + &-cells-year,&-cells-month{ + margin-top: 14px; + span{ + width: 40px; + height: 28px; + line-height: 28px; + margin: 10px 12px; + border-radius: @btn-border-radius-small; + em{ + width: 40px; + height: 28px; + line-height: 28px; + margin: 0; + } + } + } + + &-header{ + height: 32px; + line-height: 32px; + text-align: center; + border-bottom: 1px solid @border-color-split; + &-label{ + cursor: pointer; + transition: color @transition-time @ease-in-out; + &:hover{ + color: @primary-color; + } + } + } + &-prev-btn{ + float: left; + &-arrow-double{ + margin-left: 10px; + i:after{ + content: "\F3D2"; + } + } + } + &-next-btn{ + float: right; + &-arrow-double{ + margin-right: 10px; + i:after{ + content: "\F3D3"; + } + } + } +} + +.@{picker-prefix-cls} { + &-panel{ + &-icon-btn{ + display: inline-block; + width: 20px; + height: 24px; + line-height: 26px; + margin-top: 4px; + text-align: center; + cursor: pointer; + color: @btn-disable-color; + transition: color @transition-time @ease-in-out; + &:hover{ + color: @primary-color; + } + i{ + font-size: 14px; + } + } + } } \ No newline at end of file diff --git a/test/routers/date.vue b/test/routers/date.vue index cb599a1..73618ab 100644 --- a/test/routers/date.vue +++ b/test/routers/date.vue @@ -1,23 +1,42 @@ \ No newline at end of file -- libgit2 0.21.4