SET NAMES utf8mb4;

-- 1. 订单履约 → 供应商履约
UPDATE sys_menu SET menu_name = '供应商履约' WHERE menu_id = 2023;

-- 2. 新建甲方履约根菜单 (2040)
INSERT IGNORE INTO sys_menu(menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES(2040, '甲方履约', 0, 23, 'client-delivery', NULL, 1, 0, 'M', '0', '0', 'bid:clientdelivery:list', 's-order', 'admin', NOW());

-- 3. 子菜单
INSERT IGNORE INTO sys_menu(menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES(2041, '甲方待发', 2040, 1, 'pending', 'bid/clientDelivery/pending', 1, 0, 'C', '0', '0', 'bid:clientdelivery:pending', 'time', 'admin', NOW());

INSERT IGNORE INTO sys_menu(menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES(2042, '甲方在途', 2040, 2, 'transit', 'bid/clientDelivery/transit', 1, 0, 'C', '0', '0', 'bid:clientdelivery:transit', 'truck', 'admin', NOW());

INSERT IGNORE INTO sys_menu(menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES(2043, '甲方签收', 2040, 3, 'signed', 'bid/clientDelivery/signed', 1, 0, 'C', '0', '0', 'bid:clientdelivery:signed', 'finished', 'admin', NOW());

-- 4. 按钮权限
INSERT IGNORE INTO sys_menu(menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES(2050, '发货确认', 2041, 1, '#', NULL, 1, 0, 'F', '0', '0', 'bid:clientdelivery:ship', '#', 'admin', NOW());
INSERT IGNORE INTO sys_menu(menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
VALUES(2051, '签收确认', 2043, 1, '#', NULL, 1, 0, 'F', '0', '0', 'bid:clientdelivery:sign', '#', 'admin', NOW());

-- 5. admin 角色授权
INSERT IGNORE INTO sys_role_menu (role_id, menu_id)
SELECT 1, menu_id FROM sys_menu WHERE menu_id IN (2040, 2041, 2042, 2043, 2050, 2051);

SELECT menu_id, menu_name, parent_id FROM sys_menu WHERE menu_id IN (2023, 2040, 2041, 2042, 2043) ORDER BY menu_id;
