refactor(用户组和权限): 权限表格选择权限优化

This commit is contained in:
shiziyuan9527 2021-05-22 10:01:48 +08:00 committed by 刘瑞斌
parent 845a9fe1b3
commit d8612baeb9
4 changed files with 43 additions and 4 deletions

View File

@ -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

View File

@ -159,7 +159,11 @@ export default {
if (response.data.workspaceId) {
localStorage.setItem("workspace_id", response.data.workspaceId);
}
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);
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);

View File

@ -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">

View File

@ -32,10 +32,22 @@ export default {
},
methods: {
change(val, permission) {
//
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;
}
}
}
}
</script>
<style scoped>