24
24
:actions-def ='getActionsDef()' ,
25
25
:row-action-def ='getRowActionsDef()' ,
26
26
action-col-width ='200'
27
- @row-click ='rowClick' )
27
+ @row-click ='rowClick'
28
+ ref ='table1' )
28
29
el-table-column( prop ='flow_no' , label ='服务编号' , sortable ='custom' )
29
30
el-table-column( prop ='content' , label ='服务内容' , sortable ='custom' )
30
31
el-table-column( prop ='create_time' , label ='服务时间' , sortable ='custom' )
98
99
99
100
el-card
100
101
.desc
101
- p 事件 ( https://github.com/njleonzhang/vue-data-tables#event)
102
+ a ( href = ' https://github.com/njleonzhang/vue-data-tables#event' ) 事件
102
103
p 多数的事件都是对element-ui el-table事件的proxy
103
- p filtered-data事件用于传递过滤后数据,配合alasql(https://github.com/agershun/alasql)等库使用可以实现导出excel等功能
104
+ p filtered-data事件用于传递过滤后数据,配合
105
+ a( href ='https://github.com/zemirco/json2csv' ) json2csv
106
+ span 、
107
+ a( href ='https://github.com/agershun/alasql' ) alasql
108
+ span 等库使用可以实现导出excel等功能
104
109
data-tables(
105
110
:data ='tableData1' ,
111
+ :actions-def ='getExportActionsDef()' ,
106
112
:col-not-row-click ='["special_selection_col"]' ,
107
113
@row-click ='rowClick' ,
108
114
@select ='handleSelect' ,
145
151
<script >
146
152
import DataTables from ' ../../src/index.js'
147
153
import {cn } from ' ../mock'
154
+ import CsvExport from ' ../utils/CsvExport'
148
155
149
156
export default {
150
157
name: ' app' ,
@@ -154,7 +161,9 @@ export default {
154
161
155
162
data () {
156
163
return {
157
- tableData: []
164
+ tableData: [],
165
+ tableData1: [],
166
+ filteredData: []
158
167
}
159
168
},
160
169
@@ -185,6 +194,7 @@ export default {
185
194
}]
186
195
}
187
196
},
197
+
188
198
getCheckFilterDef () {
189
199
return {
190
200
width: 14 ,
@@ -225,6 +235,29 @@ export default {
225
235
name: ' RUA'
226
236
}]
227
237
},
238
+
239
+ getExportActionsDef () {
240
+ let columns = [' room_no' , ' cellphone' , ' flow_no' , ' state' ]
241
+ let columnNames = [' 房号' , ' 电话号码' , ' 订单号' , ' 状态' ]
242
+
243
+ return {
244
+ width: 19 ,
245
+ def: [{
246
+ name: ' export all' ,
247
+ handler : () => {
248
+ CsvExport (this .tableData1 , columns, columnNames, ' 所有数据' )
249
+ },
250
+ icon: ' plus'
251
+ }, {
252
+ name: ' export filtered' ,
253
+ handler : () => {
254
+ CsvExport (this .filteredData , columns, columnNames, ' 过滤后的数据' )
255
+ },
256
+ icon: ' upload'
257
+ }]
258
+ }
259
+ },
260
+
228
261
rowClick (row ) {
229
262
this .$message (' row clicked' )
230
263
console .log (' row clicked' , row)
@@ -240,6 +273,7 @@ export default {
240
273
},
241
274
handleFilterDataChange (filteredData ) {
242
275
console .log (' handleFilterDataChange' , filteredData)
276
+ this .filteredData = filteredData
243
277
},
244
278
getSearchDef () {
245
279
return {
0 commit comments