Просмотр исходного кода

fix(duty): show duty schedule on portal home launcher

Register /duty frontend route module, add portal top-module order, and fix sys_menu as L1 directory with schedule leaf plus role grants.

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 2 месяцев назад
Родитель
Сommit
4c23ff9f61

+ 26 - 4
backend/scripts/migrate_20260814_duty_schedule.sql

@@ -60,7 +60,28 @@ CREATE TABLE IF NOT EXISTS `duty_assignment` (
   KEY `idx_tenant` (`tenant_no`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='值班占位(指定或抢班)';
 
--- 菜单:挂在 Web 虚拟根(parent_id=2,menu_name=Web端)下「值班排班」
+-- 菜单:一级「值班管理」+ 叶子「值班排班」(门户首页按一级模块出卡片)
+INSERT INTO `sys_menu` (
+  `id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
+  `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
+  `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
+) VALUES (
+  'DUTY000000000000000000000000000',
+  '值班管理',
+  '2',
+  'M',
+  '/duty',
+  '/index/index',
+  NULL,
+  1, '1', '1', 'shanxia2.0', 85,
+  '值班一级模块(门户首页分区)',
+  'system', '', NOW(), NULL, NOW(), 0
+)
+ON DUPLICATE KEY UPDATE
+  `menu_name`=VALUES(`menu_name`),
+  `component`=VALUES(`component`),
+  `path`=VALUES(`path`);
+
 INSERT INTO `sys_menu` (
   `id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
   `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
@@ -68,17 +89,18 @@ INSERT INTO `sys_menu` (
 ) VALUES (
   'DUTY000000000000000000000000001',
   '值班排班',
-  '2',
+  'DUTY000000000000000000000000000',
   'C',
-  'duty-schedule',
+  'schedule',
   '/duty/schedule/index',
   'duty:schedule:list',
-  1, '1', '1', 'shanxia2.0', 90,
+  1, '1', '1', 'shanxia2.0', 1,
   '日历排班与公开抢班链接',
   'system', '', NOW(), NULL, NOW(), 0
 )
 ON DUPLICATE KEY UPDATE
   `menu_name`=VALUES(`menu_name`),
+  `parent_id`=VALUES(`parent_id`),
   `component`=VALUES(`component`),
   `perms`=VALUES(`perms`),
   `path`=VALUES(`path`);

+ 75 - 0
backend/scripts/migrate_20260815_duty_menu_portal_fix.sql

@@ -0,0 +1,75 @@
+-- backend/scripts/migrate_20260815_duty_menu_portal_fix.sql
+-- 修复:值班菜单改为一级目录 /duty + 叶子 schedule,才能出现在门户首页启动器
+
+-- 1) 一级目录「值班管理」
+INSERT INTO `sys_menu` (
+  `id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
+  `is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
+  `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
+) VALUES (
+  'DUTY000000000000000000000000000',
+  '值班管理',
+  '2',
+  'M',
+  '/duty',
+  '/index/index',
+  NULL,
+  1, '1', '1', 'shanxia2.0', 85,
+  '值班一级模块(门户首页分区)',
+  'system', '', NOW(), NULL, NOW(), 0
+)
+ON DUPLICATE KEY UPDATE
+  `menu_name`=VALUES(`menu_name`),
+  `parent_id`=VALUES(`parent_id`),
+  `menu_type`=VALUES(`menu_type`),
+  `path`=VALUES(`path`),
+  `component`=VALUES(`component`),
+  `visible`=VALUES(`visible`),
+  `status`=VALUES(`status`);
+
+-- 2) 叶子「值班排班」挂到值班管理下
+UPDATE `sys_menu`
+SET
+  `parent_id` = 'DUTY000000000000000000000000000',
+  `menu_type` = 'C',
+  `path` = 'schedule',
+  `component` = '/duty/schedule/index',
+  `perms` = 'duty:schedule:list',
+  `visible` = '1',
+  `status` = '1',
+  `order_num` = 1,
+  `update_time` = NOW()
+WHERE `id` = 'DUTY000000000000000000000000001';
+
+-- 3) 给「超级管理员」「管理员」授权(若已有则忽略)
+INSERT INTO `sys_role_menu` (
+  `id`, `role_id`, `menu_id`, `tenant_no`, `order_num`, `remark`,
+  `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
+)
+SELECT
+  REPLACE(UUID(), '-', ''),
+  r.id,
+  m.menu_id,
+  'shanxia2.0',
+  NULL,
+  'duty portal',
+  'system',
+  '',
+  NOW(),
+  NULL,
+  NOW(),
+  0
+FROM `sys_role` r
+JOIN (
+  SELECT 'DUTY000000000000000000000000000' AS menu_id
+  UNION ALL
+  SELECT 'DUTY000000000000000000000000001'
+) m
+WHERE r.del_flag = 0
+  AND r.role_name IN ('超级管理员', '管理员')
+  AND NOT EXISTS (
+    SELECT 1 FROM `sys_role_menu` rm
+    WHERE rm.role_id = r.id
+      AND rm.menu_id = m.menu_id
+      AND IFNULL(rm.del_flag, 0) = 0
+  );

+ 31 - 2
web-admin/src/router/modules/sqxp.ts

@@ -519,7 +519,36 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
   },
 
   // ──────────────────────────────────────────────
-  // 5. 工作流管理
+  // 5. 值班管理
+  // ──────────────────────────────────────────────
+  {
+    id: 'DUTY000000000000000000000000000',
+    name: 'Duty',
+    path: '/duty',
+    component: '/index/index',
+    meta: {
+      title: '值班管理',
+      icon: 'ri:calendar-schedule-line',
+      keepAlive: false,
+      roles: ['admin', 'super_admin']
+    },
+    children: [
+      {
+        id: 'DUTY000000000000000000000000001',
+        name: 'DutySchedule',
+        path: 'schedule',
+        component: '/duty/schedule/index',
+        meta: {
+          title: '值班排班',
+          keepAlive: true,
+          menuCode: 'duty:schedule:list'
+        }
+      }
+    ]
+  },
+
+  // ──────────────────────────────────────────────
+  // 6. 工作流管理
   // ──────────────────────────────────────────────
   {
     id: 'WKF00000000000000000000000000001',
@@ -593,7 +622,7 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
   },
 
   // ──────────────────────────────────────────────
-  // 6. 系统管理
+  // 7. 系统管理
   // ──────────────────────────────────────────────
   {
     id: 'SYSM000000000000000000000000000001',

+ 2 - 0
web-admin/src/utils/router/menu-icon.ts

@@ -55,6 +55,8 @@ export const SIDEBAR_MENU_ICON_MAP: Record<string, string> = {
   WorkflowCompleted: 'ri:checkbox-circle-line',
   WorkflowMyApplications: 'ri:file-user-line',
   LeaveRequest: 'ri:calendar-event-line',
+  Duty: 'ri:calendar-schedule-line',
+  DutySchedule: 'ri:calendar-check-line',
 
   // ── 系统 ──
   SystemManage: 'ri:settings-3-line',

+ 1 - 0
web-admin/src/utils/router/portal-menu.ts

@@ -21,6 +21,7 @@ export const PORTAL_TOP_MODULE_ORDER = [
   '/bx',
   '/db',
   '/pl',
+  '/duty',
   '/workflow',
   '/system'
 ] as const