Skip to content

Commit

Permalink
featrue: 恢复已删除用户 TencentBlueKing#73
Browse files Browse the repository at this point in the history
  • Loading branch information
v_yutyi committed Oct 29, 2021
1 parent 2d9c70d commit 6586a57
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/pages/src/store/modules/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,10 @@ export default {
getProfileById(context, params, config = {}) {
return http.get(`api/v2/profiles/${params.id}/`);
},
// 恢复删除用户
postProfilesRestoration(context, params, config = {}) {
const { id } = params;
return http.post(`/api/v2/profiles/${id}/restoration/`);
},
},
};
1 change: 1 addition & 0 deletions src/pages/src/views/organization/details/DetailsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:fields-list="fieldsList"
@editProfile="editProfile"
@deleteProfile="$emit('deleteProfile')"
@restoreProfile="$emit('restoreProfile')"
@getTableData="$emit('getTableData')"
@showBarLoading="$emit('showBarLoading')"
@closeBarLoading="$emit('closeBarLoading')" />
Expand Down
34 changes: 24 additions & 10 deletions src/pages/src/views/organization/details/UserMaterial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,31 @@
<template>
<div :class="['look-user-info-wrapper',{ 'forbid-operate': isForbid }]">
<div class="action-btn-wrapper" v-if="currentCategoryType === 'local'">
<bk-button theme="primary" class="editor-btn" @click="editProfile">
<bk-button :disabled="isStatus" theme="primary" class="editor-btn" @click="editProfile">
{{$t('编辑')}}
</bk-button>
<bk-button theme="default" :class="['editor-btn',{ 'forbidMark': isForbid }]" @click="changeStatus">
{{!isForbid ? $t('禁用') : $t('启用')}}
</bk-button>
<template v-if="isAdmin">
<bk-button theme="default" class="editor-btn" disabled>
{{$t('删除')}}
<template v-if="!isStatus">
<bk-button theme="default" :class="['editor-btn',{ 'forbidMark': isForbid }]" @click="changeStatus">
{{!isForbid ? $t('禁用') : $t('启用')}}
</bk-button>
<template v-if="isAdmin">
<bk-button theme="default" class="editor-btn" disabled>
{{$t('删除')}}
</bk-button>
</template>
<template v-else>
<bk-button theme="default" :class="['editor-btn',{ 'forbidMark': isForbid }]" @click="deleteProfile">
{{$t('删除')}}
</bk-button>
</template>
</template>
<template v-else>
<bk-button theme="default" :class="['editor-btn',{ 'forbidMark': isForbid }]" @click="deleteProfile">
{{$t('删除')}}
<bk-button theme="default" @click="restoreProfile">
{{$t('恢复')}}
</bk-button>
</template>
<div class="reset">
<bk-button theme="default" @click="showResetDialog">
<bk-button :disabled="isStatus" theme="default" @click="showResetDialog">
{{$t('重置密码')}}
</bk-button>
<div class="reset-dialog" v-if="isShowReset" v-click-outside="closeResetDialog">
Expand Down Expand Up @@ -203,6 +210,9 @@ export default {
// 这里先根据唯一字段 username 判断是否是 admin 用户
return this.currentProfile.username === 'admin';
},
isStatus() {
return this.currentProfile.status === 'DELETED';
},
},
mounted() {
this.$nextTick(() => {
Expand Down Expand Up @@ -259,6 +269,10 @@ export default {
deleteProfile() {
this.$emit('deleteProfile');
},
// 恢复已删除用户
restoreProfile() {
this.$emit('restoreProfile');
},
// 禁用/启用
async changeStatus() {
try {
Expand Down
43 changes: 41 additions & 2 deletions src/pages/src/views/organization/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@
:no-search-or-search-department="noSearchOrSearchDepartment"
@viewDetails="viewDetails"
@showTableLoading="showTableLoading"
@closeTableLoading="closeTableLoading" />
@closeTableLoading="closeTableLoading"
@updateTableData="updateTableData" />
<div class="table-pagination" v-if="noSearchOrSearchDepartment && paginationConfig.count > 0">
<div class="table-pagination-left">{{$t('共计')}}
{{Math.ceil(paginationConfig.count / paginationConfig.limit)}} {{$t('页')}},
Expand Down Expand Up @@ -251,7 +252,8 @@
@updateUserInfor="updateUserInfor"
@editProfile="editProfile"
@handleCancelEdit="handleCancelEdit"
@deleteProfile="deleteProfile" />
@deleteProfile="deleteProfile"
@restoreProfile="restoreProfile" />
</div>
</bk-sideslider>
<!-- 弹窗操作 -->
Expand Down Expand Up @@ -891,6 +893,9 @@ export default {
this.detailsBarInfo.basicLoading = false;
this.detailsBarInfo.quickClose = true;
},
updateTableData(item) {
this.tableData = item;
},
// 侧边栏 点击保存 更新列表 userMessage.userInforList
async updateUserInfor() {
if (this.treeSearchResult && this.treeSearchResult.groupType !== 'department') {
Expand Down Expand Up @@ -1144,6 +1149,40 @@ export default {
},
});
},
// 恢复某一条用户信息
restoreProfile() {
this.clickSecond = true;
this.hideBar();
this.$store.dispatch('organization/postProfilesRestoration', {
id: this.currentProfile.id,
}).then((res) => {
if (res.result === true) {
this.$bkMessage({
message: this.$t('恢复成功'),
theme: 'success',
});
this.currentProfile.status = 'NORMAL';
}
this.detailsBarInfo.isShow = false;
setTimeout(() => {
this.isHideBar = false;
}, 500);
if (this.treeSearchResult && this.treeSearchResult.groupType !== 'department') {
// 搜索个人信息下删除 profile 关闭搜索
this.basicLoading = false;
this.$refs.searchChild.closeSearch();
} else {
this.getTableData();
}
})
.catch((e) => {
console.warn(e);
this.showBar();
})
.finally(() => {
this.clickSecond = false;
});
},
// 点击某个树节点
handleClickTreeNode(item, isSearchProfile = false) {
if (isSearchProfile) {
Expand Down
1 change: 1 addition & 0 deletions src/pages/src/views/organization/table/UserTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default {
},
methods: {
handleOriginList(value) {
this.$emit('updateTableData', value);
if (this.isAllChecked) {
this.isAllChecked = false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/src/views/organization/tree/TreeSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ export default {
return this.$t('已冻结');
case 'DISABLED':
return this.$t('已禁用');
case 'DELETED':
return this.$t('已删除');
}
},
dealDepartmentPath(path) {
Expand Down

0 comments on commit 6586a57

Please sign in to comment.