Skip to content

Commit

Permalink
feat:用户个人视角 权限管理优化 TencentBlueKing#11138
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 26102
  • Loading branch information
useryuyu committed Dec 6, 2024
1 parent afb8e7c commit c01d35a
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
:group-total="projectTable.count"
:limit="projectTable.limit"
:pagination="projectTable.pagination"
:is-remote-pagination="projectTable.isRemotePagination"
:current="projectTable.current"
:selected-data="selectedData"
:has-next="projectTable.hasNext"
Expand Down Expand Up @@ -69,6 +70,7 @@
:resource-type="item.resourceType"
:group-total="item.count"
:pagination="item.pagination"
:is-remote-pagination="item.isRemotePagination"
:limit="item.limit"
:current="item.current"
:selected-data="selectedData"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
show-overflow-tooltip
:pagination="pagination"
:border="border"
remote-pagination
:remote-pagination="isRemotePagination"
empty-cell-text="--"
selection-key="resourceCode"
:checked="selectedResourceCode"
Expand Down Expand Up @@ -105,10 +105,10 @@
text
theme="primary"
@click="handleRenewal(row)"
:disabled="row.beingHandedOver || row.removeMemberButtonControl === 'DEPARTMENT'"
:disabled="row.removeMemberButtonControl === 'DEPARTMENT'"
v-bk-tooltips="{
content: row.beingHandedOver ? t('等待审核中') : row.removeMemberButtonControl === 'DEPARTMENT' ? t('通过组织加入的 不允许 续期/移出/移交') : '',
disabled: !row.beingHandedOver && row.removeMemberButtonControl !== 'DEPARTMENT'
content: t('通过组织加入的 不允许 续期/移出/移交'),
disabled: row.removeMemberButtonControl !== 'DEPARTMENT'
}"
>
{{t("续期")}}
Expand All @@ -118,10 +118,10 @@
theme="primary"
class="operation-btn"
@click="handleHandOver(row, index)"
:disabled="row.isExpired || row.removeMemberButtonControl === 'DEPARTMENT'"
:disabled="row.isExpired || row.removeMemberButtonControl === 'DEPARTMENT' || row.beingHandedOver "
v-bk-tooltips="{
content: row.isExpired ? t('已过期,无需移交') : row.removeMemberButtonControl === 'DEPARTMENT' ? t('通过组织加入的 不允许 续期/移出/移交') : '',
disabled: !row.isExpired && row.removeMemberButtonControl !== 'DEPARTMENT'
content: row.isExpired ? t('已过期,无需移交') : row.removeMemberButtonControl === 'DEPARTMENT' ? t('通过组织加入的 不允许 续期/移出/移交') : row.beingHandedOver ? t('等待审核中') : '',
disabled: !row.isExpired && row.removeMemberButtonControl !== 'DEPARTMENT' && !row.beingHandedOver
}"
>
{{t("移交")}}
Expand All @@ -133,8 +133,8 @@
:disabled="row.removeMemberButtonControl != 'OTHER'"
@click="handleRemove(row, index)"
v-bk-tooltips="{
content: TOOLTIPS_CONTENT[row.removeMemberButtonControl] || '',
disabled: row.removeMemberButtonControl === 'OTHER'
content: row.beingHandedOver ? t('等待审核中') : TOOLTIPS_CONTENT[row.removeMemberButtonControl],
disabled: row.removeMemberButtonControl === 'OTHER' && !row.beingHandedOver
}"
>
{{t("移出")}}
Expand Down Expand Up @@ -177,6 +177,10 @@ const props = defineProps({
loading: Boolean,
groupName: String,
batchFlag: String,
isRemotePagination:{
type: Boolean,
default: true,
},
});
const emit = defineEmits([
'handleRenewal',
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/devops-permission/src/css/svg/info-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions src/frontend/devops-permission/src/http/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import fetch from './fetch';
import { OPERATE_CHANNEL } from "@/utils/constants";

const apiPerfix = '/ms/auth/api/user';
const projectPerfix = 'ms/project/api/user'

export default {
getUser() {
return fetch.get(`${projectPerfix}/users`);
Expand Down Expand Up @@ -62,7 +64,7 @@ export default {
* 获取(代码库、流水线、部署节点)授权列表
*/
getResourceAuthList(projectId: string, params: any) {
return fetch.post(`${apiPerfix}/auth/authorization/${projectId}/listResourceAuthorization?operateChannel=PERSONAL`, params);
return fetch.post(`${apiPerfix}/auth/authorization/${projectId}/listResourceAuthorization?operateChannel=${OPERATE_CHANNEL}`, params);
},
/**
* 批量交接用户组成员
Expand Down Expand Up @@ -169,9 +171,15 @@ export default {
return fetch.post(`${apiPerfix}/auth/handover/listGroupsOfHandover`, params);
},
/**
* 获取交接单中用户组相关
* 获取移交移出时的单条数据
*/
getMemberGroupDetails(projectId: string, resourceType: string, groupId: number, memberId: string) {
return fetch.get(`${apiPerfix}/auth/resource/group/${projectId}/${resourceType}/${groupId}/getMemberGroupDetails?memberId=${memberId}`);
},
/**
* 单条移出检测是否可以直接移出项目
*/
getMemberGroupDetails(projectId: string, resourceType: string, groupId: number) {
return fetch.get(`${apiPerfix}/auth/resource/group/${projectId}/${resourceType}/${groupId}/getMemberGroupDetails`);
getIsDirectRemove(projectId: string, groupId: number, params: any) {
return fetch.DELETE(`${apiPerfix}/auth/resource/member/${projectId}/single/${groupId}/${OPERATE_CHANNEL}/remove`, params);
},
}
}
44 changes: 28 additions & 16 deletions src/frontend/devops-permission/src/store/userGroupTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRoute } from 'vue-router';
import { ref, reactive, computed, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import dayjs from 'dayjs';
import { OPERATE_CHANNEL } from "@/utils/constants";

interface GroupTableType {
resourceCode: string,
Expand Down Expand Up @@ -36,8 +37,8 @@ interface SourceType {
activeFlag?: boolean;
tableLoading?: boolean;
scrollLoading?: boolean;
isRemotePagination?: boolean;
tableData: GroupTableType[];
allSelectData?: GroupTableType[];
}
interface SelectedDataType {
[key: string]: GroupTableType[];
Expand Down Expand Up @@ -110,7 +111,7 @@ export default defineStore('userGroupTable', () => {
paginations.value = []
try {
const query = {
operateChannel: 'PERSONAL',
operateChannel: OPERATE_CHANNEL,
memberId: memberId,
...searchObj,
}
Expand All @@ -125,6 +126,7 @@ export default defineStore('userGroupTable', () => {
...item,
tableLoading: false,
scrollLoading: false,
isRemotePagination: true,
tableData: [],
}))

Expand All @@ -145,7 +147,7 @@ export default defineStore('userGroupTable', () => {
}
try {
const params = {
operateChannel: 'PERSONAL',
operateChannel: OPERATE_CHANNEL,
memberId: memberId.value,
start: paginations.value[resourceType][0],
limit: paginations.value[resourceType][1],
Expand Down Expand Up @@ -295,6 +297,19 @@ export default defineStore('userGroupTable', () => {
console.log(error);
}
}
/**
* 替换行数据
*/
async function handleReplaceRow(memberId: string) {
const activeTableData = sourceList.value.find(group => group.resourceType === selectedTableGroupType.value);
if (activeTableData) {
const res = await http.getMemberGroupDetails(projectId.value, selectedRow.value!.resourceType, selectedRow.value!.groupId, memberId)
activeTableData.tableData?.splice(rowIndex.value as number, 1, res);
activeTableData.tableData = [...activeTableData.tableData];
}
isPermission.value = sourceList.value.every(item => item.count !== 0)
handleClear(selectedTableGroupType.value);
}
/**
* 删除行数据
*/
Expand Down Expand Up @@ -338,10 +353,9 @@ export default defineStore('userGroupTable', () => {
count: sourceItem.isAll ? sourceItem.count! : tableData.length
},
...sourceItem,
tableData: tableData.slice(0, 11),
tableData: tableData,
...(!sourceItem.isAll && { isRemotePagination: false }),
...(!sourceItem.isAll && { groupIds: tableData.map(item => item.groupId) }),
...(!sourceItem.isAll && { count: tableData.length }),
...(!sourceItem.isAll && { allSelectData: tableData })
};
});
}
Expand Down Expand Up @@ -416,16 +430,11 @@ export default defineStore('userGroupTable', () => {
try {
let item = selectSourceList.value.find((item: SourceType) => item.resourceType == resourceType);
if (item) {
paginations.value[resourceType][1] = limit;
item.tableLoading = true;
if (item.isAll) {
paginations.value[resourceType][1] = limit;
paginations.value[resourceType][0] = 1;
if (item.isRemotePagination) {
const res = await getGroupList(resourceType, searchObj.value)
item.tableData = res.records;
item.tableLoading = false;
} else {
item.tableData = [];
item.tableData = item.allSelectData!.slice(0, limit + 1);
}
item.tableLoading = false;
}
Expand All @@ -437,14 +446,16 @@ export default defineStore('userGroupTable', () => {
* 切换表格分页时
*/
async function pageValueChange(value: number, resourceType: string) {
paginations.value[resourceType][0] = (value - 1) * 10 + 1;
try {
let item = selectSourceList.value.find((item: SourceType) => item.resourceType == resourceType);
if (item) {
paginations.value[resourceType][0] = (value - 1) * 10 + 1;
item.tableLoading = true;
const res = await getGroupList(resourceType, searchObj.value)
if (item.isRemotePagination) {
const res = await getGroupList(resourceType, searchObj.value)
item.tableData = res.records;
}
item.tableLoading = false;
item.tableData = res.records;
}
} catch (error) {

Expand Down Expand Up @@ -475,6 +486,7 @@ export default defineStore('userGroupTable', () => {
handleSelectAllData,
handleClear,
collapseClick,
handleReplaceRow,
handleRemoveRow,
handleUpDateRow,
pageLimitChange,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/devops-permission/src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

export const OPERATE_CHANNEL = 'PERSONAL';
export const TIME_FILTERS = {
30: '1个月',
90: '3个月',
Expand Down
Loading

0 comments on commit c01d35a

Please sign in to comment.