2424 :actions-def ='getActionsDef()' ,
2525 :row-action-def ='getRowActionsDef()' ,
2626 action-col-width ='200'
27- @row-click ='rowClick' )
27+ @row-click ='rowClick'
28+ ref ='table1' )
2829 el-table-column( prop ='flow_no' , label ='服务编号' , sortable ='custom' )
2930 el-table-column( prop ='content' , label ='服务内容' , sortable ='custom' )
3031 el-table-column( prop ='create_time' , label ='服务时间' , sortable ='custom' )
9899
99100 el-card
100101 .desc
101- p 事件 ( https://github.com/njleonzhang/vue-data-tables#event)
102+ a ( href = ' https://github.com/njleonzhang/vue-data-tables#event' ) 事件
102103 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等功能
104109 data-tables(
105110 :data ='tableData1' ,
111+ :actions-def ='getExportActionsDef()' ,
106112 :col-not-row-click ='["special_selection_col"]' ,
107113 @row-click ='rowClick' ,
108114 @select ='handleSelect' ,
145151<script >
146152import DataTables from ' ../../src/index.js'
147153import {cn } from ' ../mock'
154+ import CsvExport from ' ../utils/CsvExport'
148155
149156export default {
150157 name: ' app' ,
@@ -154,7 +161,9 @@ export default {
154161
155162 data () {
156163 return {
157- tableData: []
164+ tableData: [],
165+ tableData1: [],
166+ filteredData: []
158167 }
159168 },
160169
@@ -185,6 +194,7 @@ export default {
185194 }]
186195 }
187196 },
197+
188198 getCheckFilterDef () {
189199 return {
190200 width: 14 ,
@@ -225,6 +235,29 @@ export default {
225235 name: ' RUA'
226236 }]
227237 },
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+
228261 rowClick (row ) {
229262 this .$message (' row clicked' )
230263 console .log (' row clicked' , row)
@@ -240,6 +273,7 @@ export default {
240273 },
241274 handleFilterDataChange (filteredData ) {
242275 console .log (' handleFilterDataChange' , filteredData)
276+ this .filteredData = filteredData
243277 },
244278 getSearchDef () {
245279 return {
0 commit comments