Blame view

examples/routers/table.vue 8.53 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'>
c1115edd   huanghong   fixed table
18
              <Table  :width='600' :height='200' border :columns="columns2" :data="data3"></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
153
154
                      },
                      {
                          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...
155
                  
b08bd8a8   huanghong   fixed height changed
156
                  fixedHeader: false,
944c0dac   huanghong   add example for d...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
                  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
180
                          title: 'Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6',
944c0dac   huanghong   add example for d...
181
182
                          key: 'data6'
                      },
bb49347b   梁灏   fixed #2823
183
184
185
                  ]
              }
          },
944c0dac   huanghong   add example for d...
186
187
188
          mounted(){
              this.refreshData();
          },
bb49347b   梁灏   fixed #2823
189
190
191
192
193
194
          methods: {
              handleSelectAll (status) {
                  this.$refs.selection.selectAll(status);
              },
              handleSetData () {
                  this.data1 = [
b142865e   梁灏   fixed #2102
195
196
197
198
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
199
                          date: '2016-10-03'
b142865e   梁灏   fixed #2102
200
201
202
203
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
ceeb9361   梁灏   fixed Table bug i...
204
205
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
b142865e   梁灏   fixed #2102
206
207
208
209
210
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
211
                          date: '2016-10-02'
b142865e   梁灏   fixed #2102
212
213
214
215
216
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
217
                          date: '2016-10-04'
437b8059   Sergio Crisostomo   Added Table to CS...
218
                      }
bb49347b   梁灏   fixed #2823
219
220
221
222
                  ];
              },
              handleClearData () {
                  this.data1 = [];
944c0dac   huanghong   add example for d...
223
224
225
226
227
228
229
230
231
232
              },
              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...
233
                          data6: ''+Math.floor(Math.random () * Math.random () * 100000000)+Math.floor(Math.random () * 100000000)+Math.floor(Math.random () * 100000000),
944c0dac   huanghong   add example for d...
234
235
236
237
238
239
                      });
                  }
                  this.tableData1 = data;
              },
              changePage(){
                  this.refreshData();
c5beedf8   梁灏   fixed #690
240
              }
2cb8a6d9   梁灏   commit Table comp...
241
          }
6c634aa6   梁灏   fixed #2078
242
      }
4ad72493   梁灏   Revert Table demo
243
  </script>