Former-commit-id: f3c11b2f64cc627044be20129050e193a8eec631 Former-commit-id: 49657d956a264020cda5ee3230870cf736197400 Former-commit-id: c3796afffe32e911c917133f2dc804cfe664acd7
66 lines
1.4 KiB
Vue
66 lines
1.4 KiB
Vue
<template>
|
|
<Container>
|
|
<PageHeader
|
|
slot="header"
|
|
title="导出表格">
|
|
</PageHeader>
|
|
<div class="dd-mb">
|
|
<el-button type="primary" @click="exportCsv">
|
|
<Icon name="download"></Icon>
|
|
导出 CSV
|
|
</el-button>
|
|
<el-button type="primary" @click="exportExcel">
|
|
<Icon name="download"></Icon>
|
|
导出 Excel
|
|
</el-button>
|
|
</div>
|
|
<el-table v-bind="table" style="width: 100%" class="dd-mb">
|
|
<el-table-column
|
|
v-for="(item, index) in table.columns"
|
|
:key="index"
|
|
:prop="item.prop"
|
|
:label="item.label">
|
|
</el-table-column>
|
|
</el-table>
|
|
<Markdown url="/static/md/插件 - 导出.md"></Markdown>
|
|
</Container>
|
|
</template>
|
|
|
|
<script>
|
|
// 假数据
|
|
import table from '../../data'
|
|
export default {
|
|
data () {
|
|
return {
|
|
table: {
|
|
columns: table.columns,
|
|
data: table.data,
|
|
size: 'mini',
|
|
stripe: true,
|
|
border: true
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
exportCsv (params = {}) {
|
|
this.$export.csv({
|
|
columns: this.table.columns,
|
|
data: this.table.data
|
|
})
|
|
.then(() => {
|
|
this.$message('导出CSV成功')
|
|
})
|
|
},
|
|
exportExcel () {
|
|
this.$export.excel({
|
|
columns: this.table.columns,
|
|
data: this.table.data
|
|
})
|
|
.then(() => {
|
|
this.$message('导出表格成功')
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|