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