@ -112,6 +112,15 @@
@@ -112,6 +112,15 @@
v - hasPermi = "['system:user:remove']"
> 删除 < / e l - b u t t o n >
< / e l - c o l >
< el -col :span ="1.5" >
< el -button
type = "info"
icon = "el-icon-upload2"
size = "mini"
@ click = "handleImport"
v - hasPermi = "['system:user:import']"
> 导入 < / e l - b u t t o n >
< / e l - c o l >
< el -col :span ="1.5" >
< el -button
type = "warning"
@ -284,11 +293,43 @@
@@ -284,11 +293,43 @@
< el -button @click ="cancel" > 取 消 < / el -button >
< / div >
< / e l - d i a l o g >
<!-- 用户导入对话框 -- >
< el -dialog :title ="upload.title" :visible.sync ="upload.open" width = "400px" >
< el -upload
ref = "upload"
: limit = "1"
accept = ".xlsx, .xls"
: headers = "upload.headers"
: action = "upload.url + '?updateSupport=' + upload.updateSupport"
: disabled = "upload.isUploading"
: on - progress = "handleFileUploadProgress"
: on - success = "handleFileSuccess"
: auto - upload = "false"
drag
>
< i class = "el-icon-upload" > < / i >
< div class = "el-upload__text" >
将文件拖到此处 , 或
< em > 点击上传 < / em >
< / div >
< div class = "el-upload__tip" slot = "tip" >
< el -checkbox v -model = " upload.updateSupport " / > 是否更新已经存在的用户数据
< el -link type = "info" style = "font-size:12px" @click ="importTemplate" > 下载模板 < / el -link >
< / div >
< div class = "el-upload__tip" style = "color:red" slot = "tip" > 提示 : 仅允许导入 “ xls ” 或 “ xlsx ” 格式文件 ! < / div >
< / e l - u p l o a d >
< div slot = "footer" class = "dialog-footer" >
< el -button type = "primary" @click ="submitFileForm" > 确 定 < / el -button >
< el -button @ click = "upload.open = false" > 取 消 < / e l - b u t t o n >
< / div >
< / e l - d i a l o g >
< / div >
< / template >
< script >
import { listUser , getUser , delUser , addUser , updateUser , exportUser , resetUserPwd , changeUserStatus } from "@/api/system/user" ;
import { listUser , getUser , delUser , addUser , updateUser , exportUser , resetUserPwd , changeUserStatus , importTemplate } from "@/api/system/user" ;
import { getToken } from "@/utils/auth" ;
import { treeselect } from "@/api/system/dept" ;
import Treeselect from "@riophae/vue-treeselect" ;
import "@riophae/vue-treeselect/dist/vue-treeselect.css" ;
@ -336,6 +377,21 @@ export default {
@@ -336,6 +377,21 @@ export default {
children : "children" ,
label : "label"
} ,
/ / 用 户 导 入 参 数
upload : {
/ / 是 否 显 示 弹 出 层 ( 用 户 导 入 )
open : false ,
/ / 弹 出 层 标 题 ( 用 户 导 入 )
title : "" ,
/ / 是 否 禁 用 上 传
isUploading : false ,
/ / 是 否 更 新 已 经 存 在 的 用 户 数 据
updateSupport : 0 ,
/ / 设 置 上 传 的 请 求 头 部
headers : { Authorization : "Bearer " + getToken ( ) } ,
/ / 上 传 的 地 址
url : process . env . VUE _APP _BASE _API + "/system/user/importData"
} ,
/ / 查 询 参 数
queryParams : {
pageNum : 1 ,
@ -473,9 +529,9 @@ export default {
@@ -473,9 +529,9 @@ export default {
} ,
/ / 多 选 框 选 中 数 据
handleSelectionChange ( selection ) {
this . ids = selection . map ( item => item . userId )
this . single = selection . length != 1
this . multiple = ! selection . length
this . ids = selection . map ( item => item . userId ) ;
this . single = selection . length != 1 ;
this . multiple = ! selection . length ;
} ,
/** 新增按钮操作 */
handleAdd ( ) {
@ -493,7 +549,7 @@ export default {
@@ -493,7 +549,7 @@ export default {
handleUpdate ( row ) {
this . reset ( ) ;
this . getTreeselect ( ) ;
const userId = row . userId || this . ids
const userId = row . userId || this . ids ;
getUser ( userId ) . then ( response => {
this . form = response . data ;
this . postOptions = response . posts ;
@ -574,6 +630,33 @@ export default {
@@ -574,6 +630,33 @@ export default {
} ) . then ( response => {
this . download ( response . msg ) ;
} ) . catch ( function ( ) { } ) ;
} ,
/** 导入按钮操作 */
handleImport ( ) {
this . upload . title = "用户导入" ;
this . upload . open = true ;
} ,
/** 下载模板操作 */
importTemplate ( ) {
importTemplate ( ) . then ( response => {
this . download ( response . msg ) ;
} ) ;
} ,
/ / 文 件 上 传 中 处 理
handleFileUploadProgress ( event , file , fileList ) {
this . upload . isUploading = true ;
} ,
/ / 文 件 上 传 成 功 处 理
handleFileSuccess ( response , file , fileList ) {
this . upload . open = false ;
this . upload . isUploading = false ;
this . $refs . upload . clearFiles ( ) ;
this . $alert ( response . msg , "导入结果" , { dangerouslyUseHTMLString : true } ) ;
this . getList ( ) ;
} ,
/ / 提 交 上 传 文 件
submitFileForm ( ) {
this . $refs . upload . submit ( ) ;
}
}
} ;