Blame view

test/routers/date.vue 5.98 KB
0f677893   梁灏   update DatePicker
1
  <template>
3cf7cfd1   梁灏   update DatePicker
2
      <div style="margin: 50px">
b9041a0d   梁灏   DatePicker add co...
3
4
          <i-button @click="type = 'year'">year</i-button>
          <i-button @click="type = 'month'">month</i-button>
c46f385a   梁灏   update DatePicker
5
6
          <br>
          <row>
336b4f46   梁灏   fixed #132
7
              <i-col span="8">
2533a192   梁灏   update DatePicker
8
                  <!--<i-button @click="setDate">set date</i-button>-->
e1874103   梁灏   update DatePicker
9
                  <date-picker
b9041a0d   梁灏   DatePicker add co...
10
                          :type="type"
e1874103   梁灏   update DatePicker
11
12
13
                          style="width:200px"
                          placeholder="请选择日期"
                          :value.sync="value"
e1874103   梁灏   update DatePicker
14
                          @on-change="change"
b9041a0d   梁灏   DatePicker add co...
15
16
                          :confirm="true"
                          :options="options"
e9dd4dab   梁灏   publish 0.9.11-rc-1
17
18
19
20
                          open
                          @on-open-change="change2">
                      <p>123</p>
                  </date-picker>
c46f385a   梁灏   update DatePicker
21
              </i-col>
336b4f46   梁灏   fixed #132
22
              <i-col span="8">
3cf7cfd1   梁灏   update DatePicker
23
24
                  <date-picker
                          type="daterange"
7c5ccdab   梁灏   update DatePicker
25
                          style="width:300px"
3cf7cfd1   梁灏   update DatePicker
26
27
28
                          placeholder="请选择日期"
                          :value.sync="value2"
                          align="right"
7c5ccdab   梁灏   update DatePicker
29
                          :editable="true"
3602b78d   梁灏   update DatePicker
30
                          @on-change="change"
b9041a0d   梁灏   DatePicker add co...
31
                          :confirm="true"
3cf7cfd1   梁灏   update DatePicker
32
                          :options="options2"></date-picker>
c46f385a   梁灏   update DatePicker
33
34
              </i-col>
          </row>
0f677893   梁灏   update DatePicker
35
36
37
38
      </div>
  </template>
  <script>
      export default {
0f677893   梁灏   update DatePicker
39
          data () {
50637863   梁灏   update DatePicker
40
              return {
2533a192   梁灏   update DatePicker
41
  //                value: new Date(),
b9041a0d   梁灏   DatePicker add co...
42
                  type: 'date',
e55f00ff   梁灏   update DatePicker
43
                  value: '2016-12-25',
3cf7cfd1   梁灏   update DatePicker
44
                  value2: ['2016-12-17', '2017-01-05'],
e0cd7f90   梁灏   fixed #134
45
                  options2: {
7c5ccdab   梁灏   update DatePicker
46
47
48
49
50
51
52
53
54
55
56
  //                    disabledDate(time) {
  ////                        console.log(time)
  ////                        return time.getFullYear() < 2016;
  ////                        return time.getTime() < Date.now() - 8.64e7;
  ////                        return time && time.valueOf() < Date.now();
  //                        if (time.getDate() === 22 || time.getDate() === 23) {
  //                            return true;
  //                        } else {
  //                            return false;
  //                        }
  //                    },
3cf7cfd1   梁灏   update DatePicker
57
58
                      shortcuts: [
                          {
7c5ccdab   梁灏   update DatePicker
59
                              text: '最近一周',
3cf7cfd1   梁灏   update DatePicker
60
                              value () {
7c5ccdab   梁灏   update DatePicker
61
62
63
64
                                  const end = new Date();
                                  const start = new Date();
                                  start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                                  return [start, end];
3cf7cfd1   梁灏   update DatePicker
65
66
                              },
                              onClick (picker) {
7c5ccdab   梁灏   update DatePicker
67
                                  console.log('点击了最近一周');
3cf7cfd1   梁灏   update DatePicker
68
69
70
                              }
                          },
                          {
7c5ccdab   梁灏   update DatePicker
71
                              text: '最近一个月',
3cf7cfd1   梁灏   update DatePicker
72
                              value () {
7c5ccdab   梁灏   update DatePicker
73
74
75
76
                                  const end = new Date();
                                  const start = new Date();
                                  start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                                  return [start, end];
3cf7cfd1   梁灏   update DatePicker
77
78
                              },
                              onClick () {
7c5ccdab   梁灏   update DatePicker
79
                                  console.log('点击了最近一个月');
3cf7cfd1   梁灏   update DatePicker
80
81
82
83
84
                              }
                          },
                          {
                              text: '最近三个月',
                              value () {
7c5ccdab   梁灏   update DatePicker
85
86
87
88
                                  const end = new Date();
                                  const start = new Date();
                                  start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                                  return [start, end];
3cf7cfd1   梁灏   update DatePicker
89
90
                              },
                              onClick () {
7c5ccdab   梁灏   update DatePicker
91
                                  console.log('点击了最近三个月');
3cf7cfd1   梁灏   update DatePicker
92
93
94
                              }
                          }
                      ]
e0cd7f90   梁灏   fixed #134
95
                  },
50637863   梁灏   update DatePicker
96
97
                  options: {
                      disabledDate(time) {
13be4434   梁灏   update DatePicker
98
99
  //                        console.log(time)
  //                        return time.getFullYear() < 2016;
50637863   梁灏   update DatePicker
100
101
                          return time.getTime() < Date.now() - 8.64e7;
  //                        return time && time.valueOf() < Date.now();
2533a192   梁灏   update DatePicker
102
103
104
105
106
                      },
                      shortcuts: [
                          {
                              text: '今天',
                              value () {
e55f00ff   梁灏   update DatePicker
107
108
  //                                return new Date();
                                  return '1/2/19'
2533a192   梁灏   update DatePicker
109
                              },
e55f00ff   梁灏   update DatePicker
110
                              onClick (picker) {
2533a192   梁灏   update DatePicker
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
                                  console.log('点击了今天');
                              }
                          },
                          {
                              text: '昨天',
                              value () {
                                  const date = new Date();
                                  date.setTime(date.getTime() - 3600 * 1000 * 24);
                                  return date;
                              },
                              onClick () {
                                  console.log('点击了昨天');
                              }
                          },
                          {
6e572d44   梁灏   fixed #133
126
                              text: '最近三个月',
2533a192   梁灏   update DatePicker
127
128
129
130
131
                              value () {
                                  const date = new Date();
                                  date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                                  return date;
                              },
e55f00ff   梁灏   update DatePicker
132
133
134
                              onClick () {
                                  console.log('点击了一周前');
                              }
2533a192   梁灏   update DatePicker
135
136
                          }
                      ]
c46f385a   梁灏   update DatePicker
137
                  },
b9041a0d   梁灏   DatePicker add co...
138
                  format: 'yyyy-MM',
50637863   梁灏   update DatePicker
139
              }
0f677893   梁灏   update DatePicker
140
141
          },
          computed: {},
c46f385a   梁灏   update DatePicker
142
143
          methods: {
              change (date) {
699a9dc8   梁灏   update DatePicker
144
                  console.log(date)
c46f385a   梁灏   update DatePicker
145
146
147
              },
              change2 (s) {
  //                console.log(s)
2533a192   梁灏   update DatePicker
148
149
              },
              setDate () {
fa3a666d   梁灏   update DatePicker
150
  //                this.value = '2016-12-24'
0a5c5f41   梁灏   update DatePicker
151
                  this.value2 = ['2016-9-1', '2016-9-20']
c46f385a   梁灏   update DatePicker
152
153
              }
          }
0f677893   梁灏   update DatePicker
154
155
      }
  </script>