Commit 2533a192dd8abbe30e42f0a0dbda25f393a63b07
1 parent
13be4434
update DatePicker
update DatePicker
Showing
4 changed files
with
76 additions
and
7 deletions
Show diff stats
src/components/date-picker/panel/date.vue
1 | <template> | 1 | <template> |
2 | - <div :class="[prefixCls + '-body-wrapper']"> | 2 | + <div :class="classes"> |
3 | <div :class="[prefixCls + '-sidebar']" v-if="shortcuts"> | 3 | <div :class="[prefixCls + '-sidebar']" v-if="shortcuts"> |
4 | <div | 4 | <div |
5 | :class="[prefixCls + '-shortcut']" | 5 | :class="[prefixCls + '-shortcut']" |
@@ -91,6 +91,14 @@ | @@ -91,6 +91,14 @@ | ||
91 | } | 91 | } |
92 | }, | 92 | }, |
93 | computed: { | 93 | computed: { |
94 | + classes () { | ||
95 | + return [ | ||
96 | + `${prefixCls}-body-wrapper`, | ||
97 | + { | ||
98 | + [`${prefixCls}-with-sidebar`]: this.shortcuts.length | ||
99 | + } | ||
100 | + ] | ||
101 | + }, | ||
94 | yearLabel () { | 102 | yearLabel () { |
95 | const year = this.year; | 103 | const year = this.year; |
96 | if (!year) return ''; | 104 | if (!year) return ''; |
@@ -122,7 +130,8 @@ | @@ -122,7 +130,8 @@ | ||
122 | this.$emit('on-pick', ''); | 130 | this.$emit('on-pick', ''); |
123 | }, | 131 | }, |
124 | handleShortcutClick (shortcut) { | 132 | handleShortcutClick (shortcut) { |
125 | - | 133 | + if (shortcut.value) this.$emit('on-pick', shortcut.value()); |
134 | + if (shortcut.onClick) shortcut.onClick(this); | ||
126 | }, | 135 | }, |
127 | iconBtnCls (direction, type = '') { | 136 | iconBtnCls (direction, type = '') { |
128 | return [ | 137 | return [ |
src/components/table/table.vue
@@ -454,14 +454,17 @@ | @@ -454,14 +454,17 @@ | ||
454 | let data = this.makeData(); | 454 | let data = this.makeData(); |
455 | let sortType = 'normal'; | 455 | let sortType = 'normal'; |
456 | let sortIndex = -1; | 456 | let sortIndex = -1; |
457 | + let isCustom = false; | ||
458 | + | ||
457 | for (let i = 0; i < this.cloneColumns.length; i++) { | 459 | for (let i = 0; i < this.cloneColumns.length; i++) { |
458 | if (this.cloneColumns[i]._sortType !== 'normal') { | 460 | if (this.cloneColumns[i]._sortType !== 'normal') { |
459 | sortType = this.cloneColumns[i]._sortType; | 461 | sortType = this.cloneColumns[i]._sortType; |
460 | sortIndex = i; | 462 | sortIndex = i; |
463 | + isCustom = this.cloneColumns[i].sortable === 'custom'; | ||
461 | break; | 464 | break; |
462 | } | 465 | } |
463 | } | 466 | } |
464 | - if (sortType !== 'normal') data = this.sortData(data, sortType, sortIndex); | 467 | + if (sortType !== 'normal' && !isCustom) data = this.sortData(data, sortType, sortIndex); |
465 | return data; | 468 | return data; |
466 | }, | 469 | }, |
467 | makeDataWithFilter () { | 470 | makeDataWithFilter () { |
src/styles/components/date-picker.less
@@ -172,5 +172,25 @@ | @@ -172,5 +172,25 @@ | ||
172 | font-size: 14px; | 172 | font-size: 14px; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | + | ||
176 | + &-body-wrapper&-with-sidebar{ | ||
177 | + padding-left: 92px; | ||
178 | + } | ||
179 | + &-sidebar{ | ||
180 | + width: 92px; | ||
181 | + float: left; | ||
182 | + margin-left: -92px; | ||
183 | + position: absolute; | ||
184 | + top: 0; | ||
185 | + bottom: 0; | ||
186 | + background: @border-color-split; | ||
187 | + border-radius: @border-radius-small 0 0 @border-radius-small; | ||
188 | + } | ||
189 | + &-shortcut{ | ||
190 | + | ||
191 | + } | ||
192 | + &-body{ | ||
193 | + float: left; | ||
194 | + } | ||
175 | } | 195 | } |
176 | } | 196 | } |
177 | \ No newline at end of file | 197 | \ No newline at end of file |
test/routers/date.vue
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | <br> | 3 | <br> |
4 | <row> | 4 | <row> |
5 | <i-col span="4"> | 5 | <i-col span="4"> |
6 | + <!--<i-button @click="setDate">set date</i-button>--> | ||
6 | <date-picker | 7 | <date-picker |
7 | style="width:200px" | 8 | style="width:200px" |
8 | placeholder="请选择日期" | 9 | placeholder="请选择日期" |
@@ -25,17 +26,50 @@ | @@ -25,17 +26,50 @@ | ||
25 | export default { | 26 | export default { |
26 | data () { | 27 | data () { |
27 | return { | 28 | return { |
28 | - value: new Date(), | ||
29 | -// value: '', | 29 | +// value: new Date(), |
30 | + value: '', | ||
30 | options: { | 31 | options: { |
31 | disabledDate(time) { | 32 | disabledDate(time) { |
32 | // console.log(time) | 33 | // console.log(time) |
33 | // return time.getFullYear() < 2016; | 34 | // return time.getFullYear() < 2016; |
34 | return time.getTime() < Date.now() - 8.64e7; | 35 | return time.getTime() < Date.now() - 8.64e7; |
35 | // return time && time.valueOf() < Date.now(); | 36 | // return time && time.valueOf() < Date.now(); |
36 | - } | 37 | + }, |
38 | + shortcuts: [ | ||
39 | + { | ||
40 | + text: '今天', | ||
41 | + value () { | ||
42 | + return new Date(); | ||
43 | + }, | ||
44 | + onClick () { | ||
45 | + console.log('点击了今天'); | ||
46 | + } | ||
47 | + }, | ||
48 | + { | ||
49 | + text: '昨天', | ||
50 | + value () { | ||
51 | + const date = new Date(); | ||
52 | + date.setTime(date.getTime() - 3600 * 1000 * 24); | ||
53 | + return date; | ||
54 | + }, | ||
55 | + onClick () { | ||
56 | + console.log('点击了昨天'); | ||
57 | + } | ||
58 | + }, | ||
59 | + { | ||
60 | + text: '一周前', | ||
61 | + value () { | ||
62 | + const date = new Date(); | ||
63 | + date.setTime(date.getTime() - 3600 * 1000 * 24 * 7); | ||
64 | + return date; | ||
65 | + }, | ||
66 | +// onClick () { | ||
67 | +// console.log('点击了一周前'); | ||
68 | +// } | ||
69 | + } | ||
70 | + ] | ||
37 | }, | 71 | }, |
38 | - format: 'yyyy年MM月dd日' | 72 | + format: 'yyyy-MM-dd' |
39 | } | 73 | } |
40 | }, | 74 | }, |
41 | computed: {}, | 75 | computed: {}, |
@@ -45,6 +79,9 @@ | @@ -45,6 +79,9 @@ | ||
45 | }, | 79 | }, |
46 | change2 (s) { | 80 | change2 (s) { |
47 | // console.log(s) | 81 | // console.log(s) |
82 | + }, | ||
83 | + setDate () { | ||
84 | + this.value = '2016-12-24' | ||
48 | } | 85 | } |
49 | } | 86 | } |
50 | } | 87 | } |