feat(系统设置): 项目成员列表 处理冲突
This commit is contained in:
parent
f6c566f77a
commit
2ad4b4fa3b
|
@ -24,4 +24,8 @@ public interface ExtUserGroupMapper {
|
||||||
List<User> getMemberList(@Param("member") QueryMemberRequest request);
|
List<User> getMemberList(@Param("member") QueryMemberRequest request);
|
||||||
|
|
||||||
List<UserGroupHelpDTO> getUserRoleHelpList(@Param("userId") String userId);
|
List<UserGroupHelpDTO> getUserRoleHelpList(@Param("userId") String userId);
|
||||||
|
|
||||||
|
List<User> getProjectMemberList(@Param("request") QueryMemberRequest request);
|
||||||
|
|
||||||
|
List<Group> getProjectMemberGroups(@Param("projectId") String projectId,@Param("userId") String userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,4 +66,17 @@
|
||||||
|
|
||||||
WHERE ug.user_id = #{userId}
|
WHERE ug.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getProjectMemberList" resultType="io.metersphere.base.domain.User">
|
||||||
|
SELECT DISTINCT * FROM (
|
||||||
|
SELECT `user`.* FROM user_group JOIN `user` ON user_group.user_id = `user`.id
|
||||||
|
WHERE user_group.source_id = #{request.projectId}
|
||||||
|
order by `user`.update_time desc) temp
|
||||||
|
</select>
|
||||||
|
<select id="getProjectMemberGroups" resultType="io.metersphere.base.domain.Group">
|
||||||
|
select r.id, r.name
|
||||||
|
from project p
|
||||||
|
join user_group ur on p.id = ur.source_id
|
||||||
|
join `group` r on r.id = ur.group_id
|
||||||
|
where p.id = #{projectId} and ur.user_id = #{userId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -78,6 +78,11 @@ public class GroupController {
|
||||||
return groupService.getWorkspaceMemberGroups(workspaceId, userId);
|
return groupService.getWorkspaceMemberGroups(workspaceId, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list/project/{projectId}/{userId}")
|
||||||
|
public List<Group> getProjectMemberGroups(@PathVariable String projectId, @PathVariable String userId) {
|
||||||
|
return groupService.getProjectMemberGroups(projectId, userId);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/org/{userId}")
|
@GetMapping("/org/{userId}")
|
||||||
public List<Organization> getOrganization(@PathVariable String userId) {
|
public List<Organization> getOrganization(@PathVariable String userId) {
|
||||||
return groupService.getOrganization(userId);
|
return groupService.getOrganization(userId);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.controller.request.AddProjectRequest;
|
import io.metersphere.controller.request.AddProjectRequest;
|
||||||
import io.metersphere.controller.request.ProjectRequest;
|
import io.metersphere.controller.request.ProjectRequest;
|
||||||
import io.metersphere.dto.ProjectDTO;
|
import io.metersphere.dto.ProjectDTO;
|
||||||
|
import io.metersphere.dto.WorkspaceMemberDTO;
|
||||||
import io.metersphere.log.annotation.MsAuditLog;
|
import io.metersphere.log.annotation.MsAuditLog;
|
||||||
import io.metersphere.service.CheckPermissionService;
|
import io.metersphere.service.CheckPermissionService;
|
||||||
import io.metersphere.service.ProjectService;
|
import io.metersphere.service.ProjectService;
|
||||||
|
@ -123,4 +124,10 @@ public class ProjectController {
|
||||||
public void deleteFile(@PathVariable String fileId) {
|
public void deleteFile(@PathVariable String fileId) {
|
||||||
projectService.deleteFile(fileId);
|
projectService.deleteFile(fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/member/update")
|
||||||
|
// @MsAuditLog(module = "workspace_member", type = OperLogConstants.UPDATE, title = "#memberDTO.name")
|
||||||
|
public void updateMember(@RequestBody WorkspaceMemberDTO memberDTO) {
|
||||||
|
projectService.updateMember(memberDTO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,12 @@ public class UserController {
|
||||||
return PageUtils.setPageInfo(page, userService.getMemberList(request));
|
return PageUtils.setPageInfo(page, userService.getMemberList(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/project/member/list/{goPage}/{pageSize}")
|
||||||
|
public Pager<List<User>> getProjectMemberList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryMemberRequest request) {
|
||||||
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
|
return PageUtils.setPageInfo(page, userService.getProjectMemberList(request));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取工作空间成员用户 不分页
|
* 获取工作空间成员用户 不分页
|
||||||
*/
|
*/
|
||||||
|
@ -234,6 +240,13 @@ public class UserController {
|
||||||
userService.addMember(request);
|
userService.addMember(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/project/member/add")
|
||||||
|
// @MsAuditLog(module = "workspace_member", type = OperLogConstants.CREATE, title = "添加项目成员成员")
|
||||||
|
public void addProjectMember(@RequestBody AddMemberRequest request) {
|
||||||
|
// workspaceService.checkWorkspaceOwner(wsId);
|
||||||
|
userService.addProjectMember(request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除工作空间成员
|
* 删除工作空间成员
|
||||||
*/
|
*/
|
||||||
|
@ -249,6 +262,17 @@ public class UserController {
|
||||||
userService.deleteMember(workspaceId, userId);
|
userService.deleteMember(workspaceId, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/project/member/delete/{projectId}/{userId}")
|
||||||
|
// @MsAuditLog(module = "workspace_member", type = OperLogConstants.DELETE, title = "删除工作空间成员")
|
||||||
|
public void deleteProjectMember(@PathVariable String projectId, @PathVariable String userId) {
|
||||||
|
// workspaceService.checkWorkspaceOwner(workspaceId);
|
||||||
|
// String currentUserId = SessionUtils.getUser().getId();
|
||||||
|
// if (StringUtils.equals(userId, currentUserId)) {
|
||||||
|
// MSException.throwException(Translator.get("cannot_remove_current"));
|
||||||
|
// }
|
||||||
|
userService.deleteProjectMember(projectId, userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加组织成员
|
* 添加组织成员
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,4 +13,5 @@ public class AddMemberRequest {
|
||||||
private List<String> userIds;
|
private List<String> userIds;
|
||||||
private List<String> roleIds;
|
private List<String> roleIds;
|
||||||
private List<String> groupIds;
|
private List<String> groupIds;
|
||||||
|
private String projectId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,4 +8,5 @@ import lombok.Setter;
|
||||||
public class QueryMemberRequest {
|
public class QueryMemberRequest {
|
||||||
private String name;
|
private String name;
|
||||||
private String workspaceId;
|
private String workspaceId;
|
||||||
|
private String projectId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class WorkspaceMemberDTO {
|
||||||
private Long updateTime;
|
private Long updateTime;
|
||||||
private String language;
|
private String language;
|
||||||
private String workspaceId;
|
private String workspaceId;
|
||||||
|
private String projectId;
|
||||||
private List<String> roleIds = new ArrayList<>();
|
private List<String> roleIds = new ArrayList<>();
|
||||||
private List<String> groupIds = new ArrayList<>();
|
private List<String> groupIds = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -325,4 +325,8 @@ public class GroupService {
|
||||||
list = organizationMapper.selectByExample(organizationExample);
|
list = organizationMapper.selectByExample(organizationExample);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Group> getProjectMemberGroups(String projectId, String userId) {
|
||||||
|
return extUserGroupMapper.getProjectMemberGroups(projectId, userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,15 @@ import io.metersphere.api.service.APITestService;
|
||||||
import io.metersphere.api.service.ApiAutomationService;
|
import io.metersphere.api.service.ApiAutomationService;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtOrganizationMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtProjectMapper;
|
import io.metersphere.base.mapper.ext.ExtProjectMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtUserGroupMapper;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.ServiceUtils;
|
import io.metersphere.commons.utils.ServiceUtils;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.controller.request.ProjectRequest;
|
import io.metersphere.controller.request.ProjectRequest;
|
||||||
import io.metersphere.dto.ProjectDTO;
|
import io.metersphere.dto.ProjectDTO;
|
||||||
|
import io.metersphere.dto.WorkspaceMemberDTO;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.log.utils.ReflexObjectUtil;
|
import io.metersphere.log.utils.ReflexObjectUtil;
|
||||||
import io.metersphere.log.vo.DetailColumn;
|
import io.metersphere.log.vo.DetailColumn;
|
||||||
|
@ -70,6 +73,12 @@ public class ProjectService {
|
||||||
private ApiAutomationService apiAutomationService;
|
private ApiAutomationService apiAutomationService;
|
||||||
@Resource
|
@Resource
|
||||||
private PerformanceReportService performanceReportService;
|
private PerformanceReportService performanceReportService;
|
||||||
|
@Resource
|
||||||
|
private UserGroupMapper userGroupMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtOrganizationMapper extOrganizationMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtUserGroupMapper extUserGroupMapper;
|
||||||
|
|
||||||
public Project addProject(Project project) {
|
public Project addProject(Project project) {
|
||||||
if (StringUtils.isBlank(project.getName())) {
|
if (StringUtils.isBlank(project.getName())) {
|
||||||
|
@ -304,4 +313,39 @@ public class ProjectService {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateMember(WorkspaceMemberDTO memberDTO) {
|
||||||
|
String projectId = memberDTO.getProjectId();
|
||||||
|
String userId = memberDTO.getId();
|
||||||
|
// 已有角色
|
||||||
|
List<Group> memberGroups = extUserGroupMapper.getProjectMemberGroups(projectId, userId);
|
||||||
|
// 修改后的角色
|
||||||
|
List<String> groups = memberDTO.getGroupIds();
|
||||||
|
List<String> allGroupIds = memberGroups.stream().map(Group::getId).collect(Collectors.toList());
|
||||||
|
// 更新用户时添加了角色
|
||||||
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
|
if (checkSourceRole(projectId, userId, groups.get(i)) == 0) {
|
||||||
|
UserGroup userGroup = new UserGroup();
|
||||||
|
userGroup.setId(UUID.randomUUID().toString());
|
||||||
|
userGroup.setUserId(userId);
|
||||||
|
userGroup.setGroupId(groups.get(i));
|
||||||
|
userGroup.setSourceId(projectId);
|
||||||
|
userGroup.setCreateTime(System.currentTimeMillis());
|
||||||
|
userGroup.setUpdateTime(System.currentTimeMillis());
|
||||||
|
userGroupMapper.insertSelective(userGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allGroupIds.removeAll(groups);
|
||||||
|
if (allGroupIds.size() > 0) {
|
||||||
|
UserGroupExample userGroupExample = new UserGroupExample();
|
||||||
|
userGroupExample.createCriteria().andUserIdEqualTo(userId)
|
||||||
|
.andSourceIdEqualTo(projectId)
|
||||||
|
.andGroupIdIn(allGroupIds);
|
||||||
|
userGroupMapper.deleteByExample(userGroupExample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer checkSourceRole(String workspaceId, String userId, String roleId) {
|
||||||
|
return extOrganizationMapper.checkSourceRole(workspaceId, userId, roleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1124,4 +1124,53 @@ public class UserService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<User> getProjectMemberList(QueryMemberRequest request) {
|
||||||
|
return extUserGroupMapper.getProjectMemberList(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProjectMember(AddMemberRequest request) {
|
||||||
|
if (!CollectionUtils.isEmpty(request.getUserIds())) {
|
||||||
|
for (String userId : request.getUserIds()) {
|
||||||
|
UserGroupExample userGroupExample = new UserGroupExample();
|
||||||
|
userGroupExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getProjectId());
|
||||||
|
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
|
||||||
|
if (userGroups.size() > 0) {
|
||||||
|
MSException.throwException(Translator.get("user_already_exists"));
|
||||||
|
} else {
|
||||||
|
for (String groupId : request.getGroupIds()) {
|
||||||
|
UserGroup userGroup = new UserGroup();
|
||||||
|
userGroup.setGroupId(groupId);
|
||||||
|
userGroup.setSourceId(request.getProjectId());
|
||||||
|
userGroup.setUserId(userId);
|
||||||
|
userGroup.setId(UUID.randomUUID().toString());
|
||||||
|
userGroup.setUpdateTime(System.currentTimeMillis());
|
||||||
|
userGroup.setCreateTime(System.currentTimeMillis());
|
||||||
|
userGroupMapper.insertSelective(userGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteProjectMember(String projectId, String userId) {
|
||||||
|
GroupExample groupExample = new GroupExample();
|
||||||
|
groupExample.createCriteria().andTypeEqualTo(UserGroupType.PROJECT);
|
||||||
|
List<Group> groups = groupMapper.selectByExample(groupExample);
|
||||||
|
|
||||||
|
List<String> groupIds = groups.stream().map(Group::getId).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(groupIds)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UserGroupExample userGroupExample = new UserGroupExample();
|
||||||
|
userGroupExample.createCriteria().andUserIdEqualTo(userId)
|
||||||
|
.andSourceIdEqualTo(projectId)
|
||||||
|
.andGroupIdIn(groupIds);
|
||||||
|
User user = userMapper.selectByPrimaryKey(userId);
|
||||||
|
if (StringUtils.equals(projectId, user.getLastProjectId())) {
|
||||||
|
user.setLastProjectId("");
|
||||||
|
userMapper.updateByPrimaryKeySelective(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
userGroupMapper.deleteByExample(userGroupExample);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
<template>
|
||||||
|
<el-dialog :close-on-click-modal="false" title="添加成员" :visible.sync="dialogVisible" width="30%" :destroy-on-close="true"
|
||||||
|
@close="handleClose">
|
||||||
|
<el-form :model="form" ref="form" :rules="rules" label-position="right" label-width="100px" size="small">
|
||||||
|
<el-form-item :label="$t('commons.member')" prop="memberSign" :rules="{required: true, message: $t('member.input_id_or_email'), trigger: 'change'}">
|
||||||
|
<el-autocomplete
|
||||||
|
class="input-with-autocomplete"
|
||||||
|
v-model="form.memberSign"
|
||||||
|
:placeholder="$t('member.input_id_or_email')"
|
||||||
|
:trigger-on-focus="false"
|
||||||
|
:fetch-suggestions="querySearch"
|
||||||
|
size="small"
|
||||||
|
highlight-first-item
|
||||||
|
value-key="email"
|
||||||
|
>
|
||||||
|
<template v-slot:default="scope">
|
||||||
|
<span class="workspace-member-name">{{scope.item.id}}</span>
|
||||||
|
<span class="workspace-member-email">{{scope.item.email}}</span>
|
||||||
|
</template>
|
||||||
|
</el-autocomplete>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户组" prop="groupIds">
|
||||||
|
<el-select v-model="form.groupIds" multiple placeholder="请选择用户组" class="select-width">
|
||||||
|
<el-option
|
||||||
|
v-for="item in form.groups"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template v-slot:footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="dialogVisible = false" size="medium">{{ $t('commons.cancel') }}</el-button>
|
||||||
|
<el-button type="primary" @click="submitForm('form')" @keydown.enter.native.prevent size="medium">
|
||||||
|
{{ $t('commons.confirm') }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {GROUP_PROJECT} from "@/common/js/constants";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "EditMember",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
form: {},
|
||||||
|
rules: {
|
||||||
|
userIds: [
|
||||||
|
{required: true, message: this.$t('member.please_choose_member'), trigger: ['blur']}
|
||||||
|
],
|
||||||
|
groupIds: [
|
||||||
|
{required: true, message: '请选择用户组', trigger: ['blur']}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
userList: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
projectId() {
|
||||||
|
return this.$store.state.projectId;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submitForm() {
|
||||||
|
this.$refs['form'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
let userIds = [];
|
||||||
|
let userId = this.form.userId;
|
||||||
|
let email = this.form.memberSign;
|
||||||
|
let member = this.userList.find(user => user.id === email || user.email === email);
|
||||||
|
if (!member) {
|
||||||
|
this.$warning(this.$t('member.no_such_user'));
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
userId = member.id;
|
||||||
|
}
|
||||||
|
userIds.push(userId);
|
||||||
|
let param = {
|
||||||
|
userIds: userIds,
|
||||||
|
groupIds: this.form.groupIds,
|
||||||
|
projectId: this.projectId
|
||||||
|
};
|
||||||
|
this.result = this.$post("user/project/member/add", param, () => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
|
this.$emit("refresh");
|
||||||
|
this.dialogVisible = false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
open() {
|
||||||
|
this.$get('/user/list/', response => {
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.userList = response.data;
|
||||||
|
})
|
||||||
|
this.result = this.$post('/user/group/list', {type: GROUP_PROJECT, resourceId: this.projectId}, response => {
|
||||||
|
this.$set(this.form, "groups", response.data);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleClose() {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.form = {};
|
||||||
|
},
|
||||||
|
querySearch(queryString, cb) {
|
||||||
|
var userList = this.userList;
|
||||||
|
var results = queryString ? userList.filter(this.createFilter(queryString)) : userList;
|
||||||
|
// 调用 callback 返回建议列表的数据
|
||||||
|
cb(results);
|
||||||
|
},
|
||||||
|
createFilter(queryString) {
|
||||||
|
return (user) => {
|
||||||
|
return (user.email.indexOf(queryString.toLowerCase()) === 0 || user.id.indexOf(queryString.toLowerCase()) === 0);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.workspace-member-name {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-member-email {
|
||||||
|
float: right;
|
||||||
|
color: #8492a6;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-with-autocomplete {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,196 @@
|
||||||
|
<template>
|
||||||
|
<div v-loading="result.loading">
|
||||||
|
<el-card class="table-card">
|
||||||
|
<template v-slot:header>
|
||||||
|
<ms-table-header :condition.sync="condition" @search="initTableData" @create="create"
|
||||||
|
:create-tip="$t('member.create')" :title="$t('commons.member')" :have-search="false"/>
|
||||||
|
</template>
|
||||||
|
<el-table border class="adjust-table ms-select-all-fixed" :data="tableData" style="width: 100%"
|
||||||
|
:height="screenHeight"
|
||||||
|
ref="userTable">
|
||||||
|
|
||||||
|
<el-table-column prop="id" label="ID"/>
|
||||||
|
<el-table-column prop="name" :label="$t('commons.username')"/>
|
||||||
|
<el-table-column prop="email" :label="$t('commons.email')"/>
|
||||||
|
<el-table-column prop="phone" :label="$t('commons.phone')"/>
|
||||||
|
<el-table-column prop="groups" label="用户组" width="120">
|
||||||
|
<template v-slot:default="scope">
|
||||||
|
<ms-roles-tag :roles="scope.row.groups" type="success"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column :label="$t('commons.operating')">
|
||||||
|
<template v-slot:default="scope">
|
||||||
|
<ms-table-operator :tip2="$t('commons.remove')" @editClick="edit(scope.row)" @deleteClick="del(scope.row)"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||||
|
:total="total"/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
|
||||||
|
<el-dialog :close-on-click-modal="false" :title="$t('member.modify')" :visible.sync="updateVisible" width="30%" :destroy-on-close="true"
|
||||||
|
@close="handleClose">
|
||||||
|
<el-form :model="form" label-position="right" 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="$t('commons.username')" prop="name">
|
||||||
|
<el-input v-model="form.name" autocomplete="off" :disabled="true"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('commons.email')" prop="email">
|
||||||
|
<el-input v-model="form.email" autocomplete="off" :disabled="true"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('commons.phone')" prop="phone">
|
||||||
|
<el-input v-model="form.phone" autocomplete="off" :disabled="true"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户组" prop="groupIds" :rules="{required: true, message: '请选择用户组', trigger: 'change'}">
|
||||||
|
<el-select v-model="form.groupIds" multiple placeholder="请选择用户组" class="select-width">
|
||||||
|
<el-option
|
||||||
|
v-for="item in form.allgroups"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template v-slot:footer>
|
||||||
|
<ms-dialog-footer
|
||||||
|
@cancel="updateVisible = false"
|
||||||
|
@confirm="updateProjectMember('updateUserForm')"/>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<edit-member ref="editMember" @refresh="initTableData"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import MsRolesTag from "@/business/components/common/components/MsRolesTag";
|
||||||
|
import MsTableOperator from "@/business/components/common/components/MsTableOperator";
|
||||||
|
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||||
|
import MsCreateBox from "@/business/components/settings/CreateBox";
|
||||||
|
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
|
||||||
|
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||||
|
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
|
||||||
|
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
|
||||||
|
import EditMember from "@/business/components/settings/project/EditMember";
|
||||||
|
import {GROUP_PROJECT, GROUP_WORKSPACE} from "@/common/js/constants";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Member",
|
||||||
|
components: {
|
||||||
|
EditMember,
|
||||||
|
MsRolesTag,
|
||||||
|
MsTableOperator,
|
||||||
|
MsTablePagination,
|
||||||
|
MsCreateBox,
|
||||||
|
MsTableHeader,
|
||||||
|
MsDialogFooter,
|
||||||
|
MsTableHeaderSelectPopover,
|
||||||
|
ShowMoreBtn,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
condition: {},
|
||||||
|
result: {},
|
||||||
|
tableData: [],
|
||||||
|
screenHeight: 'calc(100vh - 255px)',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
updateVisible: false,
|
||||||
|
form: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
projectId() {
|
||||||
|
return this.$store.state.projectId;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
create() {
|
||||||
|
this.$refs.editMember.open();
|
||||||
|
},
|
||||||
|
initTableData() {
|
||||||
|
let param = {};
|
||||||
|
param.projectId = this.projectId;
|
||||||
|
this.$post('/user/project/member/list/' + this.currentPage + "/" + this.pageSize, param, response => {
|
||||||
|
let data = response.data;
|
||||||
|
this.tableData = data.listObject;
|
||||||
|
let url = "/user/group/list/project/" + this.projectId;
|
||||||
|
for (let i = 0; i < this.tableData.length; i++) {
|
||||||
|
this.$get(url + "/" + encodeURIComponent(this.tableData[i].id), response => {
|
||||||
|
let groups = response.data;
|
||||||
|
this.$set(this.tableData[i], "groups", groups);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.total = data.itemCount;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
edit(row) {
|
||||||
|
this.updateVisible = true;
|
||||||
|
this.form = Object.assign({}, row);
|
||||||
|
let groupIds = this.form.groups.map(r => r.id);
|
||||||
|
this.result = this.$post('/user/group/list', {type: GROUP_PROJECT, resourceId: this.projectId}, response => {
|
||||||
|
this.$set(this.form, "allgroups", response.data);
|
||||||
|
})
|
||||||
|
// 编辑使填充角色信息
|
||||||
|
this.$set(this.form, 'groupIds', groupIds);
|
||||||
|
},
|
||||||
|
del(row) {
|
||||||
|
this.$confirm(this.$t('member.remove_member'), '', {
|
||||||
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
|
cancelButtonText: this.$t('commons.cancel'),
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
this.result = this.$get('/user/project/member/delete/' + this.projectId + '/' + encodeURIComponent(row.id),() => {
|
||||||
|
this.$success(this.$t('commons.remove_success'));
|
||||||
|
this.initTableData();
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
this.$info(this.$t('commons.remove_cancel'));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleClose() {
|
||||||
|
this.form = {};
|
||||||
|
this.updateVisible = false;
|
||||||
|
},
|
||||||
|
updateProjectMember(formName) {
|
||||||
|
let param = {
|
||||||
|
id: this.form.id,
|
||||||
|
name: this.form.name,
|
||||||
|
email: this.form.email,
|
||||||
|
phone: this.form.phone,
|
||||||
|
groupIds: this.form.groupIds,
|
||||||
|
projectId: this.projectId
|
||||||
|
}
|
||||||
|
this.$refs[formName].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.result = this.$post("/project/member/update", param, () => {
|
||||||
|
this.$success(this.$t('commons.modify_success'));
|
||||||
|
this.updateVisible = false;
|
||||||
|
this.initTableData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
activated() {
|
||||||
|
this.initTableData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.input-with-autocomplete {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -89,6 +89,11 @@ export default {
|
||||||
component: () => import('@/business/components/settings/workspace/WorkspaceMember'),
|
component: () => import('@/business/components/settings/workspace/WorkspaceMember'),
|
||||||
meta: {workspace: true, title: 'commons.member', permissions: ['WORKSPACE_USER:READ']}
|
meta: {workspace: true, title: 'commons.member', permissions: ['WORKSPACE_USER:READ']}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'projectmember',
|
||||||
|
component: () => import('@/business/components/settings/project/Member'),
|
||||||
|
meta: {project: true, title: 'commons.member', permissions: ['PROJECT_USER:READ']}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'personsetting',
|
path: 'personsetting',
|
||||||
component: () => import('@/business/components/settings/personal/PersonSetting'),
|
component: () => import('@/business/components/settings/personal/PersonSetting'),
|
||||||
|
|
Loading…
Reference in New Issue