no message

Former-commit-id: b92f9e868330959cc6bbe4077384c468fbd2a695
Former-commit-id: 230d13822ebb3408c908967d2fac35f5a3ed0b07
Former-commit-id: ee34ffb35b16cd0b2b5c501095d4d4c1c06e9a8d
This commit is contained in:
李杨
2018-02-12 11:00:52 +08:00
parent 5a2544abe2
commit ac065aab6e
3 changed files with 4 additions and 4 deletions

View File

@@ -0,0 +1,37 @@
import Mock from 'mockjs'
const mockData = Mock.mock({
'data|3-6': [{
'id|+1': 1,
'name': '@CNAME',
'creatDate': '@DATE',
'address': '@CITY',
'zip': '@ZIP'
}]
})
export default {
data: mockData.data,
columns: [
{
label: 'ID',
prop: 'id'
},
{
label: '名称',
prop: 'name'
},
{
label: '创建日期',
prop: 'creatDate'
},
{
label: '地址',
prop: 'address'
},
{
label: '邮编',
prop: 'zip'
}
]
}

View File

@@ -0,0 +1,65 @@
<template>
<Container>
<PageHeader
slot="header"
title="基本示例">
</PageHeader>
<div class="dd-mb">
<el-button @click="exportCsv">
<Icon name="download"></Icon>
导出CSV
</el-button>
<el-button @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/markdownFiles/article/插件 - 导出数据.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>