-- 年度汇总表菜单配置脚本 (增强版：包含字段补全与管理员授权)

SET @AdminRoleId = '94e3a9bb0fce4547886972998fddba1c'; -- 系统管理员角色ID

-- 1. 清理旧数据 (防止重复执行报错)
DELETE FROM BASE_MODULE WHERE F_Id IN ('annual-summary-catalog', 'annual-summary-data', 'annual-summary-dashboard');
DELETE FROM BASE_AUTHORIZE WHERE F_ItemId IN ('annual-summary-catalog', 'annual-summary-data', 'annual-summary-dashboard');

-- 2. 创建目录: 年度经营数据 (父级: 报表中心 725873504657868037)
INSERT INTO BASE_MODULE (F_Id, F_ParentId, F_Type, F_FullName, F_EnCode, F_UrlAddress, F_Icon, F_SortCode, F_EnabledMark, F_Category, F_DeleteMark, F_LinkTarget, F_PropertyJson, F_IsButtonAuthorize, F_IsColumnAuthorize, F_IsDataAuthorize, F_IsFormAuthorize, F_CreatorTime)
VALUES 
('annual-summary-catalog', '725873504657868037', 1, '年度经营数据', 'annualSummary', '', 'icon-ym icon-ym-report', 10, 1, 'Web', NULL, '_self', '{"moduleId":"","iconBackgroundColor":"","isTree":0}', 0, 0, 0, 0, NOW());

-- 3. 创建菜单: 汇总数据列表 (父级: 年度经营数据)
INSERT INTO BASE_MODULE (F_Id, F_ParentId, F_Type, F_FullName, F_EnCode, F_UrlAddress, F_Icon, F_SortCode, F_EnabledMark, F_Category, F_DeleteMark, F_LinkTarget, F_PropertyJson, F_IsButtonAuthorize, F_IsColumnAuthorize, F_IsDataAuthorize, F_IsFormAuthorize, F_CreatorTime)
VALUES 
('annual-summary-data', 'annual-summary-catalog', 2, '汇总数据列表', 'annualSummaryData', 'extend/annualSummary/dataManage', 'icon-ym icon-ym-extended', 1, 1, 'Web', NULL, '_self', '{"moduleId":"","iconBackgroundColor":"","isTree":0}', 1, 1, 1, 1, NOW());

-- 4. 创建菜单: 经营统计分析 (父级: 年度经营数据)
INSERT INTO BASE_MODULE (F_Id, F_ParentId, F_Type, F_FullName, F_EnCode, F_UrlAddress, F_Icon, F_SortCode, F_EnabledMark, F_Category, F_DeleteMark, F_LinkTarget, F_PropertyJson, F_IsButtonAuthorize, F_IsColumnAuthorize, F_IsDataAuthorize, F_IsFormAuthorize, F_CreatorTime)
VALUES 
('annual-summary-dashboard', 'annual-summary-catalog', 2, '经营统计分析', 'annualSummaryDashboard', 'extend/annualSummary/dashboard', 'icon-ym icon-ym-report-columnar', 2, 1, 'Web', NULL, '_self', '{"moduleId":"","iconBackgroundColor":"","isTree":0}', 1, 1, 1, 1, NOW());

-- 5. 授权给 系统管理员 角色
INSERT INTO BASE_AUTHORIZE (F_Id, F_ItemType, F_ItemId, F_ObjectType, F_ObjectId, F_SortCode, F_CreatorTime, F_CreatorUserId)
VALUES 
(REPLACE(UUID(), '-', ''), 'module', 'annual-summary-catalog', 'Role', @AdminRoleId, 1, NOW(), 'admin'),
(REPLACE(UUID(), '-', ''), 'module', 'annual-summary-data', 'Role', @AdminRoleId, 2, NOW(), 'admin'),
(REPLACE(UUID(), '-', ''), 'module', 'annual-summary-dashboard', 'Role', @AdminRoleId, 3, NOW(), 'admin');

