From 3fc4bec81a0e52a4758518cc12dc7fe651aff44d Mon Sep 17 00:00:00 2001 From: ANHE <1983933789@qq.com> Date: Wed, 19 Mar 2025 23:27:42 +0800 Subject: [PATCH] =?UTF-8?q?chore:=E5=AE=8C=E5=96=84=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advanced/table-header-operation.vue | 2 +- src/hooks/business/auth.ts | 21 +++++++- src/service/api/system/tenant.ts | 8 +++ src/typings/components.d.ts | 2 - src/views/system/tenant/index.vue | 52 ++++++++++++++----- .../tenant/modules/tenant-operate-drawer.vue | 4 +- 6 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/components/advanced/table-header-operation.vue b/src/components/advanced/table-header-operation.vue index 5a50cbad..d57da441 100644 --- a/src/components/advanced/table-header-operation.vue +++ b/src/components/advanced/table-header-operation.vue @@ -72,7 +72,7 @@ function handleExport() { {{ $t('common.confirmDelete') }} - + diff --git a/src/hooks/business/auth.ts b/src/hooks/business/auth.ts index f8bab27e..633818b9 100644 --- a/src/hooks/business/auth.ts +++ b/src/hooks/business/auth.ts @@ -21,7 +21,26 @@ export function useAuth() { return codeList.some(code => permissions.includes(code)); } + function hasRole(roleCodes: string | string[]) { + if (!authStore.isLogin) { + return false; + } + + const { roles } = authStore.userInfo; + + // 超级管理员拥有所有角色权限 + if (roles.includes('superadmin') || roles.includes('admin')) { + return true; + } + + // 将单个角色转换为数组统一处理 + const codeList = Array.isArray(roleCodes) ? roleCodes : [roleCodes]; + + return codeList.some(code => roles.includes(code)); + } + return { - hasAuth + hasAuth, + hasRole }; } diff --git a/src/service/api/system/tenant.ts b/src/service/api/system/tenant.ts index 5b0423fc..2ebdaf03 100644 --- a/src/service/api/system/tenant.ts +++ b/src/service/api/system/tenant.ts @@ -38,3 +38,11 @@ export function fetchBatchDeleteTenant(ids: CommonType.IdType[]) { method: 'delete' }); } + +/** 同步租户字典 */ +export function fetchSyncTenantDict() { + return request({ + url: '/system/tenant/syncTenantDict', + method: 'get' + }); +} diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 9efc2f03..f8d63331 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -47,8 +47,6 @@ declare module 'vue' { IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default'] IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] 'IconMingcute:questionLine': typeof import('~icons/mingcute/question-line')['default'] - 'IconPh:questionLight': typeof import('~icons/ph/question-light')['default'] - 'IconStash:questionLight': typeof import('~icons/stash/question-light')['default'] IconUilSearch: typeof import('~icons/uil/search')['default'] LangSwitch: typeof import('./../components/common/lang-switch.vue')['default'] LookForward: typeof import('./../components/custom/look-forward.vue')['default'] diff --git a/src/views/system/tenant/index.vue b/src/views/system/tenant/index.vue index 6851a52d..1ca0af5f 100644 --- a/src/views/system/tenant/index.vue +++ b/src/views/system/tenant/index.vue @@ -1,9 +1,11 @@