Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
周期账单生成与变动记录抽屉;查看合并按账单日 Tabs;退款原因必填;开方成功页操作按钮自动换行。
85 lines
2.6 KiB
Vue
85 lines
2.6 KiB
Vue
<script lang="ts" setup>
|
||
/**
|
||
* 同步管理员管理菜单:为预设管理员角色补全「管理员」菜单组(73 + 对应子页)
|
||
*/
|
||
import { ref } from 'vue';
|
||
|
||
import { useVbenModal } from '@vben/common-ui';
|
||
|
||
import { Alert, message } from 'ant-design-vue';
|
||
|
||
import { countMissingAdminMenus, syncAdminManagementMenus } from '../api';
|
||
|
||
const missingCount = ref(0);
|
||
const missingRoleIds = ref<number[]>([]);
|
||
const gridApi = ref();
|
||
|
||
const [Modal, modalApi] = useVbenModal({
|
||
fullscreenButton: false,
|
||
draggable: true,
|
||
onCancel() {
|
||
modalApi.close();
|
||
},
|
||
onConfirm: async () => {
|
||
modalApi.setState({ loading: true, confirmLoading: true });
|
||
try {
|
||
const res = await syncAdminManagementMenus();
|
||
const synced = res?.synced_count ?? 0;
|
||
if (synced > 0) {
|
||
message.success(`已为 ${synced} 个角色补全管理员管理菜单(含父级菜单链)`);
|
||
} else {
|
||
message.info('未发现需要补全的管理员菜单');
|
||
}
|
||
gridApi.value?.reload?.();
|
||
modalApi.close();
|
||
} catch (err) {
|
||
console.error(err);
|
||
} finally {
|
||
modalApi.setState({ loading: false, confirmLoading: false });
|
||
}
|
||
},
|
||
onOpenChange: async (isOpen) => {
|
||
if (!isOpen) {
|
||
return;
|
||
}
|
||
gridApi.value = modalApi.getData()?.gridApi;
|
||
modalApi.setState({ loading: true });
|
||
try {
|
||
const res = await countMissingAdminMenus();
|
||
missingCount.value = res?.count ?? 0;
|
||
missingRoleIds.value = res?.role_ids ?? [];
|
||
} catch (err) {
|
||
console.error(err);
|
||
} finally {
|
||
modalApi.setState({ loading: false });
|
||
}
|
||
},
|
||
});
|
||
|
||
defineExpose(modalApi);
|
||
</script>
|
||
|
||
<template>
|
||
<Modal class="w-[80%] md:w-[50%]" title="同步管理员管理菜单">
|
||
<Alert
|
||
class="mb-4"
|
||
show-icon
|
||
type="info"
|
||
:message="
|
||
missingCount > 0
|
||
? `${missingCount} 个预设管理员角色缺少「管理员」菜单组`
|
||
: '各预设管理员角色的「管理员」菜单已齐全'
|
||
"
|
||
:description="
|
||
missingCount > 0
|
||
? `待补全角色 ID:${missingRoleIds.join('、')}(将追加菜单 4→21→73 及对应子页)`
|
||
: '可点击确定执行一次幂等检查;若侧栏仍无「管理员」菜单,请让对应账号重新登录'
|
||
"
|
||
/>
|
||
<div class="text-sm text-[hsl(var(--muted-foreground))]">
|
||
自动为可识别的管理员角色补全「基础管理 → RBAC管理 → 管理员 → 子页」整条菜单链。
|
||
预设角色按 ID 匹配;自定义角色按角色代码(value)与菜单路径匹配。仅追加缺失项。
|
||
</div>
|
||
</Modal>
|
||
</template>
|