Blame view

examples/routers/table.vue 4.29 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>
944c0dac   huanghong   add example for d...
8
9
10
11
12
13
14
15
          <div style="margin:20px 0px;">
              <Table :data="tableData1" :columns="tableColumns1"  style="width: 100%;" stripe></Table>
              <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
16
      </div>
2cb8a6d9   梁灏   commit Table comp...
17
18
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
19
      export default {
51356c2c   梁灏   fixed #658
20
21
          data () {
              return {
bb49347b   梁灏   fixed #2823
22
                  columns4: [
ceeb9361   梁灏   fixed Table bug i...
23
                      {
bb49347b   梁灏   fixed #2823
24
25
26
                          type: 'selection',
                          width: 60,
                          align: 'center'
ceeb9361   梁灏   fixed Table bug i...
27
                      },
437b8059   Sergio Crisostomo   Added Table to CS...
28
                      {
55f90d87   梁灏   fixed #1648
29
                          title: 'Name',
ceeb9361   梁灏   fixed Table bug i...
30
                          key: 'name'
2993f4ee   梁灏   update Tab
31
32
                      },
                      {
55f90d87   梁灏   fixed #1648
33
                          title: 'Age',
bb49347b   梁灏   fixed #2823
34
                          key: 'age'
2993f4ee   梁灏   update Tab
35
36
                      },
                      {
55f90d87   梁灏   fixed #1648
37
                          title: 'Address',
b34e09b8   梁灏   fixed #2832
38
                          key: 'address'
437b8059   Sergio Crisostomo   Added Table to CS...
39
40
                      }
                  ],
bb49347b   梁灏   fixed #2823
41
42
                  data1: [
  
944c0dac   huanghong   add example for d...
43
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
69
70
                  ],
                  
                  tableData1: [],
                  tableColumns1: [
                      {
                          title: 'Data1',
                          key: 'data1'
                      },
                      {
                          title: 'Data2',
                          key: 'data2'
                      },
                      {
                          title: 'Data3',
                          key: 'data3'
                      },
                      {
                          title: 'Data4',
                          key: 'data4'
                      },
                      {
                          title: 'Data5',
                          key: 'data5'
                      },
                      {
                          title: 'Data6',
                          key: 'data6'
                      },
bb49347b   梁灏   fixed #2823
71
72
73
                  ]
              }
          },
944c0dac   huanghong   add example for d...
74
75
76
          mounted(){
              this.refreshData();
          },
bb49347b   梁灏   fixed #2823
77
78
79
80
81
82
          methods: {
              handleSelectAll (status) {
                  this.$refs.selection.selectAll(status);
              },
              handleSetData () {
                  this.data1 = [
b142865e   梁灏   fixed #2102
83
84
85
86
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
87
                          date: '2016-10-03'
b142865e   梁灏   fixed #2102
88
89
90
91
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
ceeb9361   梁灏   fixed Table bug i...
92
93
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
b142865e   梁灏   fixed #2102
94
95
96
97
98
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
99
                          date: '2016-10-02'
b142865e   梁灏   fixed #2102
100
101
102
103
104
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
105
                          date: '2016-10-04'
437b8059   Sergio Crisostomo   Added Table to CS...
106
                      }
bb49347b   梁灏   fixed #2823
107
108
109
110
                  ];
              },
              handleClearData () {
                  this.data1 = [];
944c0dac   huanghong   add example for d...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
              },
              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),
                          data6: Math.floor(Math.random () * Math.random () * 100000000),
                      });
                  }
                  this.tableData1 = data;
              },
              changePage(){
                  this.refreshData();
c5beedf8   梁灏   fixed #690
128
              }
2cb8a6d9   梁灏   commit Table comp...
129
          }
6c634aa6   梁灏   fixed #2078
130
      }
17db7df4   梁灏   fixed #1751
131
  </script>