Skip to content

Commit

Permalink
feat: 项目成员管理 #9620
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 15090
  • Loading branch information
vhwweng committed Aug 13, 2024
1 parent 113250d commit 80ad448
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<bk-loading class="aside" :loading="manageAsideStore.isLoading" >
<bk-loading class="aside" :loading="manageAsideStore.isLoading">
<div class="aside-header">
{{t("组织/用户")}}
<span class="refresh" @click="refresh">
Expand Down Expand Up @@ -88,96 +88,99 @@
:width="640"
@closed="handOverClose"
>
<template #header>
{{ t("移出项目") }}
<span class="dialog-header"> {{t("移出用户")}}: {{ removeUser.id }}({{ removeUser.name }}) </span>
</template>
<template #default>
<template v-if="removeMemberChecked">
<p class="remove-tips">{{ t('XXX拥有的权限均已过期,无需交接,确定移出用户并清理过期权限吗?', [`${removeUser.id}(${removeUser.name})}`]) }}</p>
</template>
<template v-else>
<div class="dialog">
<p class="text-tag">
<i class="manage-icon manage-icon-info-line"></i>
<span>
{{t("将用户移出项目前,需要指定移交人,平台将自动完成所有权限/授权的移交")}}。
</span>
</p>
<bk-form
ref="formRef"
:rules="rules"
:model="handOverForm"
form-type="vertical"
>
<bk-form-item
required
:label="t('移交人')"
property="name"
labelWidth=""
<template #header>
{{ t("移出项目") }}
<span class="dialog-header"> {{t("移出用户")}}: {{ removeUser.id }}({{ removeUser.name }}) </span>
</template>
<bk-loading :loading="removeCheckLoading">
<template #default>
<template v-if="removeMemberChecked">
<p class="remove-tips">{{ t('XXX拥有的权限均已过期,无需交接,确定移出用户并清理过期权限吗?', [`${removeUser.id}(${removeUser.name})}`]) }}</p>
</template>
<template v-else>
<div class="dialog">
<p class="text-tag">
<i class="manage-icon manage-icon-info-line"></i>
<span>
{{t("将用户移出项目时需指定移交人,确认后将自动移交有效的权限/授权;已过期权限不交接,将自动清理。")}}
</span>
</p>
<bk-form
ref="formRef"
:rules="rules"
:model="handOverForm"
form-type="vertical"
>
<project-user-selector
@change="handleChangeOverFormName"
@removeAll="handOverInputClear"
<bk-form-item
required
:label="t('移交人')"
property="name"
labelWidth=""
>
</project-user-selector>
</bk-form-item>
</bk-form>

<p class="verifying">
<span v-if="isChecking">
<Spinner class="check-checking-icon" />
{{ t("正在校验授权") }}
</span>
<span v-if="isAuthorizedSuccess">
<Success class="check-success-icon" />
{{t("授权校验通过")}}
</span>
</p>

<div v-if="isHandOverfail" class="hand-over-fail">
<p class="err-text">
<p class="deal">
<i class="manage-icon manage-icon-close"></i>
<i18n-t keypath="检测到以下授权将无法移交给X,请先前往「授权管理」单独处理" tag="div" >
<span> {{ handOverForm.name }} </span>
</i18n-t>
</p>
<p class="blue-text" @click="refreshHandOverfail">
<i class="manage-icon manage-icon-refresh"></i>
<span>{{t("刷新")}}</span>
</p>
<project-user-selector
@change="handleChangeOverFormName"
@removeAll="handOverInputClear"
>
</project-user-selector>
</bk-form-item>
</bk-form>

<p class="verifying">
<span v-if="isChecking">
<Spinner class="check-checking-icon" />
{{ t("正在校验授权") }}
</span>
<span v-if="isAuthorizedSuccess">
<Success class="check-success-icon" />
{{t("授权校验通过")}}
</span>
</p>
<div class="hand-over-table-group" v-for="item in overTable" :key="item.id">
<p class="hand-over-table-item">
{{item.name}}({{ item.resourceType }})
</p>
<p class="blue-text" @click="goAuthorization(item.resourceType)">
<i class="manage-icon manage-icon-jump"></i>
<span>{{t("前往处理")}}</span>

<div v-if="isHandOverfail" class="hand-over-fail">
<p class="err-text">
<p class="deal">
<i class="manage-icon manage-icon-close"></i>
<i18n-t keypath="检测到以下授权将无法移交给X,请先前往「授权管理」单独处理" tag="div" >
<span> {{ handOverForm.name }} </span>
</i18n-t>
</p>
<p class="blue-text" @click="refreshHandOverfail">
<i class="manage-icon manage-icon-refresh"></i>
<span>{{t("刷新")}}</span>
</p>
</p>
<div class="hand-over-table-group" v-for="item in overTable" :key="item.id">
<p class="hand-over-table-item">
{{item.name}}({{ item.resourceType }})
</p>
<p class="blue-text" @click="goAuthorization(item.resourceType)">
<i class="manage-icon manage-icon-jump"></i>
<span>{{t("前往处理")}}</span>
</p>
</div>
</div>
</div>
</div>
</template>
</template>
</template>
<template #footer>
<bk-button
theme="primary"
@click="handConfirm('user')"
:loading="manageAsideStore.btnLoading"
:disabled="!isAuthorizedSuccess && !removeMemberChecked"
>
{{ removeMemberChecked ? t('确定') : t("移交并移出")}}
</bk-button>
<bk-button
class="btn-margin"
@click="handOverClose"
>
{{ t('取消') }}
</bk-button>
</template>
<template #footer>
<bk-button
theme="primary"
@click="handConfirm('user')"
:loading="manageAsideStore.btnLoading"
:disabled="!isAuthorizedSuccess && !removeMemberChecked"
>
{{ removeMemberChecked ? t('确定') : t("移交并移出")}}
</bk-button>
<bk-button
class="btn-margin"
@click="handOverClose"
>
{{ t('取消') }}
</bk-button>
</template>
</bk-loading>
</bk-dialog>

<bk-dialog
:width="480"
theme="primary"
Expand Down Expand Up @@ -253,6 +256,7 @@ const route = useRoute();
const manageAsideStore = useManageAside();
const current = ref(1);
const isShowHandOverDialog = ref(false);
const removeCheckLoading = ref(false);
const formRef = ref(null);
const isHandOverfail = ref(false);
const isShowPersonDialog = ref(false);
Expand Down Expand Up @@ -323,23 +327,26 @@ function pageChange(current) {
emit('pageChange', current, projectId.value);
}
async function handleRemoval(item) {
if(item.type === 'department') {
removeUser.value = item;
if (item.type === 'department') {
isShowRemoveDialog.value = true;
} else {
await removeMemberFromProjectCheck(item);
handOverForm.value && (Object.assign(handOverForm.value, getHandOverForm()));
formRef.value?.clearValidate();
isShowHandOverDialog.value = true;
await removeMemberFromProjectCheck(item);
formRef.value?.clearValidate();
}
removeUser.value = item;
}
async function removeMemberFromProjectCheck (payload) {
try {
removeCheckLoading.value = true;
removeMemberChecked.value = await http.removeMemberFromProjectCheck(projectId.value, {
targetMember: payload
})
removeCheckLoading.value = false;
} catch (e) {
removeCheckLoading.value = false;
console.error(e)
}
Expand Down Expand Up @@ -639,7 +646,7 @@ onUnmounted(() => {
.manage-icon-info-line{
font-size: 14px;
color: #3A84FF;
margin-right: 10px;
margin-right: 5px;
}
span {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ul class="aside">
<li
class="aside-item"
:class="activeIndex == index ? 'aside-active' : ''"
:class="resourceType == item.resourceType ? 'aside-active' : ''"
v-for="(item, index) in permissionList"
:key="index"
@click="handleAsideClick(item, index)"
Expand Down Expand Up @@ -146,10 +146,11 @@
<bk-table
ref="resetTable"
:data="resetTableData"
:pagination="resetTablePagination"
:border="['outer', 'row']"
show-overflow-tooltip
>
<bk-table-column :label="searchName" prop="resourceName" />
<bk-table-column :label="searchName" width="200" prop="resourceName" />
<bk-table-column :label="t('失败原因')" prop="handoverFailedMessage">
<template v-slot="{ row }">
<span class="failed-msg" v-html="row.handoverFailedMessage"></span>
Expand Down Expand Up @@ -195,7 +196,12 @@ const { t } = useI18n();
const route = useRoute();
const tableData = ref([]);
const resetTableData = ref([]);
const activeIndex = ref(0);
const resetTablePagination = ref({
count: 0,
limit: 6,
current: 1,
limitList: [6, 10, 20]
})
const formRef = ref(null);
const refTable = ref(null);
const selectList = ref([]);
Expand All @@ -209,8 +215,8 @@ const isChecking = ref(false);
const canLoading = ref(true);
const projectId = computed(() => route.params?.projectCode);
const userId = computed(() => route.query?.userId);
const resourceType = computed(() => route.query?.resourceType) || ref('pipeline');
console.log(resourceType, 'resourceType')
const initialResourceType = computed(() => route.query?.resourceType || 'repertory');
const resourceType = ref(initialResourceType.value);
const isSelectAll = ref(false); // 选择全量数据
const dateTimeRange = ref(['', '']);
const daterangeCache = ref(['', '']);
Expand Down Expand Up @@ -359,11 +365,6 @@ watch(() => searchValue.value, (val, oldVal) => {
});
onMounted(() => {
const currentResourceType = route.query.resourceType;
if(currentResourceType){
activeIndex.value = permissionList.value.findIndex(item => item.resourceType === currentResourceType);
resourceType.value = currentResourceType;
}
init();
});
Expand Down Expand Up @@ -419,8 +420,7 @@ async function getTableList () {
* aside点击事件
*/
function handleAsideClick(item, index) {
if (activeIndex.value === index) return;
activeIndex.value = index;
if (item.resourceType === resourceType.value) return;
resourceType.value = item.resourceType;
init();
};
Expand Down Expand Up @@ -510,7 +510,8 @@ async function handleCheckReset () {
if (!resetFormData.value.name) return // 点击input输入框清空按钮,会触发失焦事件
failedCount.value = res['FAILED']?.length || 0
if (failedCount.value) {
resetTableData.value = res['FAILED'].splice(0,6)
resetTableData.value = res['FAILED']
resetTablePagination.value.count = failedCount.value
}
isResetFailure.value = !!failedCount.value;
isResetSuccess.value = !failedCount.value;
Expand All @@ -519,6 +520,8 @@ async function handleCheckReset () {
const selectFlag = isSelectAll.value ? pagination.value.count : selectList.value.length
disabledResetBtn.value = failedCount.value === selectFlag;
} catch (e) {
isChecking.value = false;
canLoading.value = false;
console.error(e)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/locale/manage/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"人员列表": "User List",
"移出项目": "Remove",
"移出用户": "User",
"将用户移出项目前,需要指定移交人,平台将自动完成所有权限/授权的移交": "Before removing the user from the project, a transferee needs to be designated, and the platform will automatically transfer all permissions/authorizations",
"将用户移出项目时需指定移交人,确认后将自动移交有效的权限/授权;已过期权限不交接,将自动清理。": "When removing a user from the project, a transferee must be designated. Upon confirmation, valid permissions/authorizations will be automatically transferred; expired permissions will not be transferred and will be automatically cleaned up.",
"移交人": "Transferee",
"刷新": "Refresh",
"检测到以下授权将无法移交给X,请先前往「授权管理」单独处理": "The following authorizations cannot be transferred to {0}, please go to \"Authorization Management\" to handle it individually",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/locale/manage/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
"人员列表": "人员列表",
"移出项目": "移出项目",
"移出用户": "移出用户",
"将用户移出项目前,需要指定移交人,平台将自动完成所有权限/授权的移交": "将用户移出项目前,需要指定移交人,平台将自动完成所有权限/授权的移交",
"将用户移出项目时需指定移交人,确认后将自动移交有效的权限/授权;已过期权限不交接,将自动清理。": "将用户移出项目时需指定移交人,确认后将自动移交有效的权限/授权;已过期权限不交接,将自动清理。",
"移交人": "移交人",
"刷新": "刷新",
"检测到以下授权将无法移交给X,请先前往「授权管理」单独处理": "检测到以下授权将无法移交给{0},请先前往「授权管理」单独处理",
Expand Down

0 comments on commit 80ad448

Please sign in to comment.