no message

Former-commit-id: 749c159b54ea39951ddad455ca99256a55745644
Former-commit-id: 2dda6f7f898b9fc36d236eb478a615d9cd03ba1f
Former-commit-id: a21343caef3ca2939d104cbdba14780da79381ef
This commit is contained in:
李杨
2018-02-09 19:52:42 +08:00
parent c997f662e8
commit 554162775c
2 changed files with 14 additions and 11 deletions

View File

@@ -4,12 +4,12 @@
slot="header" slot="header"
title="基本示例"> title="基本示例">
</PageHeader> </PageHeader>
<div> <!-- <div>
<el-button @click="exportCsv"> <el-button @click="exportCsv">
<Icon name="download"></Icon> <Icon name="download"></Icon>
exportCsv exportCsv
</el-button> </el-button>
</div> </div> -->
<el-table v-bind="table" style="width: 100%" class="dd-mb"> <el-table v-bind="table" style="width: 100%" class="dd-mb">
<el-table-column <el-table-column
v-for="(item, index) in table.columns" v-for="(item, index) in table.columns"
@@ -25,8 +25,8 @@
// 假数据 // 假数据
import table from './data' import table from './data'
// 库 // 库
// import Csv from '@/utils/csv.js' import Csv from '@/utils/csv.js'
// import ExportCsv from '@/utils/export-csv.js' import ExportCsv from '@/utils/export-csv.js'
export default { export default {
data () { data () {
return { return {
@@ -39,12 +39,14 @@ export default {
} }
} }
}, },
mounted () {
this.exportCsv()
},
methods: { methods: {
exportCsv (params) { exportCsv (params = {}) {
let _params = Object.assign({}, params, { const noHeader = false
filename: 'table' const data = Csv(this.table.columns, this.table.data, params, noHeader)
}) ExportCsv.download('table.csv', data)
console.log(_params)
} }
} }
} }

View File

@@ -30,11 +30,12 @@ export default function csv(columns, datas, options, noHeader = false) {
if (columns) { if (columns) {
columnOrder = columns.map(v => { columnOrder = columns.map(v => {
console.log(v)
if (typeof v === 'string') return v; if (typeof v === 'string') return v;
if (!noHeader) { if (!noHeader) {
column.push(typeof v.title !== 'undefined' ? v.title : v.key); column.push(typeof v.label !== 'undefined' ? v.label : v.prop);
} }
return v.key; return v.prop;
}); });
if (column.length > 0) appendLine(content, column, options); if (column.length > 0) appendLine(content, column, options);
} else { } else {