refactor(用户组): 成员列表优化

This commit is contained in:
shiziyuan9527 2021-06-29 15:51:53 +08:00 committed by 刘瑞斌
parent 255e908b35
commit eefac4f738
6 changed files with 25 additions and 32 deletions

View File

@ -4,7 +4,8 @@
<select id="getGroupList" resultType="io.metersphere.dto.GroupDTO">
select *, (select count(distinct user_group.user_id) from user_group where user_group.group_id = temp.id) as memberSize
select *,
(select count(distinct ug.user_id) from user_group ug join user on ug.user_id = user.id where ug.group_id = temp.id) as memberSize
from (
select g.*, o.name as scopeName from `group` g, organization o
<where>
@ -40,7 +41,7 @@
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
temp.${order.name} ${order.type}
temp.${order.name} ${order.type}, temp.name desc
</foreach>
</if>
</select>

View File

@ -377,10 +377,6 @@ public class UserService {
MSException.throwException(Translator.get("cannot_delete_current_user"));
}
UserRoleExample example = new UserRoleExample();
example.createCriteria().andUserIdEqualTo(userId);
userRoleMapper.deleteByExample(example);
UserGroupExample userGroupExample = new UserGroupExample();
userGroupExample.createCriteria().andUserIdEqualTo(userId);
userGroupMapper.deleteByExample(userGroupExample);

View File

@ -37,7 +37,7 @@ export default {
let validateSelect = (rule, value, callback) => {
let checkNodes = this.$refs.cascadeSelector.getCheckedNodes(true);
if (checkNodes.length === 0) {
callback(new Error(this.$t('user.select_group')));
callback(new Error(this.$t('user.select_group').toString()));
}
callback();
};

View File

@ -43,7 +43,7 @@ export default {
let validateSelect = (rule, value, callback) => {
let checkNodes = this.$refs.cascadeSelector.getCheckedNodes(true);
if (checkNodes.length === 0) {
callback(new Error(this.$t('user.select_project')));
callback(new Error(this.$t('user.select_project').toString()));
}
callback();
};

View File

@ -1,7 +1,6 @@
<template>
<div>
<el-dialog :close-on-click-modal="false" :visible.sync="visible" width="65%" top="15vh"
:destroy-on-close="true" @close="close" v-loading="result.loading"
class="group-member"
>
@ -13,7 +12,7 @@
<el-table-column prop="email" :label="$t('commons.email')" show-overflow-tooltip/>
<el-table-column prop="phone" :label="$t('commons.phone')" show-overflow-tooltip>
<template v-slot="scope">
{{scope.row.phone || '-'}}
{{ scope.row.phone || '-' }}
</template>
</el-table-column>
<el-table-column :label="typeLabel" v-if="showTypeLabel">
@ -23,7 +22,7 @@
width="250"
trigger="click"
>
<div v-loading="source.loading" style="height: 150px;overflow: auto;">
<div v-loading="sourceResult.loading" style="height: 150px;overflow: auto;">
<el-tag
v-for="item in groupSource"
:key="item.id"
@ -55,7 +54,8 @@
</el-dialog>
<el-dialog :close-on-click-modal="false" :visible.sync="memberVisible" width="45%"
:title="title" :destroy-on-close="true" v-loading="memberResult.loading" @close="memberDialogClose">
<el-form ref="memberFrom" label-position="right" :model="form" size="small" :rules="rules" label-width="120px" style="margin-right: 40px;">
<el-form ref="memberFrom" label-position="right" :model="form" size="small" :rules="rules" label-width="120px"
style="margin-right: 40px;">
<el-form-item :label="$t('commons.member')" prop="userIds">
<el-select
v-model="form.userIds"
@ -119,7 +119,7 @@ export default {
pageSize: 5,
total: 0,
result: {},
source: {},
sourceResult: {},
memberResult: {},
group: {},
groupSource: [],
@ -191,12 +191,9 @@ export default {
this.submitType = 'EDIT';
this.getUser();
this.getResource();
let userId = row.id;
let groupId = this.group.id;
this.$get('/user/group/source/' + userId + "/" + groupId, res => {
this.$get('/user/group/source/' + row.id + "/" + this.group.id, res => {
let data = res.data;
let userIds = [];
userIds.push(row.id);
let userIds = [row.id];
let sourceIds = data.map(d => d.id);
this.$set(this.form, 'userIds', userIds);
this.$set(this.form, 'sourceIds', sourceIds);
@ -222,7 +219,7 @@ export default {
})
},
removeMember(row) {
this.$confirm(this.$t('member.remove_member'), '', {
this.$confirm(this.$t('member.remove_member').toString(), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
@ -237,9 +234,7 @@ export default {
},
getGroupSource(row) {
this.groupSource = [];
let userId = row.id;
let groupId = this.group.id;
this.source = this.$get('/user/group/source/' + userId + "/" + groupId, res => {
this.sourceResult = this.$get('/user/group/source/' + row.id + "/" + this.group.id, res => {
this.groupSource = res.data;
})
},
@ -265,12 +260,10 @@ export default {
})
},
getResource() {
let id = this.group.id;
let type = this.group.type;
this.memberResult = this.$get('/organization/list/resource/' + id + "/" + type, res => {
this.memberResult = this.$get('/organization/list/resource/' + this.group.id + "/" + this.group.type, res => {
let data = res.data;
if (data) {
this._setResource(type, data);
this._setResource(this.group.type, data);
}
})
},
@ -289,9 +282,9 @@ export default {
}
},
memberDialogClose() {
this.form = {};
this.memberVisible = false;
this.userSelectDisable = false;
this.form = {};
}
}
}
@ -301,6 +294,7 @@ export default {
.group-member >>> .el-dialog__header {
padding: 0;
}
.user-select-left {
float: left;
}

View File

@ -2,7 +2,8 @@
<div v-loading="result.loading">
<el-card>
<template v-slot:header>
<ms-table-header :create-permission="['SYSTEM_GROUP:READ+CREATE','ORGANIZATION_GROUP:READ+CREATE']" :condition.sync="condition" @search="initData" @create="create"
<ms-table-header :create-permission="['SYSTEM_GROUP:READ+CREATE','ORGANIZATION_GROUP:READ+CREATE']"
:condition.sync="condition" @search="initData" @create="create"
:create-tip="$t('group.create')" :title="$t('group.group_permission')"/>
</template>
@ -111,8 +112,9 @@ export default {
this.result = this.$post("/user/group/get/" + this.currentPage + "/" + this.pageSize, this.condition, res => {
let data = res.data;
if (data) {
this.total = data.itemCount;
this.groups = data.listObject;
let {itemCount, listObject} = data;
this.total = itemCount;
this.groups = listObject;
}
});
},
@ -122,7 +124,7 @@ export default {
edit(row) {
if (row.id === "admin") {
this.$warning(this.$t('group.admin_not_allow_edit'));
return ;
return;
}
this.$refs.editUserGroup.open(row, 'edit', this.$t('group.edit'));
},
@ -135,7 +137,7 @@ export default {
del(row) {
if (row.system) {
this.$warning(this.$t('group.admin_not_allow_delete'));
return ;
return;
}
this.$refs.deleteConfirm.open(row);
},