cli3改版基本完成
Former-commit-id: 637e58a7d3aef389a4ea51c179aaee17f421f34c [formerly 637e58a7d3aef389a4ea51c179aaee17f421f34c [formerly 637e58a7d3aef389a4ea51c179aaee17f421f34c [formerly 637e58a7d3aef389a4ea51c179aaee17f421f34c [formerly fc66dcb2e437ff46b2c36ec1e3bcce71a6461250 [formerly b6451dc60d4c1e6006a9fcd380656d2023436e64]]]]] Former-commit-id: c791410cda91e2df1b9808bfb032f0d3d68106ef Former-commit-id: 0c5197800cfae6f27f7ab792c887fb25a73a23e0 Former-commit-id: 208a8e77c0fada6e9d191a7d495615ec2ef9704d [formerly af8c1367ed65b626196ac156c8521257cc804d60] Former-commit-id: 1fdb571cea6ed9dba9ea02f4ba6ebfb5d89e1b2f Former-commit-id: 774a145ae0694612edf988d9992ef797ddf4f21d Former-commit-id: 03fc24d70365836d60360aa24e24dc7cb4520b91 Former-commit-id: bba4fd5552fa42da029fd6b310f5ee48558d5508 Former-commit-id: 2de81d34fb07248965677e8a3866c13089fa95e7
This commit is contained in:
37
src/views/demo/plugins/export/data/index.js
Normal file
37
src/views/demo/plugins/export/data/index.js
Normal 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'
|
||||
}
|
||||
]
|
||||
}
|
||||
61
src/views/demo/plugins/export/table.vue
Normal file
61
src/views/demo/plugins/export/table.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<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
|
||||
})
|
||||
.then(() => {
|
||||
this.$message('导出表格成功')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
44
src/views/demo/plugins/export/txt.vue
Normal file
44
src/views/demo/plugins/export/txt.vue
Normal file
@@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<template slot="header">导出文本</template>
|
||||
<el-input
|
||||
type="textarea"
|
||||
:autosize="{minRows: 2, maxRows: 4}"
|
||||
placeholder="请输入内容 然后点击保存按钮导出文本文档"
|
||||
v-model="text">
|
||||
</el-input>
|
||||
<div class="d2-mt">
|
||||
<el-button type="primary" @click="exportTxt">
|
||||
<d2-icon name="download"/>
|
||||
保存为 txt
|
||||
</el-button>
|
||||
</div>
|
||||
</d2-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
text: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
exportTxt () {
|
||||
// 校验是不是空
|
||||
if (this.text === '') {
|
||||
this.$message('虽然可以为空 但是出于体验不建议这样 还是写点东西吧')
|
||||
return
|
||||
}
|
||||
// 导出
|
||||
this.$export.txt({
|
||||
text: this.text,
|
||||
title: '文本'
|
||||
})
|
||||
.then(() => {
|
||||
this.$message('导出文本成功')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user