-- 财务管理：制定业绩（按月维护各部门目标）幂等

INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    166, 'C', '制定业绩', 'el-icon-Flag', 25,
    'finance.dept_performance_target/monthMatrix', 'mubiao', 'finance/mubiao', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM dual
WHERE NOT EXISTS (
    SELECT 1 FROM `zyt_system_menu` m WHERE m.paths = 'mubiao' OR m.perms = 'finance.dept_performance_target/monthMatrix'
);

INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    m.id, 'A', '保存业绩目标', '', 1,
    'finance.dept_performance_target/batchSave', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM `zyt_system_menu` m
WHERE m.paths = 'mubiao' AND m.type = 'C'
  AND NOT EXISTS (
    SELECT 1 FROM `zyt_system_menu` x WHERE x.perms = 'finance.dept_performance_target/batchSave'
)
LIMIT 1;
