Blame view

examples/routers/table.vue 8.06 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>
ebaf3c1d   huanghong   table test
14
          <div style='margin:20px 0px;'>
47638ad8   huanghong   fixed table scrol...
15
              <Table :data="tableData1" :columns="tableColumns1" :height='500' stripe size='small'></Table>
944c0dac   huanghong   add example for d...
16
17
18
19
20
21
              <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...
22
  
bb49347b   梁灏   fixed #2823
23
      </div>
2cb8a6d9   梁灏   commit Table comp...
24
25
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
26
      export default {
51356c2c   梁灏   fixed #658
27
28
          data () {
              return {
bb49347b   梁灏   fixed #2823
29
                  columns4: [
ceeb9361   梁灏   fixed Table bug i...
30
                      {
bb49347b   梁灏   fixed #2823
31
32
33
                          type: 'selection',
                          width: 60,
                          align: 'center'
ceeb9361   梁灏   fixed Table bug i...
34
                      },
437b8059   Sergio Crisostomo   Added Table to CS...
35
                      {
55f90d87   梁灏   fixed #1648
36
                          title: 'Name',
14d1de05   huanghong   fix table changin...
37
38
                          key: 'name',
                          width: 260
2993f4ee   梁灏   update Tab
39
40
                      },
                      {
55f90d87   梁灏   fixed #1648
41
                          title: 'Age',
bb49347b   梁灏   fixed #2823
42
                          key: 'age'
2993f4ee   梁灏   update Tab
43
44
                      },
                      {
55f90d87   梁灏   fixed #1648
45
                          title: 'Address',
14d1de05   huanghong   fix table changin...
46
47
48
49
50
51
52
                          key: 'address',
                          width: 260
                      },
                      {
                          title: 'Address',
                          key: 'address',
                          width: 260
437b8059   Sergio Crisostomo   Added Table to CS...
53
54
                      }
                  ],
bb49347b   梁灏   fixed #2823
55
56
                  data1: [
  
944c0dac   huanghong   add example for d...
57
                  ],
9fea8e7d   huanghong   fixed ivu-table-f...
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
                  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',
                          width: 100
                      },
                      {
                          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
                      }
                  ],
944c0dac   huanghong   add example for d...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
                  
                  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
171
                          title: 'Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6',
944c0dac   huanghong   add example for d...
172
173
                          key: 'data6'
                      },
bb49347b   梁灏   fixed #2823
174
175
176
                  ]
              }
          },
944c0dac   huanghong   add example for d...
177
178
179
          mounted(){
              this.refreshData();
          },
bb49347b   梁灏   fixed #2823
180
181
182
183
184
185
          methods: {
              handleSelectAll (status) {
                  this.$refs.selection.selectAll(status);
              },
              handleSetData () {
                  this.data1 = [
b142865e   梁灏   fixed #2102
186
187
188
189
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
190
                          date: '2016-10-03'
b142865e   梁灏   fixed #2102
191
192
193
194
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
ceeb9361   梁灏   fixed Table bug i...
195
196
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
b142865e   梁灏   fixed #2102
197
198
199
200
201
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
202
                          date: '2016-10-02'
b142865e   梁灏   fixed #2102
203
204
205
206
207
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
208
                          date: '2016-10-04'
437b8059   Sergio Crisostomo   Added Table to CS...
209
                      }
bb49347b   梁灏   fixed #2823
210
211
212
213
                  ];
              },
              handleClearData () {
                  this.data1 = [];
944c0dac   huanghong   add example for d...
214
215
216
217
218
219
220
221
222
223
              },
              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...
224
                          data6: ''+Math.floor(Math.random () * Math.random () * 100000000)+Math.floor(Math.random () * 100000000)+Math.floor(Math.random () * 100000000),
944c0dac   huanghong   add example for d...
225
226
227
228
229
230
                      });
                  }
                  this.tableData1 = data;
              },
              changePage(){
                  this.refreshData();
c5beedf8   梁灏   fixed #690
231
              }
2cb8a6d9   梁灏   commit Table comp...
232
          }
6c634aa6   梁灏   fixed #2078
233
      }
17db7df4   梁灏   fixed #1751
234
  </script>