import type { RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'
import ParentView from '@/components/ParentView/index.vue'
import { ModuleKey } from '@/enums/ModuleEnum'

/**
 * OTR 模块路由（分组：目标 / 绩效 / 任务 / 总结 / 奖励 / 报告 / 通知 / AI）
 *
 * 层级结构：
 *   /otr  (Layout)
 *     ├─ target  (ParentView, 分组：目标管理)
 *     │   ├─ company / depart / mine / template
 *     ├─ effect  (ParentView, 分组：绩效)
 *     │   ├─ manage / mine / board / backlog / template
 *     └─ task / summary / award / report / notice / ai
 *
 * 阶段 2 / 3 业务迁移说明：所有 component 当前都是 stub，按文件逐个替换为真实业务实现。
 */
const otrRoutes: RouteRecordRaw[] = [
    {
        path: '/otr',
        component: Layout,
        redirect: '/otr/target/mine',
        name: 'OtrRoot',
        meta: { module: ModuleKey.OTR, title: 'OTR' },
        children: [
            // ============ 目标管理（迁自 sp-tems-ui / target）============
            {
                path: 'target',
                component: ParentView,
                redirect: '/otr/target/mine',
                alwaysShow: true,
                name: 'OtrTarget',
                meta: { module: ModuleKey.OTR, title: '目标管理', icon: 'guide' },
                children: [
                    {
                        path: 'company',
                        name: 'OtrTargetCompany',
                        component: () => import('@/views/target/company.vue'),
                        meta: { module: ModuleKey.OTR, title: '公司目标' },
                    },
                    {
                        path: 'depart',
                        name: 'OtrTargetDepart',
                        component: () => import('@/views/target/depart.vue'),
                        meta: { module: ModuleKey.OTR, title: '部门目标' },
                    },
                    {
                        path: 'mine',
                        name: 'OtrTargetMine',
                        component: () => import('@/views/target/mine.vue'),
                        meta: { module: ModuleKey.OTR, title: '我的目标' },
                    },
                    {
                        path: 'template',
                        name: 'OtrTargetTemplate',
                        component: () => import('@/views/target/targetTemplate.vue'),
                        meta: { module: ModuleKey.OTR, title: '目标模板' },
                    },
                    {
                        path: 'category',
                        name: 'OtrTargetCategory',
                        component: () => import('@/views/target/templateCategory.vue'),
                        meta: { module: ModuleKey.OTR, title: '模板类目' },
                    },
                    {
                        path: 'report',
                        name: 'OtrTargetReport',
                        component: () => import('@/views/target/report.vue'),
                        meta: { module: ModuleKey.OTR, title: '目标报告' },
                    },
                    {
                        path: 'tree-demo',
                        name: 'OtrTargetTreeDemo',
                        component: () => import('@/views/target/treeDemo.vue'),
                        meta: { module: ModuleKey.OTR, title: '首页目标' },
                    },
                    {
                        path: 'tree',
                        name: 'OtrTargetTree',
                        component: () => import('@/views/target/targetTree.vue'),
                        meta: { module: ModuleKey.OTR, title: '目标看板' },
                    },
                    {
                        path: 'form',
                        name: 'OtrTargetForm',
                        component: () => import('@/views/target/targetForm.vue'),
                        meta: { module: ModuleKey.OTR, title: '目标详情' },
                    },
                    {
                        path: 'detail',
                        name: 'OtrTargetDetail',
                        component: () => import('@/views/target/minedetail.vue'),
                        meta: { module: ModuleKey.OTR, title: '目标详情' },
                    },
                    {
                        path: 'draft',
                        name: 'OtrTargetDraft',
                        component: () => import('@/views/target/draft.vue'),
                        meta: { module: ModuleKey.OTR, title: '目标草稿' },
                    },
                    {
                        path: 'approval',
                        name: 'OtrTargetApproval',
                        component: () => import('@/views/target/approval.vue'),
                        meta: { module: ModuleKey.OTR, title: '目标审批' },
                    },
                ],
            },

            // ============ 绩效（迁自 sp-tems-ui / effect）============
            {
                path: 'effect',
                component: ParentView,
                redirect: '/otr/effect/mine',
                alwaysShow: true,
                name: 'OtrEffect',
                meta: { module: ModuleKey.OTR, title: '绩效管理', icon: 'chart' },
                children: [
                    {
                        path: 'manage',
                        name: 'OtrEffectManage',
                        component: () => import('@/modules/otr/effect/views/Manage.vue'),
                        meta: { module: ModuleKey.OTR, title: '绩效管理' },
                    },
                    {
                        path: 'mine',
                        name: 'OtrEffectMine',
                        component: () => import('@/modules/otr/effect/views/Mine.vue'),
                        meta: { module: ModuleKey.OTR, title: '我的绩效' },
                    },
                    {
                        path: 'board',
                        name: 'OtrEffectBoard',
                        component: () => import('@/modules/otr/effect/views/Board.vue'),
                        meta: { module: ModuleKey.OTR, title: '绩效看板' },
                    },
                    {
                        path: 'backlog',
                        name: 'OtrEffectBacklog',
                        component: () => import('@/modules/otr/effect/views/Backlog.vue'),
                        meta: { module: ModuleKey.OTR, title: '绩效待办' },
                    },
                    {
                        path: 'template',
                        name: 'OtrEffectTemplate',
                        component: () => import('@/modules/otr/effect/views/Template.vue'),
                        meta: { module: ModuleKey.OTR, title: '绩效模板' },
                    },
                    {
                        path: 'setting',
                        name: 'OtrEffectSetting',
                        component: () => import('@/modules/otr/effect/views/Setting.vue'),
                        meta: { module: ModuleKey.OTR, title: '绩效设置' },
                    },
                    {
                        path: 'detail',
                        name: 'OtrEffectDetail',
                        component: () => import('@/modules/otr/effect/views/Detail.vue'),
                        meta: { module: ModuleKey.OTR, title: '绩效详情' },
                    },
                    {
                        path: 'content-form',
                        name: 'OtrEffectContentForm',
                        component: () => import('@/modules/otr/effect/views/ContentForm.vue'),
                        meta: { module: ModuleKey.OTR, title: '新建考核内容' },
                    },
                    {
                        path: 'template-form',
                        name: 'OtrEffectTemplateForm',
                        component: () => import('@/modules/otr/effect/views/TemplateForm.vue'),
                        meta: { module: ModuleKey.OTR, title: '新建考核模板' },
                    },
                    {
                        path: 'index',
                        name: 'OtrEffectIndex',
                        component: () => import('@/modules/otr/effect/views/Index.vue'),
                        meta: { module: ModuleKey.OTR, title: '全部绩效' },
                    },
                    {
                        path: 'dept',
                        name: 'OtrEffectDept',
                        component: () => import('@/modules/otr/effect/views/Dept.vue'),
                        meta: { module: ModuleKey.OTR, title: '部门绩效' },
                    },
                    {
                        path: 'person',
                        name: 'OtrEffectPerson',
                        component: () => import('@/modules/otr/effect/views/Person.vue'),
                        meta: { module: ModuleKey.OTR, title: '个人绩效' },
                    },
                    {
                        path: 'evaluated',
                        name: 'OtrEffectEvaluated',
                        component: () => import('@/modules/otr/effect/views/Evaluated.vue'),
                        meta: { module: ModuleKey.OTR, title: '待评绩效' },
                    },
                    {
                        path: 'review',
                        name: 'OtrEffectReview',
                        component: () => import('@/modules/otr/effect/views/Review.vue'),
                        meta: { module: ModuleKey.OTR, title: '待审绩效' },
                    },
                    {
                        path: 'objection',
                        name: 'OtrEffectObjection',
                        component: () => import('@/modules/otr/effect/views/Objection.vue'),
                        meta: { module: ModuleKey.OTR, title: '异议管理' },
                    },
                    {
                        path: 'whitelist',
                        name: 'OtrEffectWhitelist',
                        component: () => import('@/modules/otr/effect/views/Whitelist.vue'),
                        meta: { module: ModuleKey.OTR, title: '白名单' },
                    },
                ],
            },

            // ============ 任务管理（迁自 sp-tems-ui / task）============
            {
                path: 'task',
                component: ParentView,
                redirect: '/otr/task/list',
                alwaysShow: true,
                name: 'OtrTask',
                meta: { module: ModuleKey.OTR, title: '任务管理', icon: 'edit' },
                children: [
                    {
                        path: 'list',
                        name: 'OtrTaskList',
                        component: () => import('@/modules/otr/task/views/List.vue'),
                        meta: { module: ModuleKey.OTR, title: '我的任务' },
                    },
                    {
                        path: 'member',
                        name: 'OtrTaskMember',
                        component: () => import('@/modules/otr/task/views/Member.vue'),
                        meta: { module: ModuleKey.OTR, title: '成员任务' },
                    },
                    {
                        path: 'table',
                        name: 'OtrTaskTable',
                        component: () => import('@/modules/otr/task/views/Table.vue'),
                        meta: { module: ModuleKey.OTR, title: '任务看板' },
                    },
                    {
                        path: 'detail',
                        name: 'OtrTaskDetail',
                        component: () => import('@/modules/otr/task/views/Detail.vue'),
                        meta: { module: ModuleKey.OTR, title: '任务详情' },
                    },
                    {
                        path: 'form',
                        name: 'OtrTaskForm',
                        component: () => import('@/modules/otr/task/views/Form.vue'),
                        meta: { module: ModuleKey.OTR, title: '新建任务' },
                    },
                    {
                        path: 'at-list',
                        name: 'OtrTaskAtList',
                        component: () => import('@/modules/otr/task/views/AtList.vue'),
                        meta: { module: ModuleKey.OTR, title: '@我的任务' },
                    },
                ],
            },

            // ============ 工作总结（迁自 sp-tems-ui / summary）============
            {
                path: 'summary/list',
                name: 'OtrSummaryList',
                component: () => import('@/modules/otr/summary/views/List.vue'),
                meta: { module: ModuleKey.OTR, title: '工作总结', icon: 'documentation' },
            },
            {
                path: 'summary/member',
                name: 'OtrSummaryMember',
                component: () => import('@/modules/otr/summary/views/Member.vue'),
                meta: { module: ModuleKey.OTR, title: '成员简报' },
            },
            {
                path: 'summary/statistics',
                name: 'OtrSummaryStatistics',
                component: () => import('@/modules/otr/summary/views/Statistics.vue'),
                meta: { module: ModuleKey.OTR, title: '简报统计' },
            },
            {
                path: 'summary/create',
                name: 'OtrSummaryCreate',
                component: () => import('@/modules/otr/summary/views/Create.vue'),
                meta: { module: ModuleKey.OTR, title: '新建简报' },
            },
            {
                path: 'summary/form',
                name: 'OtrSummaryForm',
                component: () => import('@/modules/otr/summary/views/Form.vue'),
                meta: { module: ModuleKey.OTR, title: '简报表单' },
            },
            {
                path: 'summary/draft',
                name: 'OtrSummaryDraft',
                component: () => import('@/modules/otr/summary/views/Draft.vue'),
                meta: { module: ModuleKey.OTR, title: '草稿箱' },
            },
            {
                path: 'summary/share',
                name: 'OtrSummaryShare',
                component: () => import('@/modules/otr/summary/views/Share.vue'),
                meta: { module: ModuleKey.OTR, title: '心得分享' },
            },
            {
                path: 'summary/share-detail',
                name: 'OtrSummaryShareDetail',
                component: () => import('@/modules/otr/summary/views/ShareDetail.vue'),
                meta: { module: ModuleKey.OTR, title: '心得详情' },
            },
            {
                path: 'summary/settings',
                name: 'OtrSummarySettings',
                component: () => import('@/modules/otr/summary/views/Settings.vue'),
                meta: { module: ModuleKey.OTR, title: '简报设置' },
            },
            {
                path: 'summary/remind-task',
                name: 'OtrSummaryRemindTask',
                component: () => import('@/modules/otr/summary/views/RemindTask.vue'),
                meta: { module: ModuleKey.OTR, title: '简报提醒' },
            },
            {
                path: 'summary/announcement',
                name: 'OtrSummaryAnnouncement',
                component: () => import('@/modules/otr/summary/views/Announcement.vue'),
                meta: { module: ModuleKey.OTR, title: '公告列表' },
            },

            // ============ 奖励（迁自 sp-tems-ui / award）============
            {
                path: 'award/list',
                name: 'OtrAwardList',
                component: () => import('@/modules/otr/award/views/List.vue'),
                meta: { module: ModuleKey.OTR, title: '奖励管理', icon: 'star' },
            },
            {
                path: 'award/pool',
                name: 'OtrAwardPool',
                component: () => import('@/modules/otr/award/views/Pool.vue'),
                meta: { module: ModuleKey.OTR, title: '奖金池管理' },
            },
            {
                path: 'award/trends',
                name: 'OtrAwardTrends',
                component: () => import('@/modules/otr/award/views/Trends.vue'),
                meta: { module: ModuleKey.OTR, title: '奖励动态' },
            },

            // ============ 人员报告（迁自 sp-tems-ui / person-report）============
            {
                path: 'report/person',
                name: 'OtrReportPerson',
                component: () => import('@/modules/otr/report/views/PersonReport.vue'),
                meta: { module: ModuleKey.OTR, title: '人员报告', icon: 'chart' },
            },

            // ============ 通知（迁自 sp-tems-ui / notice）============
            {
                path: 'notice/list',
                name: 'OtrNoticeList',
                component: () => import('@/modules/otr/notice/views/List.vue'),
                meta: { module: ModuleKey.OTR, title: '系统通知', icon: 'message' },
            },

            // ============ AI 工具（迁自 sp-tems-ui / addAi）============
            {
                path: 'ai/add',
                name: 'OtrAiAdd',
                component: () => import('@/modules/otr/ai/views/AddAi.vue'),
                meta: { module: ModuleKey.OTR, title: 'AI 工具', icon: 'magic-stick' },
            },
        ],
    },
]

export default otrRoutes
