feat(系统设置): 用户组权限&组织项目权限补充

This commit is contained in:
RubyLiu 2024-01-30 11:21:27 +08:00 committed by 刘瑞斌
parent 685e7891c0
commit 4de46b9122
6 changed files with 71 additions and 53 deletions

View File

@ -390,18 +390,14 @@
};
//
const initData = async (id: string, internal: boolean) => {
const initData = async (id: string) => {
try {
let res: UserGroupAuthSetting[] = [];
loading.value = true;
if (systemType === AuthScopeEnum.SYSTEM) {
res = await getGlobalUSetting(id);
} else if (systemType === AuthScopeEnum.ORGANIZATION) {
if (internal) {
res = await getGlobalUSetting(id);
} else {
res = await getOrgUSetting(id);
}
res = await getOrgUSetting(id);
} else {
res = await getAuthByUserGroup(id);
}
@ -449,7 +445,7 @@
});
}
Message.success(t('common.saveSuccess'));
initData(props.current.id, props.current.internal);
initData(props.current.id);
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
@ -459,13 +455,13 @@
//
const handleReset = () => {
if (props.current.id) {
initData(props.current.id, props.current.internal);
initData(props.current.id);
}
};
watchEffect(() => {
if (props.current.id) {
initData(props.current.id, props.current.internal);
initData(props.current.id);
}
});
defineExpose({

View File

@ -167,6 +167,7 @@
</div>
</MsMoreAction>
<MsMoreAction
v-permission="['ORGANIZATION_USER_ROLE:READ+UPDATE']"
:list="orgMoreAction"
@select="(value) => handleMoreAction(value, element.id, AuthScopeEnum.ORGANIZATION)"
>

View File

@ -3,7 +3,7 @@
<template v-if="hasAnyPermission(props.updatePermission || [])" #quickCreate>
<MsConfirmUserSelector :ok-loading="okLoading" v-bind="userSelectorProps" @confirm="handleAddMember" />
</template>
<template #action="{ record }">
<template v-if="hasAnyPermission(props.updatePermission || [])" #action="{ record }">
<MsRemoveButton
:title="t('system.userGroup.removeName', { name: record.name })"
:sub-title-tip="t('system.userGroup.removeTip')"

View File

@ -25,9 +25,13 @@
<MsUserAdminDiv :is-admin="record.orgCreateUserIsAdmin" :name="record.createUser" />
</template>
<template #memberCount="{ record }">
<span class="cursor-pointer text-[rgb(var(--primary-5))]" @click="showUserDrawer(record)">{{
record.memberCount
}}</span>
<span
v-if="hasAnyPermission(['ORGANIZATION_PROJECT:READ+UPDATE'])"
class="cursor-pointer text-[rgb(var(--primary-5))]"
@click="showUserDrawer(record)"
>{{ record.memberCount }}</span
>
<span v-else>{{ record.memberCount }}</span>
</template>
<template #operation="{ record }">
<template v-if="record.deleted">
@ -103,6 +107,7 @@
import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
import { useAppStore, useTableStore } from '@/store';
import { hasAnyPermission } from '@/utils/permission';
import { UserItem } from '@/models/setting/log';
import { CreateOrUpdateSystemProjectParams, OrgProjectTableItem } from '@/models/setting/system/orgAndProject';
@ -117,6 +122,13 @@
const { openDeleteModal, openModal } = useModal();
const appStore = useAppStore();
const currentOrgId = computed(() => appStore.currentOrgId);
const hasOperationPermission = computed(() =>
hasAnyPermission([
'ORGANIZATION_PROJECT:READ+RECOVER',
'ORGANIZATION_PROJECT:READ+UPDATE',
'ORGANIZATION_PROJECT:READ+DELETE',
])
);
const keyword = ref('');
@ -126,39 +138,13 @@
dataIndex: 'num',
width: 100,
showTooltip: true,
filterConfig: {
multiple: false,
options: [
{
label: t('common.all'),
value: 'all',
},
{
label: t('common.only'),
value: 'only',
},
],
},
},
{
title: 'system.organization.name',
revokeDeletedSlot: 'revokeDelete',
editType: ColumnEditTypeEnum.INPUT,
editType: hasAnyPermission(['ORGANIZATION_PROJECT:READ+UPDATE']) ? ColumnEditTypeEnum.INPUT : undefined,
dataIndex: 'name',
showTooltip: true,
filterConfig: {
multiple: false,
options: [
{
label: t('common.all'),
value: 'all',
},
{
label: t('common.only'),
value: 'only',
},
],
},
},
{
title: 'system.organization.member',
@ -201,11 +187,11 @@
},
},
{
title: 'system.organization.operation',
title: hasOperationPermission.value ? 'system.organization.operation' : '',
slotName: 'operation',
dataIndex: 'operation',
fixed: 'right',
width: 230,
width: hasOperationPermission.value ? 230 : 50,
},
];

View File

@ -20,10 +20,22 @@
<MsUserAdminDiv :is-admin="record.projectCreateUserIsAdmin" :name="record.createUser" />
</template>
<template #memberCount="{ record }">
<span class="primary-color" @click="showUserDrawer(record)">{{ record.memberCount }}</span>
<span
v-if="hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE'])"
class="primary-color"
@click="showUserDrawer(record)"
>{{ record.memberCount }}</span
>
<span v-else>{{ record.memberCount }}</span>
</template>
<template #projectCount="{ record }">
<span class="primary-color" @click="showProjectDrawer(record)">{{ record.projectCount }}</span>
<span
v-if="hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE'])"
class="primary-color"
@click="showProjectDrawer(record)"
>{{ record.projectCount }}</span
>
<span v-else>{{ record.projectCount }}</span>
</template>
<template #operation="{ record }">
<template v-if="record.deleted">
@ -43,12 +55,14 @@
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" @click="showOrganizationModal(record)">{{
t('common.edit')
}}</MsButton>
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ']" @click="showAddUserModal(record)">{{
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" @click="showAddUserModal(record)">{{
t('system.organization.addMember')
}}</MsButton>
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ']" @click="handleEnableOrDisableOrg(record, false)">{{
t('common.end')
}}</MsButton>
<MsButton
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']"
@click="handleEnableOrDisableOrg(record, false)"
>{{ t('common.end') }}</MsButton
>
<MsTableMoreAction
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+DELETE']"
:list="tableActions"
@ -118,6 +132,13 @@
const currentOrganizationId = ref('');
const currentUpdateOrganization = ref<CreateOrUpdateSystemOrgParams>();
const { openDeleteModal, openModal } = useModal();
const hasOperationPermission = computed(() =>
hasAnyPermission([
'SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER',
'SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE',
'SYSTEM_ORGANIZATION_PROJECT:READ+DELETE',
])
);
const organizationColumns: MsTableColumn = [
{
@ -164,11 +185,11 @@
width: 180,
},
{
title: 'system.organization.operation',
title: hasOperationPermission.value ? 'system.organization.operation' : '',
slotName: 'operation',
dataIndex: 'operation',
fixed: 'right',
width: 230,
width: hasOperationPermission.value ? 230 : 50,
},
];

View File

@ -20,7 +20,13 @@
<MsUserAdminDiv :is-admin="record.projectCreateUserIsAdmin" :name="record.createUser" />
</template>
<template #memberCount="{ record }">
<span class="primary-color" @click="showUserDrawer(record)">{{ record.memberCount }}</span>
<span
v-if="hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE'])"
class="primary-color"
@click="showUserDrawer(record)"
>{{ record.memberCount }}</span
>
<span v-else>{{ record.memberCount }}</span>
</template>
<template #operation="{ record }">
<template v-if="record.deleted">
@ -117,6 +123,13 @@
const currentProjectId = ref('');
const currentUpdateProject = ref<CreateOrUpdateSystemProjectParams>();
const { openDeleteModal, openModal } = useModal();
const hasOperationPermission = computed(() =>
hasAnyPermission([
'SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER',
'SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE',
'SYSTEM_ORGANIZATION_PROJECT:READ+DELETE',
])
);
const organizationColumns: MsTableColumn = [
{
@ -167,10 +180,11 @@
width: 180,
},
{
title: 'system.organization.operation',
title: hasOperationPermission.value ? 'system.organization.operation' : '',
slotName: 'operation',
dataIndex: 'operation',
fixed: 'right',
width: 230,
width: hasOperationPermission.value ? 230 : 50,
},
];