feat: 权限管理组织获取权限调整

This commit is contained in:
RubyLiu 2024-01-29 19:31:54 +08:00 committed by Craftsman
parent 1f04a8423f
commit a3e8453536
4 changed files with 16 additions and 7 deletions

View File

@ -14,6 +14,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { getProjectList } from '@/api/modules/project-management/project'; import { getProjectList } from '@/api/modules/project-management/project';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { hasAnyPermission } from '@/utils/permission';
import type { ProjectListItem } from '@/models/setting/project'; import type { ProjectListItem } from '@/models/setting/project';
@ -44,8 +45,12 @@
onBeforeMount(async () => { onBeforeMount(async () => {
try { try {
const res = await getProjectList(appStore.getCurrentOrgId); if (appStore.currentOrgId && hasAnyPermission(['PROJECT_BASE_INFO:READ'])) {
projectList.value = res; const res = await getProjectList(appStore.getCurrentOrgId);
projectList.value = res;
} else {
projectList.value = [];
}
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(error); console.log(error);

View File

@ -132,6 +132,7 @@
import useLocale from '@/locale/useLocale'; import useLocale from '@/locale/useLocale';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import useUserStore from '@/store/modules/user'; import useUserStore from '@/store/modules/user';
import { hasAnyPermission } from '@/utils/permission';
import type { ProjectListItem } from '@/models/setting/project'; import type { ProjectListItem } from '@/models/setting/project';
@ -153,7 +154,7 @@
async function initProjects() { async function initProjects() {
try { try {
if (appStore.currentOrgId) { if (appStore.currentOrgId && hasAnyPermission(['PROJECT_BASE_INFO:READ'])) {
const res = await getProjectList(appStore.getCurrentOrgId); const res = await getProjectList(appStore.getCurrentOrgId);
projectList.value = res; projectList.value = res;
} else { } else {

View File

@ -52,7 +52,7 @@ function filterProject(role: UserRole, id: string) {
return role && role.type === 'PROJECT' && role.scopeId === id; return role && role.type === 'PROJECT' && role.scopeId === id;
} }
function filterOrganization(role: UserRole, id: string) { function filterOrganization(role: UserRole, id: string) {
return role && role.type === 'ORGANIZATION' && role.scopeId === id; return role && role.type === 'ORGANIZATION' && (role.scopeId === id || role.scopeId === 'global');
} }
function filterSystem(role: UserRole, id: string) { function filterSystem(role: UserRole, id: string) {
return role && role.type === 'SYSTEM' && role.scopeId === id; return role && role.type === 'SYSTEM' && role.scopeId === id;

View File

@ -32,7 +32,7 @@
import { getProjectList, switchProject } from '@/api/modules/project-management/project'; import { getProjectList, switchProject } from '@/api/modules/project-management/project';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { useAppStore, useUserStore } from '@/store'; import { useAppStore, useUserStore } from '@/store';
import { getFirstRouteNameByPermission } from '@/utils/permission'; import { getFirstRouteNameByPermission, hasAnyPermission } from '@/utils/permission';
import { SelectValue } from '@/models/projectManagement/menuManagement'; import { SelectValue } from '@/models/projectManagement/menuManagement';
import type { ProjectListItem } from '@/models/setting/project'; import type { ProjectListItem } from '@/models/setting/project';
@ -49,8 +49,11 @@
async function initProjects() { async function initProjects() {
try { try {
const res = await getProjectList(appStore.getCurrentOrgId); if (appStore.getCurrentOrgId && hasAnyPermission(['PROJECT_BASE_INFO:READ'])) {
projectList.value = res; const res = await getProjectList(appStore.getCurrentOrgId);
} else {
projectList.value = [];
}
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(error); console.log(error);