Merge branch 'dev' of github.com:fit2cloudrd/metersphere-server into dev
This commit is contained in:
commit
85e3556a86
|
@ -4,5 +4,5 @@ import org.apache.ibatis.annotations.Param;
|
|||
|
||||
public interface ExtOrganizationMapper {
|
||||
|
||||
int checkOrgRole(@Param("orgId") String orgId,@Param("userId") String userId,@Param("roleId") String roleId);
|
||||
int checkSourceRole(@Param("sourceId") String sourceId,@Param("userId") String userId,@Param("roleId") String roleId);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtOrganizationMapper">
|
||||
|
||||
<select id="checkOrgRole" resultType="Integer">
|
||||
<select id="checkSourceRole" resultType="Integer">
|
||||
select count(id)
|
||||
from user_role ur
|
||||
where ur.user_id = #{userId}
|
||||
and ur.source_id = #{orgId}
|
||||
and ur.source_id = #{sourceId}
|
||||
and ur.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ public interface ExtUserRoleMapper {
|
|||
|
||||
List<Role> getOrganizationMemberRoles(@Param("orgId") String orgId, @Param("userId") String userId);
|
||||
|
||||
List<Role> getWorkspaceMemberRoles(@Param("workspaceId") String workspaceId, @Param("userId") String userId);
|
||||
|
||||
List<User> getBesideOrgMemberList(@Param("orgId") String orgId);
|
||||
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
</select>
|
||||
|
||||
<select id="getMemberList" resultType="io.metersphere.base.domain.User">
|
||||
SELECT `user`.* FROM user_role JOIN `user` ON user_role.user_id = `user`.id
|
||||
WHERE user_role.source_id = #{member.workspaceId} AND user_role.role_id = #{member.roleId}
|
||||
SELECT distinct `user`.* FROM user_role JOIN `user` ON user_role.user_id = `user`.id
|
||||
WHERE user_role.source_id = #{member.workspaceId}
|
||||
<if test="member.name != null">
|
||||
AND `user`.name like CONCAT('%', #{member.name},'%')
|
||||
</if>
|
||||
|
@ -80,6 +80,14 @@
|
|||
where ur.source_id = #{orgId})
|
||||
</select>
|
||||
|
||||
<select id="getWorkspaceMemberRoles" resultType="io.metersphere.base.domain.Role">
|
||||
select r.id, r.name
|
||||
from workspace w
|
||||
join user_role ur on w.id = ur.source_id
|
||||
join role r on r.id = ur.role_id
|
||||
where w.id = #{workspaceId} and ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
|
@ -140,6 +140,14 @@ public class UserController {
|
|||
return PageUtils.setPageInfo(page, userService.getOrgMemberList(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织成员列表不分页
|
||||
*/
|
||||
@PostMapping("/orgmember/list/all")
|
||||
public List<User> getOrgMemberList(@RequestBody QueryOrgMemberRequest request) {
|
||||
return userService.getOrgMemberList(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询组织成员列表 带角色信息
|
||||
*/
|
||||
|
|
|
@ -16,8 +16,13 @@ public class UserRoleController {
|
|||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
@GetMapping("/list/{orgId}/{userId}")
|
||||
@GetMapping("/list/org/{orgId}/{userId}")
|
||||
public List<Role> getOrganizationMemberRoles(@PathVariable String orgId, @PathVariable String userId) {
|
||||
return userRoleService.getOrganizationMemberRoles(orgId, userId);
|
||||
}
|
||||
|
||||
@GetMapping("/list/ws/{workspaceId}/{userId}")
|
||||
public List<Role> workspaceId(@PathVariable String workspaceId, @PathVariable String userId) {
|
||||
return userRoleService.getWorkspaceMemberRoles(workspaceId, userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import io.metersphere.commons.constants.RoleConstants;
|
|||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.controller.request.WorkspaceRequest;
|
||||
import io.metersphere.dto.OrganizationMemberDTO;
|
||||
import io.metersphere.dto.WorkspaceDTO;
|
||||
import io.metersphere.dto.WorkspaceMemberDTO;
|
||||
import io.metersphere.service.WorkspaceService;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
|
@ -67,4 +69,9 @@ public class WorkspaceController {
|
|||
String currentOrganizationId = SessionUtils.getCurrentOrganizationId();
|
||||
return workspaceService.getWorkspaceListByOrgIdAndUserId(currentOrganizationId);
|
||||
}
|
||||
|
||||
@PostMapping("/member/update")
|
||||
public void updateOrgMember(@RequestBody WorkspaceMemberDTO memberDTO) {
|
||||
workspaceService.updateWorkspaceMember(memberDTO);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,16 @@ import java.util.List;
|
|||
public class AddMemberRequest {
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
private List<String> userIds;
|
||||
private List<String> roleIds;
|
||||
|
||||
public List<String> getRoleIds() {
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(List<String> roleIds) {
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
public String getWorkspaceId() {
|
||||
return workspaceId;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package io.metersphere.controller.request.member;
|
||||
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
|
||||
public class QueryMemberRequest {
|
||||
private String name;
|
||||
private String workspaceId;
|
||||
private String roleId = RoleConstants.TEST_MANAGER;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
@ -15,14 +13,6 @@ public class QueryMemberRequest {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getWorkspaceId() {
|
||||
return workspaceId;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import io.metersphere.base.domain.Role;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WorkspaceMemberDTO {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String email;
|
||||
private String phone;
|
||||
private String status;
|
||||
private Long createTime;
|
||||
private Long updateTime;
|
||||
private String language;
|
||||
private String workspaceId;
|
||||
private List<String> roleIds = new ArrayList<>();
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Long updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getWorkspaceId() {
|
||||
return workspaceId;
|
||||
}
|
||||
|
||||
public void setWorkspaceId(String workspaceId) {
|
||||
this.workspaceId = workspaceId;
|
||||
}
|
||||
|
||||
public List<String> getRoleIds() {
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(List<String> roleIds) {
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
}
|
|
@ -86,7 +86,7 @@ public class OrganizationService {
|
|||
// 更新用户时添加了角色
|
||||
if (roles.size() > allRoleIds.size()) {
|
||||
for (int i = 0; i < roles.size(); i++) {
|
||||
if (checkOrgRole(orgId, userId, roles.get(i)) == 0) {
|
||||
if (checkSourceRole(orgId, userId, roles.get(i)) == 0) {
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setId(UUID.randomUUID().toString());
|
||||
userRole.setUserId(userId);
|
||||
|
@ -107,8 +107,7 @@ public class OrganizationService {
|
|||
}
|
||||
}
|
||||
|
||||
// 检查组织成员是否有某一角色
|
||||
public Integer checkOrgRole(String orgId, String userId, String roleId) {
|
||||
return extOrganizationMapper.checkOrgRole(orgId, userId, roleId);
|
||||
public Integer checkSourceRole(String orgId, String userId, String roleId) {
|
||||
return extOrganizationMapper.checkSourceRole(orgId, userId, roleId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,8 @@ public class UserRoleService {
|
|||
return extUserRoleMapper.getOrganizationMemberRoles(orgId, userId);
|
||||
}
|
||||
|
||||
public List<Role> getWorkspaceMemberRoles(String workspaceId, String userId) {
|
||||
return extUserRoleMapper.getWorkspaceMemberRoles(workspaceId, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -251,21 +251,23 @@ public class UserService {
|
|||
public void addMember(AddMemberRequest request) {
|
||||
if (!CollectionUtils.isEmpty(request.getUserIds())) {
|
||||
for (String userId : request.getUserIds()) {
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setRoleId(RoleConstants.TEST_MANAGER);
|
||||
userRole.setSourceId(request.getWorkspaceId());
|
||||
userRole.setUserId(userId);
|
||||
userRole.setId(UUID.randomUUID().toString());
|
||||
userRole.setUpdateTime(System.currentTimeMillis());
|
||||
userRole.setCreateTime(System.currentTimeMillis());
|
||||
userRoleMapper.insertSelective(userRole);
|
||||
for (String roleId : request.getRoleIds()) {
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setRoleId(roleId);
|
||||
userRole.setSourceId(request.getWorkspaceId());
|
||||
userRole.setUserId(userId);
|
||||
userRole.setId(UUID.randomUUID().toString());
|
||||
userRole.setUpdateTime(System.currentTimeMillis());
|
||||
userRole.setCreateTime(System.currentTimeMillis());
|
||||
userRoleMapper.insertSelective(userRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteMember(String workspaceId, String userId) {
|
||||
UserRoleExample example = new UserRoleExample();
|
||||
example.createCriteria().andRoleIdEqualTo(RoleConstants.TEST_MANAGER)
|
||||
example.createCriteria().andRoleIdLike("%test%")
|
||||
.andUserIdEqualTo(userId).andSourceIdEqualTo(workspaceId);
|
||||
userRoleMapper.deleteByExample(example);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.UserMapper;
|
||||
import io.metersphere.base.mapper.UserRoleMapper;
|
||||
import io.metersphere.base.mapper.WorkspaceMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtOrganizationMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtWorkspaceMapper;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
|
@ -10,9 +12,11 @@ import io.metersphere.commons.exception.MSException;
|
|||
import io.metersphere.controller.request.WorkspaceRequest;
|
||||
import io.metersphere.dto.UserRoleHelpDTO;
|
||||
import io.metersphere.dto.WorkspaceDTO;
|
||||
import io.metersphere.dto.WorkspaceMemberDTO;
|
||||
import io.metersphere.user.SessionUser;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -33,6 +37,10 @@ public class WorkspaceService {
|
|||
private ExtUserRoleMapper extUserRoleMapper;
|
||||
@Resource
|
||||
private UserRoleMapper userRoleMapper;
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private ExtOrganizationMapper extOrganizationMapper;
|
||||
|
||||
public Workspace saveWorkspace(Workspace workspace) {
|
||||
if (StringUtils.isBlank(workspace.getName())) {
|
||||
|
@ -130,4 +138,43 @@ public class WorkspaceService {
|
|||
return resultWorkspaceList;
|
||||
}
|
||||
|
||||
public void updateWorkspaceMember(WorkspaceMemberDTO memberDTO) {
|
||||
User user = new User();
|
||||
BeanUtils.copyProperties(memberDTO, user);
|
||||
userMapper.updateByPrimaryKeySelective(user);
|
||||
//
|
||||
String workspaceId = memberDTO.getWorkspaceId();
|
||||
String userId = user.getId();
|
||||
// 已有角色
|
||||
List<Role> memberRoles = extUserRoleMapper.getWorkspaceMemberRoles(workspaceId, userId);
|
||||
// 修改后的角色
|
||||
List<String> roles = memberDTO.getRoleIds();
|
||||
List<String> allRoleIds = memberRoles.stream().map(Role::getId).collect(Collectors.toList());
|
||||
// 更新用户时添加了角色
|
||||
if (roles.size() > allRoleIds.size()) {
|
||||
for (int i = 0; i < roles.size(); i++) {
|
||||
if (checkSourceRole(workspaceId, userId, roles.get(i)) == 0) {
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setId(UUID.randomUUID().toString());
|
||||
userRole.setUserId(userId);
|
||||
userRole.setRoleId(roles.get(i));
|
||||
userRole.setSourceId(workspaceId);
|
||||
userRole.setCreateTime(System.currentTimeMillis());
|
||||
userRole.setUpdateTime(System.currentTimeMillis());
|
||||
userRoleMapper.insertSelective(userRole);
|
||||
}
|
||||
}
|
||||
} else if (roles.size() < allRoleIds.size()){
|
||||
allRoleIds.removeAll(roles);
|
||||
UserRoleExample userRoleExample = new UserRoleExample();
|
||||
userRoleExample.createCriteria().andUserIdEqualTo(userId)
|
||||
.andSourceIdEqualTo(workspaceId)
|
||||
.andRoleIdIn(allRoleIds);
|
||||
userRoleMapper.deleteByExample(userRoleExample);
|
||||
}
|
||||
}
|
||||
|
||||
public Integer checkSourceRole(String orgId, String userId, String roleId) {
|
||||
return extOrganizationMapper.checkSourceRole(orgId, userId, roleId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div v-loading="loading">
|
||||
<div v-loading="result.loading">
|
||||
<el-card>
|
||||
<div slot="header">
|
||||
<el-row type="flex" justify="space-between" align="middle">
|
||||
|
@ -16,8 +16,16 @@
|
|||
<el-table-column prop="name" label="用户名"/>
|
||||
<el-table-column prop="email" label="邮箱"/>
|
||||
<el-table-column prop="phone" label="电话"/>
|
||||
<el-table-column prop="roles" label="角色" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-for="(role, index) in scope.row.roles" :key="index" size="mini" effect="dark" type="success">
|
||||
{{ role.name }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column>
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="edit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/>
|
||||
<el-button @click="del(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -41,7 +49,7 @@
|
|||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-dialog title="添加成员" :visible.sync="createVisible" width="30%">
|
||||
<el-dialog title="添加成员" :visible.sync="createVisible" width="30%" :destroy-on-close="true" @close="closeFunc">
|
||||
<el-form :model="form" ref="form" :rules="rules" label-position="left" label-width="100px" size="small">
|
||||
<el-form-item label="成员" prop="userIds">
|
||||
<el-select v-model="form.userIds" multiple placeholder="请选择成员" class="select-width">
|
||||
|
@ -50,6 +58,18 @@
|
|||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
<span class="workspace-member-name">{{ item.name }}</span>
|
||||
<span class="workspace-member-email">{{ item.email }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="roleIds">
|
||||
<el-select v-model="form.roleIds" multiple placeholder="请选择角色" class="select-width">
|
||||
<el-option
|
||||
v-for="item in form.roles"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -58,6 +78,37 @@
|
|||
<el-button type="primary" @click="submitForm('form')" size="medium">保存</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="修改成员" :visible.sync="updateVisible" width="30%" :destroy-on-close="true" @close="closeFunc">
|
||||
<el-form :model="form" label-position="left" label-width="100px" size="small" ref="updateUserForm">
|
||||
<el-form-item label="ID" prop="id">
|
||||
<el-input v-model="form.id" autocomplete="off" :disabled="true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名" prop="name">
|
||||
<el-input v-model="form.name" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="电话" prop="phone">
|
||||
<el-input v-model="form.phone" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="roleIds">
|
||||
<el-select v-model="form.roleIds" multiple placeholder="请选择角色" class="select-width">
|
||||
<el-option
|
||||
v-for="item in form.allroles"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="updateWorkspaceMember('updateUserForm')" size="medium">保存</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -71,16 +122,20 @@
|
|||
components: {MsCreateBox},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
result: {},
|
||||
form: {},
|
||||
btnTips: "添加成员",
|
||||
btnTips: "添加工作空间成员",
|
||||
createVisible: false,
|
||||
updateVisible: false,
|
||||
queryPath: "/user/member/list",
|
||||
condition: "",
|
||||
tableData: [],
|
||||
rules: {
|
||||
userIds: [
|
||||
{required: true, message: '请选择成员', trigger: ['blur', 'change']}
|
||||
{required: true, message: '请选择成员', trigger: ['blur']}
|
||||
],
|
||||
roleIds: [
|
||||
{required: true, message: '请选择角色', trigger: ['blur']}
|
||||
]
|
||||
},
|
||||
multipleSelection: [],
|
||||
|
@ -107,15 +162,17 @@
|
|||
workspaceId: this.currentUser().lastWorkspaceId
|
||||
};
|
||||
|
||||
this.$post(this.buildPagePath(this.queryPath), param).then(response => {
|
||||
if (response.data.success) {
|
||||
let data = response.data.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
|
||||
let data = response.data;
|
||||
this.tableData = data.listObject;
|
||||
let url = "/userrole/list/ws/" + this.currentUser().lastWorkspaceId;
|
||||
for (let i = 0; i < this.tableData.length; i++) {
|
||||
this.$get(url + "/" + this.tableData[i].id, response => {
|
||||
let roles = response.data;
|
||||
this.$set(this.tableData[i], "roles", roles);
|
||||
})
|
||||
}
|
||||
this.loading = false;
|
||||
this.total = data.itemCount;
|
||||
})
|
||||
|
||||
},
|
||||
|
@ -131,6 +188,10 @@
|
|||
handleCurrentChange(current) {
|
||||
this.currentPage = current;
|
||||
},
|
||||
closeFunc() {
|
||||
this.form = {};
|
||||
this.initTableData();
|
||||
},
|
||||
del(row) {
|
||||
this.$confirm('移除该成员, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
|
@ -154,41 +215,69 @@
|
|||
});
|
||||
});
|
||||
},
|
||||
create() {
|
||||
this.loading = true;
|
||||
this.$get('/user/list').then(response => {
|
||||
if (response.data.success) {
|
||||
this.createVisible = true;
|
||||
this.form = {userList: response.data.data};
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
edit(row) {
|
||||
this.updateVisible = true;
|
||||
this.form = row;
|
||||
let roleIds = this.form.roles.map(r => r.id);
|
||||
this.result = this.$get('/role/list/test', response => {
|
||||
this.$set(this.form, "allroles", response.data);
|
||||
})
|
||||
// 编辑使填充角色信息
|
||||
this.$set(this.form, 'roleIds', roleIds);
|
||||
},
|
||||
updateWorkspaceMember() {
|
||||
let param = {
|
||||
id: this.form.id,
|
||||
name: this.form.name,
|
||||
email: this.form.email,
|
||||
phone: this.form.phone,
|
||||
roleIds: this.form.roleIds,
|
||||
workspaceId: this.currentUser().lastWorkspaceId
|
||||
}
|
||||
this.result = this.$post("/workspace/member/update", param,() => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '获取用户列表失败'
|
||||
type: 'success',
|
||||
message: '修改成功!'
|
||||
});
|
||||
this.updateVisible = false;
|
||||
this.initTableData();
|
||||
});
|
||||
},
|
||||
create() {
|
||||
this.form = {};
|
||||
let param = {
|
||||
name: this.condition,
|
||||
organizationId: this.currentUser().lastOrganizationId
|
||||
};
|
||||
let wsId = this.currentUser().lastWorkspaceId;
|
||||
if (typeof wsId == "undefined" || wsId == null || wsId == "") {
|
||||
this.$message({
|
||||
message:'请先选择工作空间!',
|
||||
type: 'warning'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
this.$post('/user/orgmember/list/all', param,response => {
|
||||
this.createVisible = true;
|
||||
this.$set(this.form, "userList", response.data);
|
||||
})
|
||||
this.result = this.$get('/role/list/test', response => {
|
||||
this.$set(this.form, "roles", response.data);
|
||||
})
|
||||
},
|
||||
submitForm(formName) {
|
||||
this.loading = true;
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
let param = {
|
||||
userIds: this.form.userIds,
|
||||
roleIds: this.form.roleIds,
|
||||
workspaceId: this.currentUser().lastWorkspaceId
|
||||
};
|
||||
this.$post("user/member/add", param).then(() => {
|
||||
this.$post("user/member/add", param, () => {
|
||||
this.initTableData();
|
||||
this.createVisible = false;
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -214,4 +303,15 @@
|
|||
.select-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.workspace-member-name {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.workspace-member-email {
|
||||
float: right;
|
||||
color: #8492a6;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
{{ role.name }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column>
|
||||
<template slot-scope="scope">
|
||||
|
@ -59,8 +58,8 @@
|
|||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
<span style="float: left">{{ item.name }}</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.email }}</span>
|
||||
<span class="org-member-name">{{ item.name }}</span>
|
||||
<span class="org-member-email">{{ item.email }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -95,7 +94,7 @@
|
|||
<el-input v-model="form.phone" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="roleIds">
|
||||
<el-select v-model="form.roleIds" multiple placeholder="请选择角色" class="select-width" @remove-tag="checkTag" >
|
||||
<el-select v-model="form.roleIds" multiple placeholder="请选择角色" class="select-width">
|
||||
<el-option
|
||||
v-for="item in form.allroles"
|
||||
:key="item.id"
|
||||
|
@ -159,7 +158,7 @@
|
|||
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
|
||||
let data = response.data;
|
||||
this.tableData = data.listObject;
|
||||
let url = "/userrole/list/" + this.currentUser().lastOrganizationId;
|
||||
let url = "/userrole/list/org/" + this.currentUser().lastOrganizationId;
|
||||
for (let i = 0; i < this.tableData.length; i++) {
|
||||
this.$get(url + "/" + this.tableData[i].id, response => {
|
||||
let roles = response.data;
|
||||
|
@ -215,9 +214,6 @@
|
|||
this.initTableData();
|
||||
});
|
||||
},
|
||||
checkTag() {
|
||||
// todo 修改成员信息时必须保留一个组织级角色
|
||||
},
|
||||
del(row) {
|
||||
this.$confirm('是否删除用户 ' + row.name + ' ?', '', {
|
||||
confirmButtonText: '确定',
|
||||
|
@ -276,4 +272,18 @@
|
|||
margin-right: -9px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.org-member-name {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.org-member-email {
|
||||
float: right;
|
||||
color: #8492a6;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.select-width {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue