Commit 2533a192dd8abbe30e42f0a0dbda25f393a63b07

Authored by 梁灏
1 parent 13be4434

update DatePicker

update DatePicker
src/components/date-picker/panel/date.vue
1 1 <template>
2   - <div :class="[prefixCls + '-body-wrapper']">
  2 + <div :class="classes">
3 3 <div :class="[prefixCls + '-sidebar']" v-if="shortcuts">
4 4 <div
5 5 :class="[prefixCls + '-shortcut']"
... ... @@ -91,6 +91,14 @@
91 91 }
92 92 },
93 93 computed: {
  94 + classes () {
  95 + return [
  96 + `${prefixCls}-body-wrapper`,
  97 + {
  98 + [`${prefixCls}-with-sidebar`]: this.shortcuts.length
  99 + }
  100 + ]
  101 + },
94 102 yearLabel () {
95 103 const year = this.year;
96 104 if (!year) return '';
... ... @@ -122,7 +130,8 @@
122 130 this.$emit('on-pick', '');
123 131 },
124 132 handleShortcutClick (shortcut) {
125   -
  133 + if (shortcut.value) this.$emit('on-pick', shortcut.value());
  134 + if (shortcut.onClick) shortcut.onClick(this);
126 135 },
127 136 iconBtnCls (direction, type = '') {
128 137 return [
... ...
src/components/table/table.vue
... ... @@ -454,14 +454,17 @@
454 454 let data = this.makeData();
455 455 let sortType = 'normal';
456 456 let sortIndex = -1;
  457 + let isCustom = false;
  458 +
457 459 for (let i = 0; i < this.cloneColumns.length; i++) {
458 460 if (this.cloneColumns[i]._sortType !== 'normal') {
459 461 sortType = this.cloneColumns[i]._sortType;
460 462 sortIndex = i;
  463 + isCustom = this.cloneColumns[i].sortable === 'custom';
461 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 468 return data;
466 469 },
467 470 makeDataWithFilter () {
... ...
src/styles/components/date-picker.less
... ... @@ -172,5 +172,25 @@
172 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 197 \ No newline at end of file
... ...
test/routers/date.vue
... ... @@ -3,6 +3,7 @@
3 3 <br>
4 4 <row>
5 5 <i-col span="4">
  6 + <!--<i-button @click="setDate">set date</i-button>-->
6 7 <date-picker
7 8 style="width:200px"
8 9 placeholder="请选择日期"
... ... @@ -25,17 +26,50 @@
25 26 export default {
26 27 data () {
27 28 return {
28   - value: new Date(),
29   -// value: '',
  29 +// value: new Date(),
  30 + value: '',
30 31 options: {
31 32 disabledDate(time) {
32 33 // console.log(time)
33 34 // return time.getFullYear() < 2016;
34 35 return time.getTime() < Date.now() - 8.64e7;
35 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 75 computed: {},
... ... @@ -45,6 +79,9 @@
45 79 },
46 80 change2 (s) {
47 81 // console.log(s)
  82 + },
  83 + setDate () {
  84 + this.value = '2016-12-24'
48 85 }
49 86 }
50 87 }
... ...