no message
Former-commit-id: 749c159b54ea39951ddad455ca99256a55745644 Former-commit-id: 2dda6f7f898b9fc36d236eb478a615d9cd03ba1f Former-commit-id: a21343caef3ca2939d104cbdba14780da79381ef
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
slot="header"
|
||||
title="基本示例">
|
||||
</PageHeader>
|
||||
<div>
|
||||
<!-- <div>
|
||||
<el-button @click="exportCsv">
|
||||
<Icon name="download"></Icon>
|
||||
exportCsv
|
||||
</el-button>
|
||||
</div>
|
||||
</div> -->
|
||||
<el-table v-bind="table" style="width: 100%" class="dd-mb">
|
||||
<el-table-column
|
||||
v-for="(item, index) in table.columns"
|
||||
@@ -25,8 +25,8 @@
|
||||
// 假数据
|
||||
import table from './data'
|
||||
// 库
|
||||
// import Csv from '@/utils/csv.js'
|
||||
// import ExportCsv from '@/utils/export-csv.js'
|
||||
import Csv from '@/utils/csv.js'
|
||||
import ExportCsv from '@/utils/export-csv.js'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
@@ -39,12 +39,14 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.exportCsv()
|
||||
},
|
||||
methods: {
|
||||
exportCsv (params) {
|
||||
let _params = Object.assign({}, params, {
|
||||
filename: 'table'
|
||||
})
|
||||
console.log(_params)
|
||||
exportCsv (params = {}) {
|
||||
const noHeader = false
|
||||
const data = Csv(this.table.columns, this.table.data, params, noHeader)
|
||||
ExportCsv.download('table.csv', data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,12 @@ export default function csv(columns, datas, options, noHeader = false) {
|
||||
|
||||
if (columns) {
|
||||
columnOrder = columns.map(v => {
|
||||
console.log(v)
|
||||
if (typeof v === 'string') return v;
|
||||
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);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user