Skip to content

Commit

Permalink
Merge pull request #2684 from lhzzforever/dev/develop_ci
Browse files Browse the repository at this point in the history
fix: 已关联用户组的人员模板在批量删除的时候可以成功被删除
  • Loading branch information
ielgnaw authored Jun 3, 2024
2 parents 26778ad + 4e5f41e commit 8e8ebd4
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 52 deletions.
11 changes: 9 additions & 2 deletions frontend/src/language/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,9 @@ export const m = {
'设置不可被申请,则无法申请加入此用户组': 'If the setting cannot be applied for, you cannot apply to join this user group',
'管理员已设置空间下所有用户组不可被申请': 'The administrator has set that all user groups in the space cannot be applied for',
'已选择的用户组成员不需要续期': 'The selected user group members do not need to be renewed',
'自动生成同名人员模板': 'Automatically generate member template with the same name'
'自动生成同名人员模板': 'Automatically generate member template with the same name',
'管理员组无法添加权限': 'Administrators group unable to add permissions',
'只读用户组无法添加权限': 'Read only user group cannot add permissions'
},
userGroupDetail: {
'用户组名': 'Group name: ',
Expand Down Expand Up @@ -1486,7 +1488,12 @@ export const m = {
'请输入用户/组织,按enter键搜索': 'Please enter user/organization, press enter to search',
'只读人员模板不能移除': 'The read-only member template cannot be removed',
'只读人员模板不能添加、删除、复制成员': 'Read-only member template cannot add, delete, or copy members',
'最多只能选择10个人员模板' : 'You can only select up to 10 member templates'
'最多只能选择10个人员模板' : 'You can only select up to 10 member templates',
'请勾选人员模板': 'Please check personnel template',
'当前勾选项皆为只读人员模板': 'The current options are all read-only member templates',
'当前勾选项皆为有关联用户组人员模板': 'The current options are all associated user group member templates',
'当前勾选项皆为只读和有关联用户组人员模板': 'The current options are all read-only and have associated user group member templates',
'以下为只读或有关联用户组的人员模板,不可删除。': 'The following personnel templates are read-only or have associated user groups and cannot be deleted.'
},
userOrOrg: {
'用户组名': 'User group name',
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/language/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,9 @@ export const m = {
'设置后该组只能管理员主动授权,用户无法主动申请': '设置后该组只能管理员主动授权,用户无法主动申请',
'管理员已设置空间下所有用户组不可被申请': '管理员已设置空间下所有用户组不可被申请',
'已选择的用户组成员不需要续期': '已选择的用户组成员不需要续期',
'自动生成同名人员模板': '自动生成同名人员模板'
'自动生成同名人员模板': '自动生成同名人员模板',
'管理员组无法添加权限': '管理员组无法添加权限',
'只读用户组无法添加权限': '只读用户组无法添加权限'
},
userGroupDetail: {
'用户组名': '用户组名:',
Expand Down Expand Up @@ -1489,7 +1491,12 @@ export const m = {
'请输入用户/组织,按enter键搜索': '请输入用户/组织,按enter键搜索',
'只读人员模板不能移除': '只读人员模板不能移除',
'只读人员模板不能添加、删除、复制成员': '只读人员模板不能添加、删除、复制成员',
'最多只能选择10个人员模板': '最多只能选择10个人员模板'
'最多只能选择10个人员模板': '最多只能选择10个人员模板',
'请勾选人员模板': '请勾选人员模板',
'当前勾选项皆为只读人员模板': '当前勾选项皆为只读人员模板',
'当前勾选项皆为有关联用户组人员模板': '当前勾选项皆为有关联用户组人员模板',
'当前勾选项皆为只读和有关联用户组人员模板': '当前勾选项皆为只读和有关联用户组人员模板',
'以下为只读或有关联用户组的人员模板,不可删除。': '以下为只读或有关联用户组的人员模板,不可删除。'
},
userOrOrg: {
'用户组名': '用户组名',
Expand Down
79 changes: 54 additions & 25 deletions frontend/src/views/group/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,19 @@
>
{{ $t(`m.common['添加成员']`) }}
</bk-button>
<bk-button
text
theme="primary"
style="margin-left: 10px"
:disabled="(row.attributes && row.attributes.source_from_role) || row.readonly"
@click="handleAddPerm(row)">
{{ $t(`m.common['添加权限']`) }}
</bk-button>
<bk-popover
:content="formatDisabledAddPerm(row, 'title')"
:disabled="!formatDisabledAddPerm(row, 'disabled')"
>
<bk-button
text
theme="primary"
style="margin-left: 10px"
:disabled="formatDisabledAddPerm(row, 'disabled')"
@click="handleAddPerm(row)">
{{ $t(`m.common['添加权限']`) }}
</bk-button>
</bk-popover>
<bk-popover
class="custom-table-dot-menu"
ext-cls="custom-table-dot-menu-tipper"
Expand Down Expand Up @@ -425,27 +430,51 @@
};
},
computed: {
...mapGetters(['user', 'showNoviceGuide', 'externalSystemId']),
isCanEditProcess () {
return this.currentSelectList.length > 0;
},
isRatingManager () {
return ['rating_manager', 'subset_manager'].includes(this.curRole);
},
isSuperManager () {
return this.curRole === 'super_manager';
},
curSelectIds () {
return this.currentSelectList.map((item) => item.id);
...mapGetters(['user', 'showNoviceGuide', 'externalSystemId']),
isCanEditProcess () {
return this.currentSelectList.length > 0;
},
isRatingManager () {
return ['rating_manager', 'subset_manager'].includes(this.curRole);
},
isSuperManager () {
return this.curRole === 'super_manager';
},
curSelectIds () {
return this.currentSelectList.map((item) => item.id);
},
isBatchDisabled () {
if (this.currentSelectList.length) {
const isDisabled = this.currentSelectList.every(item => item.readonly);
return isDisabled;
} else {
return true;
}
},
formatDisabledAddPerm () {
return (payload, type) => {
const typeMap = {
title: () => {
if (payload.attributes && payload.attributes.source_from_role) {
return this.$t(`m.userGroup['管理员组无法添加权限']`);
}
if (payload.readonly) {
return this.$t(`m.userGroup['只读用户组无法添加权限']`);
}
return '';
},
isBatchDisabled () {
if (this.currentSelectList.length) {
const isDisabled = this.currentSelectList.every(item => item.readonly);
return isDisabled;
} else {
disabled: () => {
if (payload.readonly || (payload.attributes && payload.attributes.source_from_role)) {
return true;
}
return false;
}
};
if (typeMap[type]) {
return typeMap[type]();
}
};
}
},
watch: {
'pagination.current' (value) {
Expand Down
127 changes: 104 additions & 23 deletions frontend/src/views/member-template/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
<bk-button theme="primary" @click="handleCreate">
{{ $t(`m.common['新建']`) }}
</bk-button>
<bk-button :disabled="isBatchDisabled" @click="handleBatchAddMember">
{{ $t(`m.common['批量添加成员']`) }}
</bk-button>
<bk-button :disabled="isBatchDisabled" @click="handleBatchDelete">
{{ $t(`m.common['批量删除']`) }}
</bk-button>
<bk-popover
:content="isBatchAddMemberDisabled('title')"
:disabled="!isBatchAddMemberDisabled('disabled')"
>
<bk-button :disabled="isBatchAddMemberDisabled('disabled')" @click="handleBatchAddMember">
{{ $t(`m.common['批量添加成员']`) }}
</bk-button>
</bk-popover>
<bk-popover
:content="isBatchDeleteDisabled('title')"
:disabled="!isBatchDeleteDisabled('disabled')"
>
<bk-button :disabled="isBatchDeleteDisabled('disabled')" @click="handleBatchDelete">
{{ $t(`m.common['批量删除']`) }}
</bk-button>
</bk-popover>
</div>
<div slot="right">
<IamSearchSelect style="width: 420px" :placeholder="$t(`m.memberTemplate['搜索模板名称、描述、创建人']`)" :data="searchData"
Expand Down Expand Up @@ -68,7 +78,7 @@
</span>
</template>
</bk-table-column>
<bk-table-column :label="$t(`m.common['操作-table']`)" fixed="right">
<bk-table-column :label="$t(`m.common['操作-table']`)" fixed="right" :width="150">
<template slot-scope="{ row }">
<div class="actions-btn">
<bk-popover
Expand Down Expand Up @@ -153,7 +163,7 @@

<DeleteActionDialog :show.sync="isShowDeleteDialog" :loading="batchQuitLoading" :width="formatDeleteWidth"
:title="delActionDialogTitle" :tip="delActionDialogTip" :name="currentActionName"
:related-action-list="readOnlyGroups" @on-after-leave="handleAfterDeleteLeave" @on-cancel="handleCancelDelete"
:related-action-list="formatDisableGroup" @on-after-leave="handleAfterDeleteLeave" @on-cancel="handleCancelDelete"
@on-submit="handleSubmitDelete" />
</div>
</template>
Expand Down Expand Up @@ -185,6 +195,7 @@
searchList: [],
searchValue: [],
readOnlyGroups: [],
hasRelatedGroups: [],
searchData: [
{
id: 'name',
Expand Down Expand Up @@ -244,8 +255,70 @@
},
computed: {
...mapGetters(['user', 'externalSystemId']),
isBatchDisabled () {
return this.currentSelectList.length === 0;
isAllReadOnly () {
return this.currentSelectList.filter((item) => item.readonly).length === this.currentSelectList.length;
},
isAllRelated () {
return this.currentSelectList.filter((item) => item.group_count > 0).length === this.currentSelectList.length;
},
isAllDisabled () {
const readOnlyList = this.currentSelectList.filter((item) => item.readonly).map((v) => v.id);
const relatedList = this.currentSelectList.filter(
(item) => item.group_count > 0 && !readOnlyList.includes(item.id));
if (!this.currentSelectList.length) {
return true;
}
return readOnlyList.length + relatedList.length === this.currentSelectList.length;
},
isBatchAddMemberDisabled () {
return (payload) => {
const typeMap = {
title: () => {
if (!this.currentSelectList.length) {
return this.$t(`m.memberTemplate['请勾选人员模板']`);
}
if ((this.isAllReadOnly && this.currentSelectList.length > 0)) {
return this.$t(`m.memberTemplate['当前勾选项皆为只读人员模板']`);
}
return '';
},
disabled: () => {
if ((this.isAllReadOnly && this.currentSelectList.length > 0) || !this.currentSelectList.length) {
return true;
}
return false;
}
};
return typeMap[payload]();
};
},
isBatchDeleteDisabled () {
return (payload) => {
const typeMap = {
title: () => {
if (!this.currentSelectList.length) {
return this.$t(`m.memberTemplate['请勾选人员模板']`);
}
if (this.isAllReadOnly) {
return this.$t(`m.memberTemplate['当前勾选项皆为只读人员模板']`);
}
if (this.isAllRelated) {
return this.$t(`m.memberTemplate['当前勾选项皆为有关联用户组人员模板']`);
}
if (this.isAllDisabled) {
return this.$t(`m.memberTemplate['当前勾选项皆为只读和有关联用户组人员模板']`);
}
return '';
},
disabled: () => {
if (this.isAllReadOnly || this.isAllRelated || this.isAllDisabled || !this.currentSelectList.length) {
return true;
}
return false;
}
};
return typeMap[payload]();
};
},
isRatingManager () {
return ['rating_manager', 'subset_manager'].includes(this.curRole);
Expand Down Expand Up @@ -284,6 +357,9 @@
};
return typeMap[type]();
};
},
formatDisableGroup () {
return this.currentSelectList.filter((item) => item.readonly || item.group_count > 0);
}
},
watch: {
Expand Down Expand Up @@ -361,7 +437,7 @@
this.fetchSelectedGroupCount();
this.handleOpenDetail();
} catch (e) {
console.error(e);
this.messageAdvancedError(e);
} finally {
this.tableLoading = false;
}
Expand Down Expand Up @@ -399,7 +475,6 @@
},
async handleSearch (payload, result) {
console.log(payload, result);
this.searchParams = payload;
this.searchList = result;
this.emptyData.tipType = 'search';
Expand Down Expand Up @@ -499,18 +574,14 @@
this.resetPagination();
this.fetchMemberTemplateList(true);
} catch (e) {
console.error(e);
this.messageAdvancedError(e);
} finally {
this.memberDialogLoading = false;
}
},
async handleSubmitDelete () {
const selectGroups = this.currentSelectList.filter((item) => !item.readonly);
if (this.readOnlyGroups.length === this.currentSelectList.length) {
return this.messageWarn(this.$t(`m.memberTemplate['当前选择人员模板皆为只读属性,暂无可删除人员模板']`), 3000);
}
const selectGroups = this.currentSelectList.filter((item) => !item.readonly && item.group_count === 0);
this.batchQuitLoading = true;
try {
for (let i = 0; i < selectGroups.length; i++) {
Expand All @@ -526,7 +597,6 @@
this.resetPagination();
this.fetchMemberTemplateList(true);
} catch (e) {
console.error(e);
this.messageAdvancedError(e);
} finally {
this.batchQuitLoading = false;
Expand Down Expand Up @@ -586,10 +656,11 @@
handleDeleteActions (type) {
const typeMap = {
delete: () => {
this.isShowDeleteDialog = true;
this.delActionDialogTitle = this.$t(`m.dialog['确认批量删除所选的人员模板吗?']`);
this.delActionDialogTip = this.$t(`m.memberTemplate['以下为只读人员模板,不可删除。']`);
this.delActionDialogTip = this.$t(`m.memberTemplate['以下为只读或有关联用户组的人员模板,不可删除。']`);
this.readOnlyGroups = this.currentSelectList.filter((item) => item.readonly);
this.hasRelatedGroups = this.currentSelectList.filter((item) => item.group_count > 0);
this.isShowDeleteDialog = true;
}
};
return typeMap[type]();
Expand Down Expand Up @@ -665,6 +736,7 @@
handleAfterDeleteLeave () {
this.currentActionName = '';
this.readOnlyGroups = [];
this.hasRelatedGroups = [];
},
handleCancelDelete () {
Expand Down Expand Up @@ -759,9 +831,18 @@
background-color: #f2fff4;
}
/deep/ .bk-form-checkbox.is-checked .bk-checkbox {
border-color: #3a84ff;
background-color: #3a84ff;
/deep/ .bk-form-checkbox.is-checked {
.bk-checkbox {
border-color: #3a84ff;
background-color: #3a84ff;
&:hover {
background-color: #3a84ff;
}
}
}
.bk-table-fixed, .bk-table-fixed-right {
border-bottom: 0;
}
}
}
Expand Down

0 comments on commit 8e8ebd4

Please sign in to comment.