![在这里插入图片描述](https://img-blog.csdnimg.cn/07293a1bf6bf47de895cc9c8e95c1ea7.png)
下载模板
- 将Excel模板文件放在/public/CTEI.xls
- a 链接跳转下载
<a-button class="ml-20" type="primary">
<a href="/CTEI.xls" download="CTEI导入模板.xls" style="text-decoration: none">下载导入模板</a>
</a-button>
导入Excel
<a-upload
style="display:inline-block"
class="mlr-20"
name="file"
:action="uploadUrl"
:headers="headers"
@change="handleChange"
:showUploadList="false"
>
<a-button type="primary"> 导入Excel </a-button>
</a-upload>
headers: {
token: Vue.ls.get(ACCESS_TOKEN)
},
uploadUrl: '/api/system/ctei/batchCTEIImport',
handleChange(info) {
console.log(11111111111, info, info.file.response)
if (info.file.status === 'done') {
if (info.file.response.code == 500) {
this.$message.error(info.file.response.msg)
} else {
this.$message.success('导入成功')
}
} else if (info.file.status === 'error') {
this.$message.error(`${info.file.name} 导入失败`)
}
},
导出列表
<a-button type="primary" @click="exportEnt">
导出
</a-button>
exportEnt() {
this.$axios({
method: 'get',
url: '/api/system/ctei/exportCtei',
params: {
enterpriseId: this.enterpriseId
},
headers: {
token: Vue.ls.get(ACCESS_TOKEN),
'Content-Type': 'application/json;charset=UTF-8'
}
}).then(res => {
if (res.data.code == 500) {
this.$message.error(res.data.msg)
} else {
var str = `/api/system/ctei/exportCtei?enterpriseId=${this.enterpriseId}&token=${this.headers.token}`
console.log(str)
window.open(str)
}
})
},