Blame view

examples/routers/date.vue 10.1 KB
4c683651   Sergio Crisostomo   improve dev examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  <!--
  <template>
      <div>
          {{ value1 }}
          <Date-picker v-model="value1" type="datetimerange" placeholder="选择日期" style="width: 200px" @on-change="hc"></Date-picker>
          <Button @click="setDate">set date</Button>
          <Button @click="getDate">get date</Button>
          &lt;!&ndash;<Date-picker v-model="value2" type="daterange" placeholder="选择日期" style="width: 200px"></Date-picker>&ndash;&gt;
          &lt;!&ndash;<Date-picker transfer type="datetimerange" placeholder="选择日期" style="width: 200px" @on-change="changeDate"></Date-picker>&ndash;&gt;
      </div>
  </template>
  <script>
      export default {
          data () {
              return {
                  value1: ['2014-10-10 10:00:01', '2017-10-10 10:00:00'],
                  value2: []
              }
          },
          methods: {
              changeDate(date){
                  console.log(date);
              },
              setDate () {
                  this.value1 = ['2016-10-10', '2017-10-10'];
              },
              getDate () {
                  const date = new Date(this.value1);
                  console.log(date.getMonth()+1)
              },
              hc (d) {
                  console.log(d);
              }
          }
      }
  </script>
  <style>
      body{
          width: 100%;
      }
  </style>
  -->
531cd165   梁灏   support DatePicke...
43
  
b9a4026f   梁灏   fixed #845
44
  
531cd165   梁灏   support DatePicke...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
  <!--<template>-->
      <!--<row>-->
          <!--<i-col span="12">-->
              <!--<Date-picker type="date" :options="options1" placeholder="选择日期" style="width: 200px"></Date-picker>-->
          <!--</i-col>-->
          <!--<i-col span="12">-->
              <!--<Date-picker type="daterange" :options="options2" placement="bottom-end" placeholder="选择日期" style="width: 200px"></Date-picker>-->
          <!--</i-col>-->
      <!--</row>-->
  <!--</template>-->
  <!--<script>-->
      <!--export default {-->
          <!--data () {-->
              <!--return {-->
                  <!--options1: {-->
                      <!--shortcuts: [-->
                          <!--{-->
                              <!--text: '今天',-->
                              <!--value () {-->
                                  <!--return new Date();-->
                              <!--},-->
                              <!--onClick: (picker) => {-->
                                  <!--this.$Message.info('点击了今天');-->
                              <!--}-->
                          <!--},-->
                          <!--{-->
                              <!--text: '昨天',-->
                              <!--value () {-->
                                  <!--const date = new Date();-->
                                  <!--date.setTime(date.getTime() - 3600 * 1000 * 24);-->
                                  <!--return date;-->
                              <!--},-->
                              <!--onClick: (picker) => {-->
                                  <!--this.$Message.info('点击了昨天');-->
                              <!--}-->
                          <!--},-->
                          <!--{-->
                              <!--text: '一周前',-->
                              <!--value () {-->
                                  <!--const date = new Date();-->
                                  <!--date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);-->
                                  <!--return date;-->
                              <!--},-->
                              <!--onClick: (picker) => {-->
                                  <!--this.$Message.info('点击了一周前');-->
                              <!--}-->
                          <!--}-->
                      <!--]-->
                  <!--},-->
                  <!--options2: {-->
                      <!--shortcuts: [-->
                          <!--{-->
                              <!--text: '最近一周',-->
                              <!--value () {-->
                                  <!--const end = new Date();-->
                                  <!--const start = new Date();-->
                                  <!--start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);-->
                                  <!--return [start, end];-->
                              <!--}-->
                          <!--},-->
                          <!--{-->
                              <!--text: '最近一个月',-->
                              <!--value () {-->
                                  <!--const end = new Date();-->
                                  <!--const start = new Date();-->
                                  <!--start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);-->
                                  <!--return [start, end];-->
                              <!--}-->
                          <!--},-->
                          <!--{-->
                              <!--text: '最近三个月',-->
                              <!--value () {-->
                                  <!--const end = new Date();-->
                                  <!--const start = new Date();-->
                                  <!--start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);-->
                                  <!--return [start, end];-->
                              <!--}-->
                          <!--}-->
                      <!--]-->
                  <!--}-->
              <!--}-->
          <!--}-->
      <!--}-->
  <!--</script>-->
  
  
  <!--<template>-->
      <!--<row>-->
          <!--<i-col span="12">-->
              <!--<Date-picker :value="value1" format="yyyy年MM月dd日" type="date" placeholder="选择日期" style="width: 200px"></Date-picker>-->
          <!--</i-col>-->
          <!--<i-col span="12">-->
              <!--<Date-picker :value="value2" format="yyyy/MM/dd" type="daterange" placement="bottom-end" placeholder="选择日期" style="width: 200px"></Date-picker>-->
          <!--</i-col>-->
      <!--</row>-->
  <!--</template>-->
  <!--<script>-->
      <!--export default {-->
          <!--data () {-->
              <!--return {-->
                  <!--value1: '2016-01-01',-->
                  <!--value2: ['2016-01-01', '2016-02-15']-->
              <!--}-->
          <!--}-->
      <!--}-->
  <!--</script>-->
  
  
4c683651   Sergio Crisostomo   improve dev examples
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
  <template>
      <div>
          <div style="width: 50%; float: left;">
              <Date-picker type="date" placeholder="选择日期和时间" style="width: 200px"></Date-picker> | Single date, no date
              <br>
              <Date-picker type="datetime" placeholder="选择日期和时间" style="width: 200px"></Date-picker> | Single datetime, no date
              <br>
              <Date-picker type="datetime" v-model="dateString" placeholder="选择日期和时间" style="width: 200px"></Date-picker> | Single datetime, string date
              <br>
              <Date-picker type="datetime" v-model="singleDate" placeholder="选择日期和时间" style="width: 200px"></Date-picker> | Single datetime, date object
              <br>
              <Date-picker type="datetime" format="yyyy-MM-dd HH:mm" placeholder="选择日期和时间(不含秒)" style="width: 200px"></Date-picker> | Single datetime, format yyyy-MM-dd HH:mm
              <br>
              <Date-picker type="date" multiple style="width: 200px"></Date-picker> | Single date, multiple
              <br>
e55ba7a2   Sergio Crisostomo   Add week numbers
168
169
              <Date-picker type="date" multiple style="width: 200px" show-week-numbers></Date-picker> | Single date, multiple, show week numbers
              <br>
4c683651   Sergio Crisostomo   improve dev examples
170
171
              <Date-picker type="date" format="yyyy-MM-dd HH:mm" placeholder="选择日期和时间(不含秒)" style="width: 200px"></Date-picker> | Single date, format MM-dd HH:mm
              <br>
ac231c9a   Sergio Crisostomo   examples
172
173
174
              <Date-picker type="datetime" :start-date="minDate" v-model="singleDate" placeholder="选择日期和时间" style="width: 200px"></Date-picker> | Single datetime, date object, start date
              <br>
  
4c683651   Sergio Crisostomo   improve dev examples
175
176
177
178
179
180
          </div>
          <div style="width: 50%; float: right;">
              <Date-picker type="datetimerange" :value="dateRange" placeholder="选择日期和时间" style="width: 300px"></Date-picker> | DateTimeRange, date objects
              <br>
              <Date-picker type="daterange" placeholder="选择日期和时间" style="width: 300px"></Date-picker> | Range, no dates
              <br>
ac231c9a   Sergio Crisostomo   examples
181
182
              <Date-picker type="daterange" split-panels placeholder="选择日期和时间" style="width: 300px"></Date-picker> | Range, no dates, split panels
              <br>
4c683651   Sergio Crisostomo   improve dev examples
183
184
185
186
187
188
189
190
191
192
              <Date-picker type="datetimerange" format="yyyy-MM-dd HH:mm" placeholder="选择日期和时间(不含秒)" style="width: 300px"></Date-picker> | DateTimeRange, format yyyy-MM-dd HH:mm
          </div>
          <div style="width: 50%; float: right;">
              <TimePicker type="timerange" placeholder="Select time" style="width: 168px"></TimePicker>
          </div>
      </div>
  </template>
  <script>
      export default {
          data(){
ac231c9a   Sergio Crisostomo   examples
193
194
              const now = new Date().getTime();
              const oneMonth = 2592e6;
4c683651   Sergio Crisostomo   improve dev examples
195
196
197
              return {
                  dateString: '2018-01-03 20:52:59',
                  singleDate: new Date(1978, 4, 10),
ac231c9a   Sergio Crisostomo   examples
198
199
200
                  dateRange: [new Date(2010, 4, 1), new Date()],
                  minDate: new Date(2010, 4, 1),
                  maxDate: new Date(now + oneMonth)
4c683651   Sergio Crisostomo   improve dev examples
201
202
203
204
              }
          }
      }
  </script>
531cd165   梁灏   support DatePicke...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  
  
  <!--<template>-->
      <!--<row>-->
          <!--<i-col span="12">-->
              <!--<Time-picker type="time" placeholder="选择时间" style="width: 168px"></Time-picker>-->
          <!--</i-col>-->
          <!--<i-col span="12">-->
              <!--<Time-picker type="timerange" placement="bottom-end" placeholder="选择时间" style="width: 168px"></Time-picker>-->
          <!--</i-col>-->
      <!--</row>-->
  <!--</template>-->
  <!--<script>-->
      <!--export default {-->
          <!--data () {-->
              <!--return {-->
                  <!--t1: ''-->
              <!--}-->
          <!--}-->
      <!--}-->
  <!--</script>-->
  
  
  
  
4c683651   Sergio Crisostomo   improve dev examples
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
  <!--<template>-->
      <!--<div>-->
          <!--<DatePicker v-model="value" @on-change="handleChange" type="daterange" placeholder="Select date" style="width: 200px"></DatePicker>-->
      <!--</div>-->
  <!--</template>-->
  <!--<script>-->
      <!--export default {-->
          <!--data () {-->
              <!--return {-->
                  <!--value: []-->
              <!--}-->
          <!--},-->
          <!--methods: {-->
              <!--handleChange (v) {-->
                  <!--console.log(v);-->
              <!--}-->
          <!--}-->
      <!--}-->
  <!--</script>-->