-
Notifications
You must be signed in to change notification settings - Fork 2
/
ele-easy-table-demo.vue
276 lines (275 loc) · 6.67 KB
/
ele-easy-table-demo.vue
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<template>
<div>
<ele-easy-table
:form="form"
:formData.sync="formData"
:table="table"
@get-list="handleSearch"
@handle-expand="handleExpand"
@selection-change="handleSelectionChange"
class="ele-easy-table-demo"
>
<template slot="slot1">
<el-button @click="test1()" size="small" type="primary">测试测试</el-button>
</template>
<template slot="slot2" slot-scope="{row}">
<el-dropdown :hide-on-click="false" @command="handleView">
<span class="el-dropdown-link">
<el-button type="text">操作</el-button>
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="{item:row,handle:'RecordDetail'}">查看详情</el-dropdown-item>
<el-dropdown-item :command="{item:row,handle:'RecordLog'}">查看日志</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<template slot="header1">
<span style="margin-right:8px">自定义标题</span>
<el-tooltip content="Top Center 提示文字" effect="dark" placement="top">
<i class="el-icon-info"></i>
</el-tooltip>
</template>
</ele-easy-table>
<CustomColumn
:baseColumns="baseColumns"
:columns.sync="table.columns"
:defaultColumns="defaultColumns"
:show.sync="showCustomColumn"
localName="ELEEASYTABLE_CUSTOM_COLUMNS"
/>
</div>
</template>
<script>
import CustomColumn from './custom-column'
const allList = [{
data1: '000',
data2: '第000000',
data5: 'aaa'
}, {
data1: '111',
data2: '第111111',
data5: 'bbb'
}, {
data1: '222',
data2: '第222222',
data5: 'ccc'
}, {
data1: '333',
data2: '第333333',
data5: 'ddd'
}, {
data1: '444',
data2: '第444444',
data5: 'eee'
}, {
data1: '555',
data2: '第555555',
data5: 'fff'
}, {
data1: '666',
data2: '第666666',
data5: 'ggg'
}, {
data1: '777',
data2: '第777777',
data5: 'hhh'
}, {
data1: '888',
data2: '第888888',
data5: 'iii'
}, {
data1: '999',
data2: '第999999',
data5: 'jjj'
}, {
data1: '101010',
data2: '第10101010',
data5: 'kkk'
}]
export default {
components: {
CustomColumn
},
data() {
return {
showCustomColumn: false,
formData: {
filterStartTime: "2019-01-01", //设置默认值
filterEndTime: "2019-01-07", //设置默认值
filterStartAndEndTime: ["2019-01-01", "2019-01-07"], //设置默认值
pageIndex: 1,
pageSize: 10,
totalCount: 11,
},
defaultColumns: ['data1', 'data3'],
baseColumns: [{
key: 'data1',
label: '标题1',
config: {
sortable: true
}
}, {
key: 'data2',
label: '标题2',
header: "header1",
type: 'format',
format: row => {
return row.data2 + '%';
}
}, {
key: 'data3',
label: '操作',
type: 'textBtn',
disabledCustom: true,
textBtn: [{
text: "操作一",
funcConfig: row => {
if (row.data1 === '333') return { disabled: true }
},
handleClick: (row, scope) => { console.log(row, scope) }
}, {
text: "操作二",
handleClick: (row, scope) => { console.log(row, scope) }
}, {
text: "操作三",
handleClick: (row, scope) => { console.log(row, scope) }
}]
}, {
key: 'data4',
label: '编辑',
type: 'slot',
slot: 'slot2'
}, {
key: 'data5',
label: 'APK'
}],
form: {
foldNum: 3,
config: { 'label-width': '100px' },
formItemStyle: {
width: "300px"
},
style: {
background: '#f2f2f2',
padding: '20px'
},
list: [{
type: 'datePicker',
key: 'filterStartAndEndTime',
startKey: 'filterStartTime',
endKey: 'filterEndTime',
label: '起止时间',
}, {
type: 'input',
key: 'modelName1',
label: '输入框1',
placeholder: "请输入姓名"
}, {
type: 'input',
key: 'modelName2',
label: '输入框2'
}, {
type: 'input',
key: 'modelName3',
label: '输入框3'
}, {
type: 'select',
key: 'productType',
config: {
filterable: true
},
options: [{
label: '全部',
value: ''
}, {
label: 'API',
value: 'API'
}, {
label: 'H5',
value: 'H5'
}],
label: '选择框'
}, {
type: 'select',
key: 'productName',
config: {
filterable: true
},
options: ['产品名称1', '产品名称2', '产品名称3'],
label: '产品名称'
}, {
type: 'select',
key: 'adType',
config: {
filterable: true
},
options: ['广告类型1', '广告类型2', '广告类型3'],
label: '广告类型'
}, {
type: 'button',
text: '查询',
handleClick: (row, key) => {
console.log(row, key);
this.handleSearch();
},
style: "margin-left:20px"
}, {
type: 'button',
text: '自定义列',
handleClick: () => {
this.showCustomColumn = true;
}
}, {
type: 'slot',
slot: 'slot1',
fold: false
}]
},
table: {
selection: {
show: true,
config: {
selectable: row => row.data1 !== '222'
}
},
list: [],
columns: []
}
}
},
methods: {
handleExpand(isExpand) {
console.log(isExpand ? "展开" : "收起");
},
getList() {
return allList.filter((item, key) =>
key < this.formData.pageSize * this.formData.pageIndex && key >= this.formData.pageSize * (this.formData.pageIndex - 1)
);
},
async handleSearch() {
console.log(this.formData);
this.table.list = this.getList()
},
handleSelectionChange(multipleSelection) {
console.log(multipleSelection);
},
test1() {
console.log('test1test1test1test1');
},
handleView(command) {
console.log(command);
}
},
created() {
this.table.list = this.getList()
}
}
</script>
<style scoped>
.ele-easy-table-demo >>> .el-table__header-wrapper {
position: sticky;
top: 0;
z-index: 999;
}
</style>