-- 销售端 CRM：加微进度菜单（租户库 tenant_sys_menu）
-- 父级：CRM客户管理 menu_id=35020（若不存在请按实际 parent_id 调整）

INSERT INTO sys_menu (
    menu_name, parent_id, order_num, path, component,
    menu_type, visible, status, perms, icon, is_frame, is_cache,
    create_by, create_time
)
SELECT
    '加微进度', 35020, 16, 'addWx', 'crm/addWx/index',
    'C', '0', '0', 'company:companyClient:list', 'el-icon-connection', 1, 0,
    'admin', NOW()
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1 FROM sys_menu WHERE parent_id = 35020 AND path = 'addWx'
);

SET @m_crm_add_wx = (
    SELECT menu_id FROM sys_menu WHERE parent_id = 35020 AND path = 'addWx' LIMIT 1
);

INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, menu_type, visible, status, perms, icon, is_frame, is_cache, create_by, create_time)
SELECT '加微进度导出', @m_crm_add_wx, 1, '', '', 'F', '0', '0', 'company:companyClient:export', '#', 1, 0, 'admin', NOW()
FROM DUAL
WHERE @m_crm_add_wx IS NOT NULL
  AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE parent_id = @m_crm_add_wx AND perms = 'company:companyClient:export');
