-- 将「设备补货单」模块添加到「库存管理」下
-- 使用大 ID (91000+) 避免与种子数据冲突

-- 1. 清理旧数据
DELETE FROM t_role_menu WHERE role_id = 1 AND menu_id IN (505, 506, 507);
DELETE FROM t_menu WHERE id IN (505, 506, 507);
DELETE FROM t_role_menu WHERE id IN (91001, 91002, 91003);

-- 2. 写入菜单
INSERT INTO t_menu (id, parent_id, menu_type, title, name, path, component, `rank`, icon, show_link, show_parent, `redirect`, keep_alive)
VALUES (505, 500, 0, '设备补货单', 'ReplenishmentOrder', '/inventory/replenishment-order', '', 4, '', 1, 0, '/inventory/replenishment-order/list', 1)
ON DUPLICATE KEY UPDATE icon = '';

INSERT INTO t_menu (id, parent_id, menu_type, title, name, path, component, `rank`, show_link, show_parent)
VALUES
(506, 505, 0, '补货单列表', 'ReplenishmentOrderList', '/inventory/replenishment-order/list', 'replenishment-order/index', 1, 1, 0),
(507, 505, 0, '补货单详情', 'ReplenishmentOrderDetail', '/inventory/replenishment-order/detail', 'replenishment-order/detail', 2, 0, 0);

-- 3. 写入角色菜单关联
INSERT INTO t_role_menu (id, role_id, menu_id, create_time)
VALUES
(91001, 1, 505, NOW()),
(91002, 1, 506, NOW()),
(91003, 1, 507, NOW());

-- 4. 如果菜单已存在，单独修正 icon 为空
UPDATE t_menu SET icon = '' WHERE id = 505;
