Blame view

examples/routers/table.vue 12.8 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
bb49347b   梁灏   fixed #2823
2
      <div>
14d1de05   huanghong   fix table changin...
3
          <Table border ref="selection" :columns="columns4" :data="data1" :height='258'></Table>
bb49347b   梁灏   fixed #2823
4
5
6
7
          <Button @click="handleSetData">Set Data</Button>
          <Button @click="handleClearData">Clear Data</Button>
          <Button @click="handleSelectAll(true)">Set all selected</Button>
          <Button @click="handleSelectAll(false)">Cancel all selected</Button>
9fea8e7d   huanghong   fixed ivu-table-f...
8
9
10
11
12
13
          <div style='margin:20px 0px'>
              <Table border :columns="columns2" :data="data3"></Table>
          </div>
          <div style='margin:20px 0px'>
              <Table :height='200' border :columns="columns2" :data="data3"></Table>
          </div>
95e1720c   huanghong   fix ivu-table-fix...
14
          <div style='margin:20px 0px'>
c1115edd   huanghong   fixed table
15
              <Table  :width='600' border :columns="columns2" :data="data3"></Table>
95e1720c   huanghong   fix ivu-table-fix...
16
17
          </div>
          <div style='margin:20px 0px'>
e25070eb   huanghong   fixed #2871
18
              <Table  :width='600' :height='200' border :columns="columns2" :data="data31"></Table>
95e1720c   huanghong   fix ivu-table-fix...
19
          </div>
ebaf3c1d   huanghong   table test
20
          <div style='margin:20px 0px;'>
b08bd8a8   huanghong   fixed height changed
21
22
              Table scrolling <i-switch v-model="fixedHeader" style="margin-right: 5px"></i-switch>
              <Table :data="tableData1" :columns="tableColumns1" :height="fixedHeader ? 250 : ''" stripe size='small'></Table>
944c0dac   huanghong   add example for d...
23
24
25
26
27
28
              <div style="margin: 10px;overflow: hidden">
                  <div style="float: right;">
                      <Page :total="100" show-sizer :current="1" @on-change="changePage"></Page>
                  </div>
              </div>
          </div>
9fea8e7d   huanghong   fixed ivu-table-f...
29
  
bb49347b   梁灏   fixed #2823
30
      </div>
2cb8a6d9   梁灏   commit Table comp...
31
32
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
33
      export default {
51356c2c   梁灏   fixed #658
34
35
          data () {
              return {
bb49347b   梁灏   fixed #2823
36
                  columns4: [
ceeb9361   梁灏   fixed Table bug i...
37
                      {
bb49347b   梁灏   fixed #2823
38
39
40
                          type: 'selection',
                          width: 60,
                          align: 'center'
ceeb9361   梁灏   fixed Table bug i...
41
                      },
437b8059   Sergio Crisostomo   Added Table to CS...
42
                      {
55f90d87   梁灏   fixed #1648
43
                          title: 'Name',
14d1de05   huanghong   fix table changin...
44
45
                          key: 'name',
                          width: 260
2993f4ee   梁灏   update Tab
46
47
                      },
                      {
55f90d87   梁灏   fixed #1648
48
                          title: 'Age',
bb49347b   梁灏   fixed #2823
49
                          key: 'age'
2993f4ee   梁灏   update Tab
50
51
                      },
                      {
55f90d87   梁灏   fixed #1648
52
                          title: 'Address',
14d1de05   huanghong   fix table changin...
53
54
55
56
57
58
59
                          key: 'address',
                          width: 260
                      },
                      {
                          title: 'Address',
                          key: 'address',
                          width: 260
437b8059   Sergio Crisostomo   Added Table to CS...
60
61
                      }
                  ],
bb49347b   梁灏   fixed #2823
62
63
                  data1: [
  
944c0dac   huanghong   add example for d...
64
                  ],
9fea8e7d   huanghong   fixed ivu-table-f...
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
                  columns2: [
                      {
                          title: 'Name',
                          key: 'name',
                          width: 100,
                          fixed: 'left'
                      },
                      {
                          title: 'Age',
                          key: 'age',
                          width: 100
                      },
                      {
                          title: 'Province',
                          key: 'province',
                          width: 100
                      },
                      {
                          title: 'City',
                          key: 'city',
                          width: 100
                      },
                      {
                          title: 'Address',
                          key: 'address',
                          width: 200
                      },
                      {
                          title: 'Postcode',
                          key: 'zip',
408b6950   huanghong   update table example
95
96
                          width: 100,
                          fixed: 'right',
9fea8e7d   huanghong   fixed ivu-table-f...
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
                      },
                      {
                          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')
                              ]);
                          }
                      }
                  ],
                  data3: [
                      {
                          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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          province: 'Canada',
                          city: 'Ottawa',
                          zip: 100000
                      }
                  ],
                  data31: [
                      {
                          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
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          province: 'Canada',
                          city: 'Ottawa',
                          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
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          province: 'Canada',
                          city: 'Ottawa',
                          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
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
                          province: 'Canada',
                          city: 'Ottawa',
                          zip: 100000
9fea8e7d   huanghong   fixed ivu-table-f...
267
268
                      }
                  ],
944c0dac   huanghong   add example for d...
269
                  
e25070eb   huanghong   fixed #2871
270
                  
b08bd8a8   huanghong   fixed height changed
271
                  fixedHeader: false,
944c0dac   huanghong   add example for d...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
                  tableData1: [],
                  tableColumns1: [
                      {
                          title: 'Data1',
                          key: 'data1'
                      },
                      {
                          title: 'Data2',
                          key: 'data2'
                      },
                      {
                          title: 'Data3',
                          key: 'data3'
                      },
                      {
                          title: 'Data4',
                          key: 'data4'
                      },
                      {
                          title: 'Data5',
                          key: 'data5'
                      },
                      {
ebaf3c1d   huanghong   table test
295
                          title: 'Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6',
944c0dac   huanghong   add example for d...
296
297
                          key: 'data6'
                      },
bb49347b   梁灏   fixed #2823
298
299
300
                  ]
              }
          },
944c0dac   huanghong   add example for d...
301
302
303
          mounted(){
              this.refreshData();
          },
bb49347b   梁灏   fixed #2823
304
305
306
307
308
309
          methods: {
              handleSelectAll (status) {
                  this.$refs.selection.selectAll(status);
              },
              handleSetData () {
                  this.data1 = [
b142865e   梁灏   fixed #2102
310
311
312
313
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
314
                          date: '2016-10-03'
b142865e   梁灏   fixed #2102
315
316
317
318
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
ceeb9361   梁灏   fixed Table bug i...
319
320
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
b142865e   梁灏   fixed #2102
321
322
323
324
325
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
326
                          date: '2016-10-02'
b142865e   梁灏   fixed #2102
327
328
329
330
331
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
332
                          date: '2016-10-04'
437b8059   Sergio Crisostomo   Added Table to CS...
333
                      }
bb49347b   梁灏   fixed #2823
334
335
336
337
                  ];
              },
              handleClearData () {
                  this.data1 = [];
944c0dac   huanghong   add example for d...
338
339
340
341
342
343
344
345
346
347
              },
              refreshData(){
                  let data = [];
                  for (let i = 0; i < 10; i++) {
                      data.push({
                          data1: Math.floor(Math.random () * 10000),
                          data2: Math.floor(Math.random () * 1000000),
                          data3: Math.floor(Math.random () * 100000000),
                          data4: Math.floor(Math.random () * Math.random () * 10000),
                          data5: Math.floor(Math.random () * Math.random () * 1000000),
47638ad8   huanghong   fixed table scrol...
348
                          data6: ''+Math.floor(Math.random () * Math.random () * 100000000)+Math.floor(Math.random () * 100000000)+Math.floor(Math.random () * 100000000),
944c0dac   huanghong   add example for d...
349
350
351
352
353
354
                      });
                  }
                  this.tableData1 = data;
              },
              changePage(){
                  this.refreshData();
c5beedf8   梁灏   fixed #690
355
              }
2cb8a6d9   梁灏   commit Table comp...
356
          }
6c634aa6   梁灏   fixed #2078
357
      }
4ad72493   梁灏   Revert Table demo
358
  </script>