Blame view

examples/routers/table.vue 4.66 KB
47638ad8   huanghong   fixed table scrol...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  <style>
      .table{
          margin:20px 0px;
      }
      .table .iview-table-cell{
          padding-left: 2px !important;
          padding-right: 2px !important;
  
      }
      .table .iview-table-small td {
          height: 30px !important;
      }
  </style>
  
2cb8a6d9   梁灏   commit Table comp...
15
  <template>
bb49347b   梁灏   fixed #2823
16
17
18
19
20
21
      <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...
22
23
24
          
          <div class="table1">
              <Table :data="tableData1" :columns="tableColumns1" :height='500' stripe size='small'></Table>
944c0dac   huanghong   add example for d...
25
26
27
28
29
30
              <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
31
      </div>
2cb8a6d9   梁灏   commit Table comp...
32
33
  </template>
  <script>
2cb8a6d9   梁灏   commit Table comp...
34
      export default {
51356c2c   梁灏   fixed #658
35
36
          data () {
              return {
bb49347b   梁灏   fixed #2823
37
                  columns4: [
ceeb9361   梁灏   fixed Table bug i...
38
                      {
bb49347b   梁灏   fixed #2823
39
40
41
                          type: 'selection',
                          width: 60,
                          align: 'center'
ceeb9361   梁灏   fixed Table bug i...
42
                      },
437b8059   Sergio Crisostomo   Added Table to CS...
43
                      {
55f90d87   梁灏   fixed #1648
44
                          title: 'Name',
ceeb9361   梁灏   fixed Table bug i...
45
                          key: 'name'
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',
b34e09b8   梁灏   fixed #2832
53
                          key: 'address'
437b8059   Sergio Crisostomo   Added Table to CS...
54
55
                      }
                  ],
bb49347b   梁灏   fixed #2823
56
57
                  data1: [
  
944c0dac   huanghong   add example for d...
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
                  ],
                  
                  tableData1: [],
                  tableColumns1: [
                      {
                          title: 'Data1',
                          key: 'data1'
                      },
                      {
                          title: 'Data2',
                          key: 'data2'
                      },
                      {
                          title: 'Data3',
                          key: 'data3'
                      },
                      {
                          title: 'Data4',
                          key: 'data4'
                      },
                      {
                          title: 'Data5',
                          key: 'data5'
                      },
                      {
47638ad8   huanghong   fixed table scrol...
83
                          title: '一二三四一二三四一二三四一二三四',
944c0dac   huanghong   add example for d...
84
85
                          key: 'data6'
                      },
bb49347b   梁灏   fixed #2823
86
87
88
                  ]
              }
          },
944c0dac   huanghong   add example for d...
89
90
91
          mounted(){
              this.refreshData();
          },
bb49347b   梁灏   fixed #2823
92
93
94
95
96
97
          methods: {
              handleSelectAll (status) {
                  this.$refs.selection.selectAll(status);
              },
              handleSetData () {
                  this.data1 = [
b142865e   梁灏   fixed #2102
98
99
100
101
                      {
                          name: 'John Brown',
                          age: 18,
                          address: 'New York No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
102
                          date: '2016-10-03'
b142865e   梁灏   fixed #2102
103
104
105
106
                      },
                      {
                          name: 'Jim Green',
                          age: 24,
ceeb9361   梁灏   fixed Table bug i...
107
108
                          address: 'London No. 1 Lake Park',
                          date: '2016-10-01'
b142865e   梁灏   fixed #2102
109
110
111
112
113
                      },
                      {
                          name: 'Joe Black',
                          age: 30,
                          address: 'Sydney No. 1 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
114
                          date: '2016-10-02'
b142865e   梁灏   fixed #2102
115
116
117
118
119
                      },
                      {
                          name: 'Jon Snow',
                          age: 26,
                          address: 'Ottawa No. 2 Lake Park',
ceeb9361   梁灏   fixed Table bug i...
120
                          date: '2016-10-04'
437b8059   Sergio Crisostomo   Added Table to CS...
121
                      }
bb49347b   梁灏   fixed #2823
122
123
124
125
                  ];
              },
              handleClearData () {
                  this.data1 = [];
944c0dac   huanghong   add example for d...
126
127
128
129
130
131
132
133
134
135
              },
              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...
136
                          data6: ''+Math.floor(Math.random () * Math.random () * 100000000)+Math.floor(Math.random () * 100000000)+Math.floor(Math.random () * 100000000),
944c0dac   huanghong   add example for d...
137
138
139
140
141
142
                      });
                  }
                  this.tableData1 = data;
              },
              changePage(){
                  this.refreshData();
c5beedf8   梁灏   fixed #690
143
              }
2cb8a6d9   梁灏   commit Table comp...
144
          }
6c634aa6   梁灏   fixed #2078
145
      }
17db7df4   梁灏   fixed #1751
146
  </script>