refactor(用户组和权限): 权限表格选择权限优化
This commit is contained in:
parent
845a9fe1b3
commit
d8612baeb9
|
@ -94,6 +94,8 @@ public class UserService {
|
|||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private ExtUserGroupMapper extUserGroupMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
public List<UserDetail> queryTypeByIds(List<String> userIds) {
|
||||
return extUserMapper.queryTypeByIds(userIds);
|
||||
|
@ -468,14 +470,31 @@ public class UserService {
|
|||
List<Workspace> workspaces = workspaceService.getWorkspaceListByOrgIdAndUserId(sourceId);
|
||||
if (workspaces.size() > 0) {
|
||||
user.setLastWorkspaceId(workspaces.get(0).getId());
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andWorkspaceIdEqualTo(workspaces.get(0).getId());
|
||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||
if (projects.size() > 0) {
|
||||
user.setLastProjectId(projects.get(0).getId());
|
||||
} else {
|
||||
user.setLastProjectId("");
|
||||
}
|
||||
} else {
|
||||
user.setLastWorkspaceId("");
|
||||
user.setLastProjectId("");
|
||||
}
|
||||
}
|
||||
if (StringUtils.equals("workspace", sign)) {
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andWorkspaceIdEqualTo(sourceId);
|
||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||
Workspace workspace = workspaceMapper.selectByPrimaryKey(sourceId);
|
||||
user.setLastOrganizationId(workspace.getOrganizationId());
|
||||
user.setLastWorkspaceId(sourceId);
|
||||
if (projects.size() > 0) {
|
||||
user.setLastProjectId(projects.get(0).getId());
|
||||
} else {
|
||||
user.setLastProjectId("");
|
||||
}
|
||||
}
|
||||
BeanUtils.copyProperties(user, newUser);
|
||||
// 切换工作空间或组织之后更新 session 里的 user
|
||||
|
|
|
@ -159,7 +159,11 @@ export default {
|
|||
if (response.data.workspaceId) {
|
||||
localStorage.setItem("workspace_id", response.data.workspaceId);
|
||||
}
|
||||
localStorage.removeItem(PROJECT_ID);
|
||||
if (response.data.lastProjectId) {
|
||||
localStorage.setItem(PROJECT_ID, response.data.lastProjectId);
|
||||
} else {
|
||||
localStorage.removeItem(PROJECT_ID);
|
||||
}
|
||||
this.$router.push('/').then(() => {
|
||||
window.location.reload();
|
||||
}).catch(err => err);
|
||||
|
@ -173,7 +177,11 @@ export default {
|
|||
this.$post("/user/switch/source/ws/" + workspaceId, {}, response => {
|
||||
saveLocalStorage(response);
|
||||
localStorage.setItem("workspace_id", workspaceId);
|
||||
localStorage.removeItem(PROJECT_ID);
|
||||
if (response.data.lastProjectId) {
|
||||
localStorage.setItem(PROJECT_ID, response.data.lastProjectId);
|
||||
} else {
|
||||
localStorage.removeItem(PROJECT_ID);
|
||||
}
|
||||
this.$router.push('/').then(() => {
|
||||
window.location.reload();
|
||||
}).catch(err => err);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-dialog :close-on-click-modal="false" :title="title"
|
||||
:visible.sync="createVisible" width="35%"
|
||||
:visible.sync="createVisible" width="40%"
|
||||
@closed="handleClose" class="edit-user-dialog"
|
||||
:destroy-on-close="true">
|
||||
<div v-loading="result.loading">
|
||||
|
|
|
@ -32,7 +32,19 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
change(val, permission) {
|
||||
permission.checked = val;
|
||||
// 取消读权限则取消其它所有操作权限
|
||||
let id = permission.id.split(":")[1];
|
||||
if (id === "READ" && !val) {
|
||||
this.permissions.map(p => p.checked = val);
|
||||
} else {
|
||||
if (val) {
|
||||
let p = this.permissions.filter(p => p.id.split(":")[1] === "READ");
|
||||
if (p.length > 0) {
|
||||
p[0].checked = val;
|
||||
}
|
||||
}
|
||||
permission.checked = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue