Blame view

examples/routers/table.vue 19.6 KB
8f230d68   huanghong   fixed table
1
2
3
4
5
6
7
  <style>
  table {
      border-collapse: collapse;
      border-spacing: 0;
  }
  </style>
  
2cb8a6d9   梁灏   commit Table comp...
8
  <template>
bb49347b   梁灏   fixed #2823
9
      <div>
6136e4dd   huanghong   fixed table horiz...
10
11
          <!-- <br><br><br><br><br> -->
          <!-- <Table border  :show-header='false' :columns="columns1" height="500" :data="data1"></Table> -->
9d304dd6   huanghong   fixed safari scro...
12
          <!-- <Table border :columns="columns1" height='300'></Table> -->
fda6dfa2   huanghong   column add prop m...
13
14
          <!-- <br><br><br><br><br> -->
          <!-- <Table width="550" height="200" border :columns="columns2" :data="data4"></Table> -->
9ea47cb3   梁灏   fixed Table multi...
15
          <!--<br><br><br><br><br>-->
77201524   huanghong   column add prop m...
16
          <!-- <Table border :columns="columns5" height="240" :data="data5"></Table> -->
fda6dfa2   huanghong   column add prop m...
17
          <!-- <br><br><br><br><br> -->
77201524   huanghong   column add prop m...
18
          <!-- <Table border :columns="columns6" :data="data5"></Table> -->
fda6dfa2   huanghong   column add prop m...
19
          <!-- <br><br><br><br><br> -->
6136e4dd   huanghong   fixed table horiz...
20
21
          <!-- <Table border  :show-header='false' :columns="columns7"  height="200" :data="data7"></Table> -->
          <!-- <Table border :columns="columns7"  height="240" :data="data7"></Table> -->
fda6dfa2   huanghong   column add prop m...
22
          <!-- <br><br><br><br><br> -->
9d304dd6   huanghong   fixed safari scro...
23
24
          <!-- <Table border :columns="columns8"  :data="data7" height="200"></Table> -->
          <!-- <Table border :columns="columns8" height="200"></Table> -->
6136e4dd   huanghong   fixed table horiz...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
          <!-- <br><br><br><br><br> -->
  
          <div class="layout-demo-con">
              <Button @click="change">修改Sider绑定的变量来控制收缩</Button>
              <Layout :style="{minHeight: '80vh'}">
                  <Sider 
                      v-model="isCollapsed"
                      collapsed-width="0" 
                      hide-trigger
                      breakpoint="sm"
                      @on-collapse="changed"
                      collapsible
                      ref="side"
                      width="200">
                      <Menu width="auto" theme="dark" active-name="1">
                          <MenuGroup title="内容管理">
                              <MenuItem name="1">
                                  <Icon type="document-text"></Icon>
                                  文章管理
                              </MenuItem>
                              <MenuItem name="2">
                                  <Icon type="chatbubbles"></Icon>
                                  评论管理
                              </MenuItem>
                          </MenuGroup>
                          <MenuGroup title="统计分析">
                              <MenuItem name="3">
                                  <Icon type="heart"></Icon>
                                  用户留存
                              </MenuItem>
                              <MenuItem name="4">
                                  <Icon type="heart-broken"></Icon>
                                  流失用户
                              </MenuItem>
                          </MenuGroup>
                      </Menu>
                      <!-- <div slot="trigger"><Icon type="document-text"></Icon></div> -->
                  </Sider>
                  <Layout class-name="test-class">
                      <Header :style="{background: '#eee'}"><Button @click="toggleCollapse">菜单</Button></Header>
                      <Content :style="{background:'#FFCF9E'}">
                          <!-- <Table border  :columns="columns1" height="500" :data="data1"></Table> -->
0f983a5c   huanghong   update table colu...
67
68
69
                          <!-- <br> -->
                          <!-- <Table border :columns="columns5" :data="data5"></Table> -->
                          <Table border :columns="columns8"  height="240" :data="data7"></Table>
6136e4dd   huanghong   fixed table horiz...
70
71
72
73
74
                      </Content>
                      <Footer>sdfsdsdfsdfs</Footer>
                  </Layout>
              </Layout>
          </div>
bb49347b   梁灏   fixed #2823
75
      </div>
2cb8a6d9   梁灏   commit Table comp...
76
77
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
78
      export default {
51356c2c   梁灏   fixed #658
79
80
          data () {
              return {
6136e4dd   huanghong   fixed table horiz...
81
                  isCollapsed: false,
1acabf79   梁灏   Table support mul...
82
                  columns1: [
437b8059   Sergio Crisostomo   Added Table to CS...
83
                      {
55f90d87   梁灏   fixed #1648
84
                          title: 'Name',
14d1de05   huanghong   fix table changin...
85
                          key: 'name',
1acabf79   梁灏   Table support mul...
86
                          align: 'center',
fda6dfa2   huanghong   column add prop m...
87
88
                          minWidth: 100,
                          maxWidth: 200,
9ea47cb3   梁灏   fixed Table multi...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
                          fixed: 'left',
                          filters: [
                              {
                                  label: 'Joe',
                                  value: 1
                              },
                              {
                                  label: 'John',
                                  value: 2
                              }
                          ],
                          filterMultiple: false,
                          filterMethod (value, row) {
                              if (value === 1) {
                                  return row.name === 'Joe';
                              } else if (value === 2) {
                                  return row.name === 'John Brown';
                              }
                          }
14d1de05   huanghong   fix table changin...
108
109
                      },
                      {
1acabf79   梁灏   Table support mul...
110
111
112
113
114
115
116
                          title: 'Other',
                          align: 'center',
                          children: [
                              {
                                  title: 'Age',
                                  key: 'age',
                                  align: 'center',
fda6dfa2   huanghong   column add prop m...
117
118
                                  minWidth: 100,
                                  maxWidth: 200,
9ea47cb3   梁灏   fixed Table multi...
119
                                  sortable: true
1acabf79   梁灏   Table support mul...
120
121
122
123
124
125
126
127
128
                              },
                              {
                                  title: 'Address',
                                  align: 'center',
                                  children: [
                                      {
                                          title: 'Street',
                                          key: 'street',
                                          align: 'center',
fda6dfa2   huanghong   column add prop m...
129
130
                                          minWidth: 100,
                                          maxWidth: 200,
1acabf79   梁灏   Table support mul...
131
132
133
134
135
136
137
138
139
                                      },
                                      {
                                          title: 'Block',
                                          align: 'center',
                                          children: [
                                              {
                                                  title: 'Building',
                                                  key: 'building',
                                                  align: 'center',
fda6dfa2   huanghong   column add prop m...
140
141
                                                  minWidth: 100,
                                                  maxWidth: 200,
9ea47cb3   梁灏   fixed Table multi...
142
                                                  sortable: true
1acabf79   梁灏   Table support mul...
143
144
145
146
147
                                              },
                                              {
                                                  title: 'Door No.',
                                                  key: 'door',
                                                  align: 'center',
fda6dfa2   huanghong   column add prop m...
148
149
                                                  minWidth: 100,
                                                  maxWidth: 200,
1acabf79   梁灏   Table support mul...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
                                              }
                                          ]
                                      }
                                  ]
                              }
                          ]
                      },
                      {
                          title: 'Company',
                          align: 'center',
                          children: [
                              {
                                  title: 'Company Address',
                                  key: 'caddress',
                                  align: 'center',
fda6dfa2   huanghong   column add prop m...
165
166
                                  minWidth: 100,
                                  maxWidth: 200,
1acabf79   梁灏   Table support mul...
167
168
169
170
171
                              },
                              {
                                  title: 'Company Name',
                                  key: 'cname',
                                  align: 'center',
fda6dfa2   huanghong   column add prop m...
172
173
                                  minWidth: 100,
                                  maxWidth: 200,
1acabf79   梁灏   Table support mul...
174
175
176
                              }
                          ]
                      },
75803add   huanghong   fixed scoll bar
177
178
179
180
181
182
183
                      // {
                      //     title: 'Gender',
                      //     key: 'gender',
                      //     align: 'center',
                      //     width: 200,
                      //     fixed: 'right'
                      // },
1acabf79   梁灏   Table support mul...
184
185
186
187
                      {
                          title: 'Gender',
                          key: 'gender',
                          align: 'center',
fda6dfa2   huanghong   column add prop m...
188
189
                          minWidth: 100,
                          maxWidth: 200,
77201524   huanghong   column add prop m...
190
                          fixed: 'right'
437b8059   Sergio Crisostomo   Added Table to CS...
191
192
                      }
                  ],
9fea8e7d   huanghong   fixed ivu-table-f...
193
194
195
196
197
198
199
200
201
202
                  columns2: [
                      {
                          title: 'Name',
                          key: 'name',
                          width: 100,
                          fixed: 'left'
                      },
                      {
                          title: 'Age',
                          key: 'age',
1acabf79   梁灏   Table support mul...
203
204
205
                          width: 100,
                          fixed: 'right',
                          sortable: true
9fea8e7d   huanghong   fixed ivu-table-f...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
                      },
                      {
                          title: 'Province',
                          key: 'province',
                          width: 100
                      },
                      {
                          title: 'City',
                          key: 'city',
                          width: 100
                      },
                      {
                          title: 'Address',
                          key: 'address',
                          width: 200
                      },
                      {
                          title: 'Postcode',
                          key: 'zip',
1acabf79   梁灏   Table support mul...
225
                          width: 100
9fea8e7d   huanghong   fixed ivu-table-f...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
                      },
                      {
                          title: 'Action',
                          key: 'action',
                          fixed: 'right',
                          width: 120,
                          render: (h, params) => {
                              return h('div', [
                                  h('Button', {
                                      props: {
                                          type: 'text',
                                          size: 'small'
                                      }
                                  }, 'View'),
                                  h('Button', {
                                      props: {
                                          type: 'text',
                                          size: 'small'
                                      }
                                  }, 'Edit')
                              ]);
                          }
                      }
                  ],
1acabf79   梁灏   Table support mul...
250
251
                  data1: [],
                  data4: [
9fea8e7d   huanghong   fixed ivu-table-f...
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
                          province: 'America',
                          city: 'New York',
                          zip: 100000
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
                          address: 'Washington, D.C. No. 1 Lake Park',
                          province: 'America',
                          city: 'Washington, D.C.',
                          zip: 100000
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
                          province: 'Australian',
                          city: 'Sydney',
                          zip: 100000
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          province: 'Canada',
                          city: 'Ottawa',
                          zip: 100000
e25070eb   huanghong   fixed #2871
283
284
                      },
                      {
e25070eb   huanghong   fixed #2871
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
                          province: 'America',
                          city: 'New York',
                          zip: 100000
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
                          address: 'Washington, D.C. No. 1 Lake Park',
                          province: 'America',
                          city: 'Washington, D.C.',
                          zip: 100000
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
                          province: 'Australian',
                          city: 'Sydney',
                          zip: 100000
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          province: 'Canada',
                          city: 'Ottawa',
                          zip: 100000
9fea8e7d   huanghong   fixed ivu-table-f...
315
                      }
9ea47cb3   梁灏   fixed Table multi...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
                  ],
                  columns5: [
                      {
                          title: 'Date',
                          key: 'date',
                          sortable: true
                      },
                      {
                          title: 'Name',
                          key: 'name'
                      },
                      {
                          title: 'Age',
                          key: 'age',
                          sortable: true
                      },
                      {
                          title: 'Address',
                          key: 'address'
                      }
                  ],
                  data5: [
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
                          date: '2016-10-03'
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
                          date: '2016-10-02'
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          date: '2016-10-04'
                      }
                  ],
                  columns6: [
                      {
                          title: 'Date',
                          key: 'date'
                      },
                      {
                          title: 'Name',
                          key: 'name'
                      },
                      {
                          title: 'Age',
                          key: 'age',
                          filters: [
                              {
                                  label: 'Greater than 25',
                                  value: 1
                              },
                              {
                                  label: 'Less than 25',
                                  value: 2
                              }
                          ],
                          filterMultiple: false,
                          filterMethod (value, row) {
                              if (value === 1) {
                                  return row.age > 25;
                              } else if (value === 2) {
                                  return row.age < 25;
                              }
                          }
                      },
                      {
                          title: 'Address',
                          key: 'address',
6b90a39c   huanghong   table example
397
                          fixed: 'right',
9ea47cb3   梁灏   fixed Table multi...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
                          filters: [
                              {
                                  label: 'New York',
                                  value: 'New York'
                              },
                              {
                                  label: 'London',
                                  value: 'London'
                              },
                              {
                                  label: 'Sydney',
                                  value: 'Sydney'
                              }
                          ],
                          filterMethod (value, row) {
                              return row.address.indexOf(value) > -1;
                          }
                      }
                  ],
75803add   huanghong   fixed scoll bar
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
                  
                  columns7: [
                      {
                          title: 'Date',
                          key: 'date',
                          sortable: true,
                          width:200,
                      },
                      {
                          title: 'Name',
                          key: 'name',
                          width:200,
                      },
                      {
                          title: 'Age',
                          key: 'age',
9d304dd6   huanghong   fixed safari scro...
433
                          width:200,
75803add   huanghong   fixed scoll bar
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
                      },
                      {
                          title: 'Address',
                          key: 'address',
                          width:200,
                      }
                  ],
                  data7: [
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
                          date: '2016-10-03'
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park Sydney No. 1 Lake Park',
                          date: '2016-10-02'
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park Ottawa No. 2 Lake Park Ottawa No. 2 Lake Park',
                          date: '2016-10-04'
                      }
                  ],
77201524   huanghong   column add prop m...
467
468
469
                  
                  columns8: [
                      {
3f5e84a1   huanghong   update table colu...
470
471
472
473
474
475
                          title: 'Address',
                          key: 'address',
                          minWidth:200,
                          //maxWidth:300,
                      },
                      {
77201524   huanghong   column add prop m...
476
477
478
                          title: 'Date',
                          key: 'date',
                          sortable: true,
3f5e84a1   huanghong   update table colu...
479
                          minWidth:100,
0f983a5c   huanghong   update table colu...
480
                          maxWidth:150,
77201524   huanghong   column add prop m...
481
482
483
484
485
486
487
488
489
490
                      },
                      {
                          title: 'Name',
                          key: 'name',
                          minWidth:100,
                          maxWidth:200,
                      },
                      {
                          title: 'Age',
                          key: 'age',
0f983a5c   huanghong   update table colu...
491
492
                          minWidth:60,
                          maxWidth:100,
77201524   huanghong   column add prop m...
493
                      },
77201524   huanghong   column add prop m...
494
                  ],
bb49347b   梁灏   fixed #2823
495
496
              }
          },
1acabf79   梁灏   Table support mul...
497
498
          mounted () {
              const data = [];
9ea47cb3   梁灏   fixed Table multi...
499
              for (let i = 0; i < 20; i++) {
1acabf79   梁灏   Table support mul...
500
501
502
503
504
505
506
507
508
509
510
                  data.push({
                      key: i,
                      name: 'John Brown',
                      age: i + 1,
                      street: 'Lake Park',
                      building: 'C',
                      door: 2035,
                      caddress: 'Lake Street 42',
                      cname: 'SoftLake Co',
                      gender: 'M',
                  });
c5beedf8   梁灏   fixed #690
511
              }
1acabf79   梁灏   Table support mul...
512
              this.data1 = data;
6136e4dd   huanghong   fixed table horiz...
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
          },
          methods: {
              toggleCollapse () {
                  this.$refs.side.toggleCollapse();
              },
              change () {
                  this.isCollapsed = !this.isCollapsed;
              },
              changed (res) {
                  console.log(res)
              }
          },
          watch: {
              isCollapsed (val) {
                  // console.log(val)
              }
2cb8a6d9   梁灏   commit Table comp...
529
          }
6c634aa6   梁灏   fixed #2078
530
      }
4ad72493   梁灏   Revert Table demo
531
  </script>