From 448856e54769dda6959114748121afc3be0681a0 Mon Sep 17 00:00:00 2001
From: dap <15891557205@163.com>
Date: Thu, 15 Jan 2026 10:03:39 +0800
Subject: [PATCH] =?UTF-8?q?feat(role):=20=E6=B7=BB=E5=8A=A0=E8=A7=92?=
=?UTF-8?q?=E8=89=B2=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E5=B8=B8=E9=87=8F?=
=?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E8=A7=92=E8=89=B2=E7=8A=B6=E6=80=81?=
=?UTF-8?q?=E5=88=87=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
refactor(role): 使用常量替换硬编码的角色ID和key
fix(role): 修正角色排序默认值为1
feat(component): 导出ApiSwitch全局组件
---
apps/web-antd/src/components/global/index.ts | 2 ++
apps/web-antd/src/views/system/role/data.tsx | 2 +-
apps/web-antd/src/views/system/role/index.vue | 31 ++++++++++++++-----
packages/constants/src/core.ts | 10 ++++++
4 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/apps/web-antd/src/components/global/index.ts b/apps/web-antd/src/components/global/index.ts
index cd5aa428..a5eee63e 100644
--- a/apps/web-antd/src/components/global/index.ts
+++ b/apps/web-antd/src/components/global/index.ts
@@ -12,3 +12,5 @@ export function setupGlobalComponent(app: App) {
// 表格操作列专用按钮
app.component('GhostButton', GhostButton);
}
+
+export { default as ApiSwitch } from './api-switch.vue';
diff --git a/apps/web-antd/src/views/system/role/data.tsx b/apps/web-antd/src/views/system/role/data.tsx
index 43184da3..f84391ea 100644
--- a/apps/web-antd/src/views/system/role/data.tsx
+++ b/apps/web-antd/src/views/system/role/data.tsx
@@ -131,7 +131,7 @@ export const drawerSchema: FormSchemaGetter = () => [
fieldName: 'roleSort',
label: '角色排序',
rules: 'required',
- defaultValue: 0,
+ defaultValue: 1,
},
{
component: 'Select',
diff --git a/apps/web-antd/src/views/system/role/index.vue b/apps/web-antd/src/views/system/role/index.vue
index 1aff61f1..4b961ff4 100644
--- a/apps/web-antd/src/views/system/role/index.vue
+++ b/apps/web-antd/src/views/system/role/index.vue
@@ -9,6 +9,12 @@ import { useRouter } from 'vue-router';
import { useAccess } from '@vben/access';
import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui';
+import {
+ ADMIN_ROLE_KEY,
+ EnableStatus,
+ SUPERADMIN_ROLE_ID,
+ SUPERADMIN_ROLE_KEY,
+} from '@vben/constants';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'antdv-next';
@@ -20,7 +26,7 @@ import {
roleList,
roleRemove,
} from '#/api/system/role';
-import { TableSwitch } from '#/components/table';
+import { ApiSwitch } from '#/components/global';
import { commonDownloadExcel } from '#/utils/file/download';
import { columns, querySchema } from './data';
@@ -122,7 +128,7 @@ function handleDownloadExcel() {
const { hasAccessByCodes, hasAccessByRoles } = useAccess();
-const isSuperAdmin = computed(() => hasAccessByRoles(['superadmin']));
+const isSuperAdmin = computed(() => hasAccessByRoles([SUPERADMIN_ROLE_KEY]));
const [RoleAuthModal, authModalApi] = useVbenModal({
connectedComponent: roleAuthModal,
@@ -137,6 +143,13 @@ const router = useRouter();
function handleAssignRole(record: Role) {
router.push(`/system/role-auth/user/${record.roleId}`);
}
+
+async function handleChangeStatus(checked: boolean, row: Role) {
+ await roleChangeStatus({
+ roleId: row.roleId,
+ status: checked ? EnableStatus.Enable : EnableStatus.Disable,
+ });
+}
@@ -169,12 +182,12 @@ function handleAssignRole(record: Role) {
-