-- 业绩看板四个 Tab 独立按钮权限（fans/yeji · pid=293）
-- Tab 权限用于单独控制 Tab 可见性；前端同时兼容下方已有接口按钮权限，旧角色无需改配即可继续使用。
-- 若仅勾选 Tab 权限、未勾选对应接口，Tab 可见但请求会 403：
--   tabDoctor        → stats.doctorDailyStats/overview
--   tabLeaderboard   → stats.yejiStats/leaderboard
--   tabZyyt          → stats.yejiStats/multi、stats.yejiStats/overview
--   tabTargetMatrix  → stats.yejiStats/multi
-- 幂等：按 perms 判重

INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩看板-医生统计', '', 8,
    'stats.yejiStats/tabDoctor', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM DUAL
WHERE EXISTS (SELECT 1 FROM `zyt_system_menu` p WHERE p.id = 293)
  AND NOT EXISTS (SELECT 1 FROM `zyt_system_menu` m WHERE m.perms = 'stats.yejiStats/tabDoctor');

INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩看板-医助排行榜', '', 9,
    'stats.yejiStats/tabLeaderboard', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM DUAL
WHERE EXISTS (SELECT 1 FROM `zyt_system_menu` p WHERE p.id = 293)
  AND NOT EXISTS (SELECT 1 FROM `zyt_system_menu` m WHERE m.perms = 'stats.yejiStats/tabLeaderboard');

INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩看板-甄养堂诊金', '', 10,
    'stats.yejiStats/tabZyyt', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM DUAL
WHERE EXISTS (SELECT 1 FROM `zyt_system_menu` p WHERE p.id = 293)
  AND NOT EXISTS (SELECT 1 FROM `zyt_system_menu` m WHERE m.perms = 'stats.yejiStats/tabZyyt');

INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩看板-目标看板卡片', '', 11,
    'stats.yejiStats/tabTargetMatrix', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM DUAL
WHERE EXISTS (SELECT 1 FROM `zyt_system_menu` p WHERE p.id = 293)
  AND NOT EXISTS (SELECT 1 FROM `zyt_system_menu` m WHERE m.perms = 'stats.yejiStats/tabTargetMatrix');
