Former-commit-id: 61b3ce81f703f3b83d29c7ec9f1f58ac351e9feb [formerly 85631772690b91e0d39e1b9e90d23dae7d929c9a] [formerly 61b3ce81f703f3b83d29c7ec9f1f58ac351e9feb [formerly 85631772690b91e0d39e1b9e90d23dae7d929c9a] [formerly 61b3ce81f703f3b83d29c7ec9f1f58ac351e9feb [formerly 85631772690b91e0d39e1b9e90d23dae7d929c9a] [formerly 85631772690b91e0d39e1b9e90d23dae7d929c9a [formerly 8194f7e92144427b7c4947a93812a1cd0564a642 [formerly f4b7b47afbed6f98890de3ee269cbeae522f819e]]]]] Former-commit-id: ea4bebdc76ac4332d037f141867abe2d88211643 Former-commit-id: 2be71d915c7aca35f87f3cd91b313a4e1d92fdc5 Former-commit-id: cf55d88b39e1f3293deada0f7294e9938a15667b [formerly 19d9709c2a3c71a1a4cf268f80ebcaff05a6c97d] Former-commit-id: e8c7b6443a38f5d4311d19a8ecf9d5a65a5e3cd2 Former-commit-id: c68ed1fe39857770bef0feb198d6c8ab55a97959 Former-commit-id: cad71a8eb5306a6303be52cd6eed4021c16c93b6 Former-commit-id: 22d6241afd1762a0f999c89dcb24052504660e82 Former-commit-id: 3a183f17d724638f25c5f5ea70a368cdc3cd4f85
64 lines
1.4 KiB
Vue
64 lines
1.4 KiB
Vue
<template>
|
|
<d2-container :filename="filename" type="card">
|
|
<template slot="header">导出表格</template>
|
|
<div class="d2-mb">
|
|
<el-button type="primary" @click="exportCsv">
|
|
<d2-icon name="download"/>
|
|
导出 CSV
|
|
</el-button>
|
|
<el-button type="primary" @click="exportExcel">
|
|
<d2-icon name="download"/>
|
|
导出 Excel
|
|
</el-button>
|
|
</div>
|
|
<el-table v-bind="table" style="width: 100%">
|
|
<el-table-column
|
|
v-for="(item, index) in table.columns"
|
|
:key="index"
|
|
:prop="item.prop"
|
|
:label="item.label">
|
|
</el-table-column>
|
|
</el-table>
|
|
</d2-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,
|
|
header: '导出 Excel',
|
|
merges: ['A1', 'E1']
|
|
})
|
|
.then(() => {
|
|
this.$message('导出表格成功')
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|