HTML部分代码:
<el-upload
class="upload-demo"
:action="fileAction"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
:show-file-list="false" :before-upload="beforeAvatarUpload" :on-progress="uploadProcess"
:on-success="importSuccess" :on-error="importError">
<el-button size="small" type="primary">文件导入</el-button>
</el-upload>
JS部分代码:
<script>
export default {
data () {
return {
paramId: "",
loadProgress: 0, // 动态显示进度条
progressFlag: false, // 关闭进度条
fileAction: "",
dataList: [], //列表数据
pageIndex: 1,
pageSize: 10,
totalPage: 0,
customColors: [
{color: '#f56c6c', percentage: 20},
{color: '#e6a23c', percentage: 40},
{color: '#5cb87a', percentage: 60},
{color: '#1989fa', percentage: 80},
{color: '#6f7ad3', percentage: 100}
]
}
},
methods: {
init (id) {
this.paramId = id;
//上传的接口
this.fileAction = this.$http.adornUrl(this.apiUrl.cinaImport+"?taskId="+this.paramId);
this.loadProgress = 0; // 动态显示进度条
this.progressFlag = false; // 关闭进度条
this.dataList = []; //列表数据
this.pageIndex = 1;
this.pageSize = 10;
this.totalPage = 0;
this.$nextTick(() => {
this.getDataList();
})
},
//获取导入的数据列表
getDataList(){
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList();
},
beforeAvatarUpload(file) {
},
//导入
uploadProcess(event, file, fileList) {
this.progressFlag = true; // 显示进度条
this.loadProgress = parseInt(event.percent); // 动态获取文件上传进度
if (this.loadProgress >= 100) {
this.loadProgress = 100
setTimeout( () => {this.progressFlag = false}, 1000) // 一秒后关闭进度条
}
},
//导入成功
importSuccess(res) {
if(res.code === 200){
this.$message({
message: '导入成功',
type: "success",
duration: 1500,
onClose: () => {
this.getDataList();
}
});
}else{
this.$message({
showClose: true,
message: res.msg,
type: 'error'
});
}
},
//导入失败
importError(err) {
this.$message({
showClose: true,
message: "导入失败",
type: 'error'
});
}
}
}
</script>
相关推荐
基于vue + elementUI的管理系统模板
【vue+leaflet+elementUI】vue项目中在Leaflet弹框Popup中使用elementui组件(三)cv可用 【vue+leaflet+elementUI】vue项目中在Leaflet弹框Popup中使用elementui组件(三)cv可用 【vue+leaflet+elementUI】vue项目中在...
vue2+elementUI后台管理系统,页面源代码,src和static目录
vue2+elementUI后台管理系统,页面源代码,src和static目录,大神必备神器,导入即可,无需更改!
springboot+vue+elementui实现增删改查和分页查询,最基础的前后端加数据库功能实现
UI库:选择ElementUI作为UI库,它是一套基于Vue的组件库,提供了丰富的UI组件,可快速构建美观的用户界面。 2. 后端开发 使用SpringBoot来实现后端功能,包括数据库操作、权限管理、接口设计等。以下是一个示例代码...
基于SpringBoot + Vue + ElementUI 实现人力资源管理系统基于SpringBoot + Vue + ElementUI 实现人力资源管理系统基于SpringBoot + Vue + ElementUI 实现人力资源管理系统基于SpringBoot + Vue + ElementUI 实现人力...
对vue + elementUI的表格常规增删改查优化封装
基于Spring Boot+Vue+ElementUI的人力资源管理系统.zip 基于Spring Boot+Vue+ElementUI的人力资源管理系统.zip 基于Spring Boot+Vue+ElementUI的人力资源管理系统.zip 基于Spring Boot+Vue+ElementUI的人力资源管理...
使用vue-cli脚手架搭建vue + elementUI 小案例,功能代码不多,主要包括vue项目目录的创建、elementUI的引入、前端路由、i18n国际化语言、scss、引入iconfont
MyUI是美亚柏科旗下新德汇出品的Web前端项目工程框架。基于 Vue + ElementUI ,专注于中台系统快速搭建,框架已在多个项目实战检验。
基于SpringBoot+MyBatis+Vue+Element的人事管理系统. 包含源代码、数据库DDL SQL、初始化数据SQL等,可以基于此做二次开发,快速搭建自己的业务系统。
毕业设计基于SpringBoot + Vue + ElementUI 的人力资源管理系统的实现.zip毕业设计基于SpringBoot + Vue + ElementUI 的人力资源管理系统的实现.zip毕业设计基于SpringBoot + Vue + ElementUI 的人力资源管理系统的...
本项目采用了前后端分离的技术,前端是基于 Vue+ElementUI+Axios 开发的,后端 则是基于 Spring Boot+MyBatis Plus+ Jwt+Mysql。本项目实现了权限菜单管理,通过员 工的权限动态渲染菜单,并动态生成路由。通过 Jwt ...
基于 SpringBoot + Vue + ElementUI 的人力资源管理系统(附源码,包含数据库文件).7z基于 SpringBoot + Vue + ElementUI 的人力资源管理系统(附源码,包含数据库文件).7z基于 SpringBoot + Vue + ElementUI 的...
vue + elementui自定义按首字母排序下拉列表组件,可点击字母定位到对应选项,支持选中事件,可扩展
前端: Vue + ElementUI 此系统为前后端分离方式开发的系统,技术栈为 后端: SpringBoot + MyBatis + MySQL 前端: Vue + ElementUI 此系统为前后端分离方式开发的系统,技术栈为 后端: SpringBoot + MyBatis...
基于SpringBoot + Vue + ElementUI 实现一个后台管理系统模板,可用作小型网站快速开发 项目经过严格测试,确保可以运行! 基于SpringBoot + Vue + ElementUI 实现一个后台管理系统模板,可用作小型网站快速开发 ...
主要为大家详细介绍了Vue+ElementUI使用vue-pdf实现预览功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下