-- 检查工单管理菜单配置
-- 诊断路由跳转问题的根本原因

-- 1. 查看工单管理的完整菜单树
SELECT 
    menu_id,
    menu_name,
    parent_id,
    order_num,
    path,
    component,
    query,
    menu_type,
    visible,
    status
FROM sys_menu
WHERE menu_id = 2098  -- 工单管理父菜单
   OR parent_id = 2098  -- 工单管理的子菜单
   OR menu_id = 2092  -- 测试工单菜单
   OR parent_id = 2092  -- 测试工单的子菜单
ORDER BY parent_id, order_num;

-- 2. 查找所有包含 testOrder 或 testWorkOrder 的错误路径
SELECT 
    menu_id,
    menu_name,
    parent_id,
    path,
    component,
    query,
    menu_type
FROM sys_menu
WHERE path LIKE '%testOrder%' 
   OR path LIKE '%testWorkOrder%'
   OR component LIKE '%test_order%';

-- 3. 查找所有状态相关的子菜单（这些可能是错误的）
SELECT 
    menu_id,
    menu_name,
    parent_id,
    path,
    component,
    query,
    menu_type
FROM sys_menu
WHERE parent_id IN (2098, 2092)
  AND menu_name IN ('进行中', '已完成', '待领取', '一审中', '二审中', '三审中', '全部工单', '测试中');

-- 4. 检查是否有重复的菜单配置
SELECT 
    menu_name,
    COUNT(*) as count,
    GROUP_CONCAT(menu_id) as menu_ids,
    GROUP_CONCAT(path) as paths
FROM sys_menu
WHERE parent_id IN (2098, 2092)
GROUP BY menu_name
HAVING COUNT(*) > 1;
