工作空间成员列表添加角色列
This commit is contained in:
parent
44743620d4
commit
f5a315ffcd
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
@ -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>
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +16,13 @@
|
|||
<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="140">
|
||||
<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="del(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/>
|
||||
|
@ -41,7 +48,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">
|
||||
|
@ -53,6 +60,16 @@
|
|||
</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>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm('form')" size="medium">保存</el-button>
|
||||
|
@ -71,7 +88,7 @@
|
|||
components: {MsCreateBox},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
result: {},
|
||||
form: {},
|
||||
btnTips: "添加成员",
|
||||
createVisible: false,
|
||||
|
@ -81,6 +98,9 @@
|
|||
rules: {
|
||||
userIds: [
|
||||
{required: true, message: '请选择成员', trigger: ['blur', 'change']}
|
||||
],
|
||||
roleIds: [
|
||||
{required: true, message: '请选择角色', trigger: ['blur', 'change']}
|
||||
]
|
||||
},
|
||||
multipleSelection: [],
|
||||
|
@ -107,15 +127,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 +153,10 @@
|
|||
handleCurrentChange(current) {
|
||||
this.currentPage = current;
|
||||
},
|
||||
closeFunc() {
|
||||
this.form = {};
|
||||
this.initTableData();
|
||||
},
|
||||
del(row) {
|
||||
this.$confirm('移除该成员, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
|
@ -171,6 +197,9 @@
|
|||
message: '获取用户列表失败'
|
||||
});
|
||||
});
|
||||
this.result = this.$get('/role/list/test', response => {
|
||||
this.$set(this.form, "roles", response.data);
|
||||
})
|
||||
},
|
||||
submitForm(formName) {
|
||||
this.loading = true;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
{{ role.name }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column>
|
||||
<template slot-scope="scope">
|
||||
|
@ -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: '确定',
|
||||
|
|
Loading…
Reference in New Issue