Blame view

examples/routers/table.vue 4.43 KB
2cb8a6d9   梁灏   commit Table comp...
1
  <template>
bb49347b   梁灏   fixed #2823
2
3
4
5
6
7
      <div>
          <Table border ref="selection" :columns="columns4" :data="data1"></Table>
          <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>
47638ad8   huanghong   fixed table scrol...
8
          
ebaf3c1d   huanghong   table test
9
          <div style='margin:20px 0px;'>
47638ad8   huanghong   fixed table scrol...
10
              <Table :data="tableData1" :columns="tableColumns1" :height='500' stripe size='small'></Table>
944c0dac   huanghong   add example for d...
11
12
13
14
15
16
              <div style="margin: 10px;overflow: hidden">
                  <div style="float: right;">
                      <Page :total="100" show-sizer :current="1" @on-change="changePage"></Page>
                  </div>
              </div>
          </div>
bb49347b   梁灏   fixed #2823
17
      </div>
2cb8a6d9   梁灏   commit Table comp...
18
19
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
20
      export default {
51356c2c   梁灏   fixed #658
21
22
          data () {
              return {
bb49347b   梁灏   fixed #2823
23
                  columns4: [
ceeb9361   梁灏   fixed Table bug i...
24
                      {
bb49347b   梁灏   fixed #2823
25
26
27
                          type: 'selection',
                          width: 60,
                          align: 'center'
ceeb9361   梁灏   fixed Table bug i...
28
                      },
437b8059   Sergio Crisostomo   Added Table to CS...
29
                      {
55f90d87   梁灏   fixed #1648
30
                          title: 'Name',
ceeb9361   梁灏   fixed Table bug i...
31
                          key: 'name'
2993f4ee   梁灏   update Tab
32
33
                      },
                      {
55f90d87   梁灏   fixed #1648
34
                          title: 'Age',
bb49347b   梁灏   fixed #2823
35
                          key: 'age'
2993f4ee   梁灏   update Tab
36
37
                      },
                      {
55f90d87   梁灏   fixed #1648
38
                          title: 'Address',
b34e09b8   梁灏   fixed #2832
39
                          key: 'address'
437b8059   Sergio Crisostomo   Added Table to CS...
40
41
                      }
                  ],
bb49347b   梁灏   fixed #2823
42
43
                  data1: [
  
944c0dac   huanghong   add example for d...
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
                  ],
                  
                  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
69
                          title: 'Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6Data6',
944c0dac   huanghong   add example for d...
70
71
                          key: 'data6'
                      },
bb49347b   梁灏   fixed #2823
72
73
74
                  ]
              }
          },
944c0dac   huanghong   add example for d...
75
76
77
          mounted(){
              this.refreshData();
          },
bb49347b   梁灏   fixed #2823
78
79
80
81
82
83
          methods: {
              handleSelectAll (status) {
                  this.$refs.selection.selectAll(status);
              },
              handleSetData () {
                  this.data1 = [
b142865e   梁灏   fixed #2102
84
85
86
87
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
88
                          date: '2016-10-03'
b142865e   梁灏   fixed #2102
89
90
91
92
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
ceeb9361   梁灏   fixed Table bug i...
93
94
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
b142865e   梁灏   fixed #2102
95
96
97
98
99
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
100
                          date: '2016-10-02'
b142865e   梁灏   fixed #2102
101
102
103
104
105
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
106
                          date: '2016-10-04'
437b8059   Sergio Crisostomo   Added Table to CS...
107
                      }
bb49347b   梁灏   fixed #2823
108
109
110
111
                  ];
              },
              handleClearData () {
                  this.data1 = [];
944c0dac   huanghong   add example for d...
112
113
114
115
116
117
118
119
120
121
              },
              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...
122
                          data6: ''+Math.floor(Math.random () * Math.random () * 100000000)+Math.floor(Math.random () * 100000000)+Math.floor(Math.random () * 100000000),
944c0dac   huanghong   add example for d...
123
124
125
126
127
128
                      });
                  }
                  this.tableData1 = data;
              },
              changePage(){
                  this.refreshData();
c5beedf8   梁灏   fixed #690
129
              }
2cb8a6d9   梁灏   commit Table comp...
130
          }
6c634aa6   梁灏   fixed #2078
131
      }
17db7df4   梁灏   fixed #1751
132
  </script>