Blame view

examples/routers/table.vue 10 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
ba8e03c6   梁灏   update Select che...
2
3
4
5
6
7
8
      <div>
          <Table :columns="columns8" :data="data7" size="small" ref="table"></Table>
          <br>
          <Button type="primary" size="large" @click="exportData(1)"><Icon type="ios-download-outline"></Icon> Export source data</Button>
          <Button type="primary" size="large" @click="exportData(2)"><Icon type="ios-download-outline"></Icon> Export sorting and filtered data</Button>
          <Button type="primary" size="large" @click="exportData(3)"><Icon type="ios-download-outline"></Icon> Export custom data</Button>
      </div>
2cb8a6d9   梁灏   commit Table comp...
9
10
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
11
      export default {
51356c2c   梁灏   fixed #658
12
13
          data () {
              return {
ba8e03c6   梁灏   update Select che...
14
                  columns8: [
a000231e   梁灏   update Table sort...
15
                      {
ba8e03c6   梁灏   update Select che...
16
17
18
19
                          "title": "Name",
                          "key": "name",
                          "fixed": "left",
                          "width": 200
a000231e   梁灏   update Table sort...
20
                      },
437b8059   Sergio Crisostomo   Added Table to CS...
21
                      {
ba8e03c6   梁灏   update Select che...
22
23
24
25
                          "title": "Show",
                          "key": "show",
                          "width": 150,
                          "sortable": true,
9f723b02   梁灏   update Table filt...
26
27
                          filters: [
                              {
ba8e03c6   梁灏   update Select che...
28
                                  label: 'Greater than 4000',
9f723b02   梁灏   update Table filt...
29
30
31
                                  value: 1
                              },
                              {
ba8e03c6   梁灏   update Select che...
32
                                  label: 'Less than 4000',
9f723b02   梁灏   update Table filt...
33
34
35
36
37
38
                                  value: 2
                              }
                          ],
                          filterMultiple: false,
                          filterMethod (value, row) {
                              if (value === 1) {
ba8e03c6   梁灏   update Select che...
39
                                  return row.show > 4000;
9f723b02   梁灏   update Table filt...
40
                              } else if (value === 2) {
ba8e03c6   梁灏   update Select che...
41
                                  return row.show < 4000;
9f723b02   梁灏   update Table filt...
42
43
                              }
                          }
9fea8e7d   huanghong   fixed ivu-table-f...
44
45
                      },
                      {
ba8e03c6   梁灏   update Select che...
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
                          "title": "Weak",
                          "key": "weak",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "Signin",
                          "key": "signin",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "Click",
                          "key": "click",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "Active",
                          "key": "active",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "7, retained",
                          "key": "day7",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "30, retained",
                          "key": "day30",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "The next day left",
                          "key": "tomorrow",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "Day Active",
                          "key": "day",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "Week Active",
                          "key": "week",
                          "width": 150,
                          "sortable": true
                      },
                      {
                          "title": "Month Active",
                          "key": "month",
                          "width": 150,
                          "sortable": true
a000231e   梁灏   update Table sort...
104
105
                      }
                  ],
ba8e03c6   梁灏   update Select che...
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
                  data7: [
                      {
                          "name": "Name1",
                          "fav": 0,
                          "show": 7302,
                          "weak": 5627,
                          "signin": 1563,
                          "click": 4254,
                          "active": 1438,
                          "day7": 274,
                          "day30": 285,
                          "tomorrow": 1727,
                          "day": 558,
                          "week": 4440,
                          "month": 5610
                      },
                      {
                          "name": "Name2",
                          "fav": 0,
                          "show": 4720,
                          "weak": 4086,
                          "signin": 3792,
                          "click": 8690,
                          "active": 8470,
                          "day7": 8172,
                          "day30": 5197,
                          "tomorrow": 1684,
                          "day": 2593,
                          "week": 2507,
                          "month": 1537
                      },
                      {
                          "name": "Name3",
                          "fav": 0,
                          "show": 7181,
                          "weak": 8007,
                          "signin": 8477,
                          "click": 1879,
                          "active": 16,
                          "day7": 2249,
                          "day30": 3450,
                          "tomorrow": 377,
                          "day": 1561,
                          "week": 3219,
                          "month": 1588
                      },
a000231e   梁灏   update Table sort...
152
                      {
ba8e03c6   梁灏   update Select che...
153
154
155
156
157
158
159
160
161
162
163
164
165
                          "name": "Name4",
                          "fav": 0,
                          "show": 9911,
                          "weak": 8976,
                          "signin": 8807,
                          "click": 8050,
                          "active": 7668,
                          "day7": 1547,
                          "day30": 2357,
                          "tomorrow": 7278,
                          "day": 5309,
                          "week": 1655,
                          "month": 9043
9ea47cb3   梁灏   fixed Table multi...
166
167
                      },
                      {
ba8e03c6   梁灏   update Select che...
168
169
170
171
172
173
174
175
176
177
178
179
180
                          "name": "Name5",
                          "fav": 0,
                          "show": 934,
                          "weak": 1394,
                          "signin": 6463,
                          "click": 5278,
                          "active": 9256,
                          "day7": 209,
                          "day30": 3563,
                          "tomorrow": 8285,
                          "day": 1230,
                          "week": 4840,
                          "month": 9908
9ea47cb3   梁灏   fixed Table multi...
181
182
                      },
                      {
ba8e03c6   梁灏   update Select che...
183
184
185
186
187
188
189
190
191
192
193
194
195
                          "name": "Name6",
                          "fav": 0,
                          "show": 6856,
                          "weak": 1608,
                          "signin": 457,
                          "click": 4949,
                          "active": 2909,
                          "day7": 4525,
                          "day30": 6171,
                          "tomorrow": 1920,
                          "day": 1966,
                          "week": 904,
                          "month": 6851
9ea47cb3   梁灏   fixed Table multi...
196
197
                      },
                      {
ba8e03c6   梁灏   update Select che...
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
                          "name": "Name7",
                          "fav": 0,
                          "show": 5107,
                          "weak": 6407,
                          "signin": 4166,
                          "click": 7970,
                          "active": 1002,
                          "day7": 8701,
                          "day30": 9040,
                          "tomorrow": 7632,
                          "day": 4061,
                          "week": 4359,
                          "month": 3676
                      },
                      {
                          "name": "Name8",
                          "fav": 0,
                          "show": 862,
                          "weak": 6520,
                          "signin": 6696,
                          "click": 3209,
                          "active": 6801,
                          "day7": 6364,
                          "day30": 6850,
                          "tomorrow": 9408,
                          "day": 2481,
                          "week": 1479,
                          "month": 2346
                      },
                      {
                          "name": "Name9",
                          "fav": 0,
                          "show": 567,
                          "weak": 5859,
                          "signin": 128,
                          "click": 6593,
                          "active": 1971,
                          "day7": 7596,
                          "day30": 3546,
                          "tomorrow": 6641,
                          "day": 1611,
                          "week": 5534,
                          "month": 3190
                      },
                      {
                          "name": "Name10",
                          "fav": 0,
                          "show": 3651,
                          "weak": 1819,
                          "signin": 4595,
                          "click": 7499,
                          "active": 7405,
                          "day7": 8710,
                          "day30": 5518,
                          "tomorrow": 428,
                          "day": 9768,
                          "week": 2864,
                          "month": 5811
021bbec2   梁灏   update Table Icons
256
                      }
ba8e03c6   梁灏   update Select che...
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
                  ]
              }
          },
          methods: {
              exportData (type) {
                  if (type === 1) {
                      this.$refs.table.exportCsv({
                          filename: 'The original data'
                      });
                  } else if (type === 2) {
                      this.$refs.table.exportCsv({
                          filename: 'Sorting and filtering data',
                          original: false
                      });
                  } else if (type === 3) {
                      this.$refs.table.exportCsv({
                          filename: 'Custom data',
                          columns: this.columns8.filter((col, index) => index < 4),
                          data: this.data7.filter((data, index) => index < 4)
                      });
                  }
021bbec2   梁灏   update Table Icons
278
              }
2cb8a6d9   梁灏   commit Table comp...
279
          }
6c634aa6   梁灏   fixed #2078
280
      }
021bbec2   梁灏   update Table Icons
281
  </script>