增加用户导入

This commit is contained in:
龙运模
2024-07-18 16:25:30 +08:00
parent a3a626292e
commit e85f113865
4 changed files with 53 additions and 4 deletions
+28
View File
@@ -17,6 +17,9 @@
<el-button type="danger" plain :size="size" icon="el-icon-delete" :disabled="selection.length==0" @click="batch_del"></el-button>
<el-button type="primary" plain :size="size" :disabled="selection.length==0" @click="role">分配角色</el-button>
<el-button type="primary" plain :size="size" :disabled="selection.length==0" @click="rePwd">密码重置</el-button>
<scImport :size="size" title="批量导入用户" @parentParams="importUpload" @importSuccess="importSuccess">
<div @click="importTemplate">下载导入模版</div>
</scImport>
</div>
<div class="right-panel">
<div class="right-panel-search">
@@ -180,6 +183,31 @@
this.$refs.saveDialog.open()
})
},
// 批量导入
async importTemplate() {
const res = await this.$API.system.user.template.post();
const blob = new Blob([res]);
const text = new Date().getTime();
const eLink = document.createElement('a');
eLink.download = "用户导入模版_"+text+'.xlsx';
eLink.style.display = 'none';
eLink.href = URL.createObjectURL(blob);
document.body.appendChild(eLink);
eLink.click();
URL.revokeObjectURL(eLink.href);
document.body.removeChild(eLink);
},
async importUpload(params) {
const res = await this.$API.system.user.import.post(params);
if(res.code == 200){
this.$message.success('上传成功,开始导入数据');
}
},
importSuccess(){
this.$refs.table.refresh()
},
//编辑
table_edit(row){
this.dialog.save = true