table.vue
4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
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
<template>
<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>
<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>
</div>
</template>
<script>
export default {
data () {
return {
columns4: [
{
type: 'selection',
width: 60,
align: 'center'
},
{
title: 'Name',
key: 'name'
},
{
title: 'Age',
key: 'age'
},
{
title: 'Address',
key: 'address'
}
],
data1: [
],
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'
},
]
}
},
mounted(){
this.refreshData();
},
methods: {
handleSelectAll (status) {
this.$refs.selection.selectAll(status);
},
handleSetData () {
this.data1 = [
{
name: 'John Brown',
age: 18,
address: 'New York No. 1 Lake Park',
date: '2016-10-03'
},
{
name: 'Jim Green',
age: 24,
address: 'London No. 1 Lake Park',
date: '2016-10-01'
},
{
name: 'Joe Black',
age: 30,
address: 'Sydney No. 1 Lake Park',
date: '2016-10-02'
},
{
name: 'Jon Snow',
age: 26,
address: 'Ottawa No. 2 Lake Park',
date: '2016-10-04'
}
];
},
handleClearData () {
this.data1 = [];
},
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();
}
}
}
</script>