dap 2024-11-27 10:11:34 +08:00
parent d8d884ecc1
commit f4a1cc72d9
2 changed files with 27 additions and 59 deletions

View File

@ -1,21 +1,12 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import { computed, ref } from 'vue';
import { ref } from 'vue';
import { useAccess } from '@vben/access';
import { useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import {
Dropdown,
Menu,
MenuItem,
type MenuProps,
Modal,
Popconfirm,
Space,
} from 'ant-design-vue';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
tableCheckboxEvent,
@ -28,8 +19,6 @@ import {
dictTypeRemove,
refreshDictTypeCache,
} from '#/api/system/dict/dict-type';
import { dictSyncTenant } from '#/api/system/tenant';
import { useTenantStore } from '#/store/tenant';
import { commonDownloadExcel } from '#/utils/file/download';
import { emitter } from '../mitt';
@ -131,35 +120,11 @@ function handleMultiDelete() {
});
}
const handleMenuClick: MenuProps['onClick'] = (e) => {
switch (e.key) {
case '1': {
handleRefreshCache();
break;
}
case '2': {
handleSyncTenantDict();
break;
}
}
};
async function handleRefreshCache() {
await refreshDictTypeCache();
await tableApi.query();
}
function handleSyncTenantDict() {
Modal.confirm({
title: '提示',
iconType: 'warning',
content: '确认同步租户字典?',
onOk: async () => {
await dictSyncTenant();
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(
dictTypeExport,
@ -167,15 +132,6 @@ function handleDownloadExcel() {
tableApi.formApi.form.values,
);
}
const { hasAccessByRoles } = useAccess();
const tenantStore = useTenantStore();
/**
* 开启租户 & 超级管理员才可以同步租户字典
*/
const couldSyncTenantDict = computed(() => {
return tenantStore.tenantEnable && hasAccessByRoles(['superadmin']);
});
</script>
<template>
@ -183,19 +139,12 @@ const couldSyncTenantDict = computed(() => {
<BasicTable id="dict-type" table-title="字典类型列表">
<template #toolbar-tools>
<Space>
<Dropdown>
<template #overlay>
<Menu @click="handleMenuClick">
<span v-access:code="['system:dict:edit']">
<MenuItem key="1">刷新字典缓存</MenuItem>
</span>
<span v-if="couldSyncTenantDict">
<MenuItem key="2"> 同步租户字典 </MenuItem>
</span>
</Menu>
</template>
<a-button> 更多 </a-button>
</Dropdown>
<a-button
v-access:code="['system:dict:edit']"
@click="handleRefreshCache"
>
刷新缓存
</a-button>
<a-button
v-access:code="['system:dict:export']"
@click="handleDownloadExcel"

View File

@ -16,6 +16,7 @@ import {
type VxeGridProps,
} from '#/adapter/vxe-table';
import {
dictSyncTenant,
tenantExport,
tenantList,
tenantRemove,
@ -140,6 +141,18 @@ const { hasAccessByCodes, hasAccessByRoles } = useAccess();
const isSuperAdmin = computed(() => {
return hasAccessByRoles(['superadmin']);
});
function handleSyncTenantDict() {
Modal.confirm({
title: '提示',
iconType: 'warning',
content: '确认同步租户字典?',
onOk: async () => {
await dictSyncTenant();
await tableApi.query();
},
});
}
</script>
<template>
@ -147,6 +160,12 @@ const isSuperAdmin = computed(() => {
<BasicTable table-title="租户列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['system:tenant:edit']"
@click="handleSyncTenantDict"
>
同步租户字典
</a-button>
<a-button
v-access:code="['system:tenant:export']"
@click="handleDownloadExcel"