Files
mes-ui-d2/src/pages/demo/plugins/import/xlsx.vue
liyang 3786b7ae04 lint
Former-commit-id: ecdadbbb5239575790787988dff81e89028e4b21 [formerly ecdadbbb5239575790787988dff81e89028e4b21 [formerly ecdadbbb5239575790787988dff81e89028e4b21 [formerly ecdadbbb5239575790787988dff81e89028e4b21 [formerly faa40145c1044f7d814aca7335e2958ee2af488f [formerly e7a26ae4b2b89f1095af40fabc80b6d7c28a88d7]]]]]
Former-commit-id: cdb18109e6f6405a153c0c77085cb26bfa2866f9
Former-commit-id: 9cd8dafaede8e06c29b9c1b28fbdc2a1ba3789e6
Former-commit-id: 8ee55ec8b9fa61ddc5c04797706db62c07e66fa9 [formerly cf46566d4316a4ac126dba8a16c9155133d6d6a1]
Former-commit-id: 7978ef3eb50dc580a497919fb7360ae382ebe71e
Former-commit-id: e0ae6ead53a9ea798a0746e72181f19c69786d2d
Former-commit-id: 784f3641d01fe1f6705725411e2abe95d0a3fd35
Former-commit-id: 13f3be9e685bd44b2c04b7821f1e737e4eefc7d9
Former-commit-id: 13aaa78b3f2f9808641261666f3c71aeb097dd9e
2018-09-11 16:46:24 +08:00

62 lines
1.4 KiB
Vue

<template>
<d2-container type="card">
<template slot="header">导入 xlsx</template>
<div class="d2-mb">
<el-button @click="download">
<d2-icon name="download"/>
下载演示 .xlsx 表格
</el-button>
</div>
<div class="d2-mb">
<el-upload :before-upload="handleUpload" action="default">
<el-button type="success">
<d2-icon name="file-o"/>
选择要导入的 .xlsx 表格
</el-button>
</el-upload>
</div>
<el-table v-bind="table">
<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>
export default {
data () {
return {
table: {
columns: [],
data: [],
size: 'mini',
stripe: true,
border: true
}
}
},
methods: {
handleUpload (file) {
this.$import.xlsx(file)
.then(({ header, results }) => {
this.table.columns = header.map(e => {
return {
label: e,
prop: e
}
})
this.table.data = results
})
return false
},
download () {
window.location.href = 'http://fairyever.qiniudn.com/d2-admin-import-xlsx-demo.xlsx'
}
}
}
</script>