-- =============================================================
-- 线上 klp-oa 库修复脚本
-- 1. 删除乱码父菜单
-- 2. 补充缺失字典
-- =============================================================
SET NAMES utf8mb4;

-- ========== 1. 清理乱码父菜单 ==========
DELETE FROM sys_role_menu WHERE menu_id = 2100000000000000035;
DELETE FROM sys_menu WHERE menu_id = 2100000000000000035;

-- ========== 2. 补充缺失字典类型 ==========
INSERT IGNORE INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark)
VALUES ('改判后质量状态', 'regrade_quality_type', '0', 'admin', NOW(), 'admin', NOW(), '');

-- ========== 3. 补充缺失字典数据 ==========
-- quality_review_status 缺的3条
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (2, '待审批', '2', 'quality_review_status', '', 'warning', 'Y', '0', 'admin', NOW());
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (3, '已通过', '3', 'quality_review_status', '', 'success', 'Y', '0', 'admin', NOW());
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (4, '已驳回', '4', 'quality_review_status', '', 'danger', 'Y', '0', 'admin', NOW());

-- regrade_quality_type 全部5条
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (1, '协议销售', 'protocol_sale', 'regrade_quality_type', '', '', 'Y', '0', 'admin', NOW());
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (2, '转分剪', 'to_slitting', 'regrade_quality_type', '', '', 'Y', '0', 'admin', NOW());
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (3, '降级', 'downgrade', 'regrade_quality_type', '', '', 'Y', '0', 'admin', NOW());
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (4, '返修', 'rework', 'regrade_quality_type', '', '', 'Y', '0', 'admin', NOW());
INSERT IGNORE INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time)
VALUES (5, '报废', 'scrap', 'regrade_quality_type', '', '', 'Y', '0', 'admin', NOW());

-- ========== 4. 验证 ==========
SELECT 'OK' as result FROM sys_dict_type WHERE dict_type = 'regrade_quality_type' LIMIT 1;
