chore:完善租户管理功能
This commit is contained in:
parent
43ea8ed755
commit
3fc4bec81a
@ -72,7 +72,7 @@ function handleExport() {
|
||||
</template>
|
||||
{{ $t('common.confirmDelete') }}
|
||||
</NPopconfirm>
|
||||
<NButton v-if="showExport" size="small" ghost type="warning" @click="handleExport">
|
||||
<NButton v-if="showExport" size="small" ghost @click="handleExport">
|
||||
<template #icon>
|
||||
<icon-ic-round-download class="text-icon" />
|
||||
</template>
|
||||
|
@ -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
|
||||
};
|
||||
}
|
||||
|
@ -38,3 +38,11 @@ export function fetchBatchDeleteTenant(ids: CommonType.IdType[]) {
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
/** 同步租户字典 */
|
||||
export function fetchSyncTenantDict() {
|
||||
return request<boolean>({
|
||||
url: '/system/tenant/syncTenantDict',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
2
src/typings/components.d.ts
vendored
2
src/typings/components.d.ts
vendored
@ -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']
|
||||
|
@ -1,9 +1,11 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm } from 'naive-ui';
|
||||
import { fetchBatchDeleteTenant, fetchGetTenantList } from '@/service/api/system/tenant';
|
||||
import { computed } from 'vue';
|
||||
import { fetchBatchDeleteTenant, fetchGetTenantList, fetchSyncTenantDict } from '@/service/api/system/tenant';
|
||||
import { $t } from '@/locales';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useAuthStore } from '@/store/modules/auth';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import DictTag from '@/components/custom/dict-tag.vue';
|
||||
import { useDownload } from '@/hooks/business/download';
|
||||
@ -20,7 +22,11 @@ useDict('sys_normal_disable');
|
||||
const appStore = useAppStore();
|
||||
const { download } = useDownload();
|
||||
const { hasAuth } = useAuth();
|
||||
const { userInfo } = useAuthStore();
|
||||
|
||||
const isSuperAdmin = computed(() => {
|
||||
return userInfo.user?.userId === 1;
|
||||
});
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
@ -178,6 +184,13 @@ async function edit(id: CommonType.IdType) {
|
||||
handleEdit('id', id);
|
||||
}
|
||||
|
||||
async function handleSyncTenantDict() {
|
||||
const { error } = await fetchSyncTenantDict();
|
||||
if (error) return;
|
||||
window.$message?.success('同步租户字典成功');
|
||||
await getData();
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
download('/system/tenant/export', searchParams, '租户列表.xlsx');
|
||||
}
|
||||
@ -188,18 +201,31 @@ async function handleExport() {
|
||||
<TenantSearch v-model:model="searchParams" @reset="resetSearchParams" @search="getDataByPage" />
|
||||
<NCard title="租户列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:disabled-delete="checkedRowKeys.length === 0"
|
||||
:loading="loading"
|
||||
:show-add="hasAuth('system:tenant:add')"
|
||||
:show-delete="hasAuth('system:tenant:delete')"
|
||||
:show-export="hasAuth('system:tenant:export')"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@export="handleExport"
|
||||
@refresh="getData"
|
||||
/>
|
||||
<NSpace>
|
||||
<NPopconfirm @positive-click="() => handleSyncTenantDict()">
|
||||
<template #trigger>
|
||||
<NButton v-if="isSuperAdmin" size="small">
|
||||
<template #icon>
|
||||
<icon-material-symbols:sync-rounded />
|
||||
</template>
|
||||
同步租户字典
|
||||
</NButton>
|
||||
</template>
|
||||
确认同步租户字典?
|
||||
</NPopconfirm>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:disabled-delete="checkedRowKeys.length === 0"
|
||||
:loading="loading"
|
||||
:show-add="hasAuth('system:tenant:add')"
|
||||
:show-delete="hasAuth('system:tenant:delete')"
|
||||
:show-export="hasAuth('system:tenant:export')"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@export="handleExport"
|
||||
@refresh="getData"
|
||||
/>
|
||||
</NSpace>
|
||||
</template>
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
|
@ -265,7 +265,7 @@ watch(visible, () => {
|
||||
<template #label>
|
||||
<span class="flex-y-center">
|
||||
用户数量
|
||||
<NTooltip trigger="hover">
|
||||
<NTooltip :show-arrow="false" trigger="hover">
|
||||
<template #trigger>
|
||||
<icon-mingcute:question-line class="ml-4px cursor-pointer text-14px" />
|
||||
</template>
|
||||
@ -279,7 +279,7 @@ watch(visible, () => {
|
||||
<template #label>
|
||||
<span class="flex-y-center">
|
||||
绑定域名
|
||||
<NTooltip trigger="hover">
|
||||
<NTooltip :show-arrow="false" trigger="hover">
|
||||
<template #trigger>
|
||||
<icon-mingcute:question-line class="ml-4px cursor-pointer text-14px" />
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user