|
@@ -11,14 +11,29 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-search"
|
|
|
+ size="mini"
|
|
|
+ @click="handleQuery"
|
|
|
+ >搜索</el-button>
|
|
|
+ <el-button
|
|
|
+ icon="el-icon-refresh"
|
|
|
+ size="mini"
|
|
|
+ @click="resetQuery"
|
|
|
+ >重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
|
<el-row :gutter="10" class="mb8 czBtns">
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openSelectUser">添加用户</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="openSelectUser"
|
|
|
+ >添加用户</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
<el-button
|
|
@@ -31,7 +46,13 @@
|
|
|
>批量取消授权</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="warning" plain icon="el-icon-back" size="mini" @click="handleClose">返回</el-button>
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ icon="el-icon-back"
|
|
|
+ size="mini"
|
|
|
+ @click="handleClose"
|
|
|
+ >返回</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
@@ -45,24 +66,43 @@
|
|
|
@selection-change="handleSelectionChange"
|
|
|
>
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
- <el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
|
|
|
- <el-table-column label="用户状态" prop="state" :show-overflow-tooltip="true">
|
|
|
+ <el-table-column
|
|
|
+ label="用户名称"
|
|
|
+ prop="userName"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="用户状态"
|
|
|
+ prop="state"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<span>{{ convertUserStatus(scope.row.state) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="用户类型" prop="userType" :show-overflow-tooltip="true">
|
|
|
+ <el-table-column
|
|
|
+ label="用户类型"
|
|
|
+ prop="userType"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<span>{{ convertUserType(scope.row.userType) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="最后登录时间" prop="lastLoginTime" width="160" />
|
|
|
<el-table-column label="创建时间" prop="createTime" width="160" />
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <el-table-column
|
|
|
+ label="操作"
|
|
|
+ align="center"
|
|
|
+ class-name="small-padding fixed-width"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button size="mini" type="text" :disabled="!multiple" @click="cancelAuthUser(scope.row)"><i
|
|
|
- class="el-icon-circle-close celBtn"
|
|
|
- /><span>取消授权</span>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ :disabled="!multiple"
|
|
|
+ @click="cancelAuthUser(scope.row)"
|
|
|
+ ><i class="el-icon-circle-close celBtn" /><span>取消授权</span>
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -76,13 +116,21 @@
|
|
|
align="right"
|
|
|
@pagination="getList"
|
|
|
/>
|
|
|
- <select-role ref="select" :role-id="queryParams.roleId" @updateUserList="getList()" />
|
|
|
+ <select-role
|
|
|
+ ref="select"
|
|
|
+ :role-id="queryParams.roleId"
|
|
|
+ @updateUserList="getList()"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import selectRole from './role-select'
|
|
|
-import { getUserListById, cancelRoleAuth, cancelAllRoleAuth } from '@/api/system/user'
|
|
|
+import {
|
|
|
+ getUserListById,
|
|
|
+ cancelRoleAuth,
|
|
|
+ cancelAllRoleAuth
|
|
|
+} from '@/api/system/user'
|
|
|
export default {
|
|
|
name: 'UserAuth',
|
|
|
components: { selectRole },
|
|
@@ -142,16 +190,18 @@ export default {
|
|
|
// result = e.name
|
|
|
// }
|
|
|
// })
|
|
|
- val === 0 ? result = '客户端用户' : result = '管理端用户'
|
|
|
+ val === 0 ? (result = '客户端用户') : (result = '管理端用户')
|
|
|
return result
|
|
|
},
|
|
|
/** 查询授权用户列表 */
|
|
|
getList() {
|
|
|
- getUserListById(this.queryParams).then(res => {
|
|
|
+ getUserListById(this.queryParams).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
const data = res.data
|
|
|
- data.userList.forEach(item => {
|
|
|
- item.lastLoginTime ? item.lastLoginTime : item.lastLoginTime = '暂未登录'
|
|
|
+ data.userList.forEach((item) => {
|
|
|
+ item.lastLoginTime
|
|
|
+ ? item.lastLoginTime
|
|
|
+ : (item.lastLoginTime = '暂未登录')
|
|
|
})
|
|
|
this.userList = data.userList
|
|
|
this.total = data.count
|
|
@@ -179,7 +229,7 @@ export default {
|
|
|
},
|
|
|
/** 多选框选中数据 */
|
|
|
handleSelectionChange(selection) {
|
|
|
- this.userIds = selection.map(item => {
|
|
|
+ this.userIds = selection.map((item) => {
|
|
|
return {
|
|
|
userId: item.userId,
|
|
|
roleId: this.queryParams.roleId
|
|
@@ -197,28 +247,35 @@ export default {
|
|
|
roleId: this.queryParams.roleId,
|
|
|
userId: row.userId
|
|
|
}
|
|
|
+ const uid = this.$store.getters.uid
|
|
|
this.$confirm('您确定要取消该用户的授权吗?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
cancelButtonClass: 'btn_custom_cancel',
|
|
|
closeOnClickModal: false,
|
|
|
type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- cancelRoleAuth(query).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.getList()
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '取消授权成功'
|
|
|
- })
|
|
|
- }
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ cancelRoleAuth(query).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '取消授权成功'
|
|
|
+ })
|
|
|
+ if (uid === query.userId) {
|
|
|
+ this.$router.push('/login')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
- }).catch(() => {
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '取消操作'
|
|
|
+ .catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '取消操作'
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
},
|
|
|
/** 批量取消授权按钮操作 */
|
|
|
cancelAuthUserAll() {
|
|
@@ -228,23 +285,25 @@ export default {
|
|
|
cancelButtonClass: 'btn_custom_cancel',
|
|
|
closeOnClickModal: false,
|
|
|
type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- cancelAllRoleAuth(this.userIds).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.getList()
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '批量取消授权成功'
|
|
|
- })
|
|
|
- }
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ cancelAllRoleAuth(this.userIds).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.getList()
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '批量取消授权成功'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
- }).catch(() => {
|
|
|
- this.$refs.roleTable.clearSelection()
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '取消操作'
|
|
|
+ .catch(() => {
|
|
|
+ this.$refs.roleTable.clearSelection()
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '取消操作'
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
}
|