import { Routes } from '@angular/router';

// 登录页
import { LoginPage } from './pages/auth/login/login';

// 客服页面
import { CustomerServiceLayout } from './pages/customer-service/customer-service-layout/customer-service-layout';
import { Dashboard as CustomerServiceDashboard } from './pages/customer-service/dashboard/dashboard';
import { ConsultationOrder } from './pages/customer-service/consultation-order/consultation-order';
import { ProjectList } from './pages/customer-service/project-list/project-list';
import { ProjectDetail } from './pages/customer-service/project-detail/project-detail';
import { CaseLibrary } from './pages/customer-service/case-library/case-library';

// 客服工作台子页面
import { ConsultationListComponent } from './pages/customer-service/dashboard/pages/consultation-list/consultation-list.component';
import { AssignmentListComponent } from './pages/customer-service/dashboard/pages/assignment-list/assignment-list.component';
import { ExceptionListComponent } from './pages/customer-service/dashboard/pages/exception-list/exception-list.component';


// 设计师页面
import { Dashboard as DesignerDashboard } from './pages/designer/dashboard/dashboard';
import { ProjectDetail as DesignerProjectDetail } from './pages/designer/project-detail/project-detail';
import { PersonalBoard } from './pages/designer/personal-board/personal-board';

// 组长页面
import { Dashboard as TeamLeaderDashboard } from './pages/team-leader/dashboard/dashboard';
import { TeamManagementComponent } from './pages/team-leader/team-management/team-management';
import { QualityManagementComponent } from './pages/team-leader/quality-management/quality-management';
import { KnowledgeBaseComponent } from './pages/team-leader/knowledge-base/knowledge-base';
import { WorkloadCalendarComponent } from './pages/team-leader/workload-calendar/workload-calendar';

// 财务页面
import { Dashboard as FinanceDashboard } from './pages/finance/dashboard/dashboard';
import { ProjectRecords } from './pages/finance/project-records/project-records';
import { Reconciliation } from './pages/finance/reconciliation/reconciliation';
import { Reports } from './pages/finance/reports/reports';

// 人事/行政页面
import { HrLayout } from './pages/hr/hr-layout/hr-layout';
import { Dashboard as HrDashboard } from './pages/hr/dashboard/dashboard';
import { EmployeeRecords } from './pages/hr/employee-records/employee-records';
import { Attendance } from './pages/hr/attendance/attendance';

// 管理员页面
import { AdminLayout } from './pages/admin/admin-layout/admin-layout';
import { AdminDashboard } from './pages/admin/dashboard/dashboard';
import { SystemManagement } from './pages/admin/system-management/system-management';
import { ProjectManagement } from './pages/admin/project-management/project-management';
import { UserManagement } from './pages/admin/user-management/user-management';
import { SystemSettings } from './pages/admin/system-settings/system-settings';
import { Logs } from './pages/admin/logs/logs';
import { ApiIntegrations } from './pages/admin/api-integrations/api-integrations';
// 新增：管理员子模块页面
import { Designers } from './pages/admin/designers/designers';
import { Customers } from './pages/admin/customers/customers';
import { FinancePage } from './pages/admin/finance/finance';

export const routes: Routes = [
  // 客服路由
  {
    path: 'customer-service',
    component: CustomerServiceLayout,
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: CustomerServiceDashboard, title: '客服工作台' },
      { path: 'consultation-order', component: ConsultationOrder, title: '客户咨询与下单' },
      { path: 'project-list', component: ProjectList, title: '项目列表' },
      { path: 'project-detail/:id', component: DesignerProjectDetail, title: '项目详情' },
      { path: 'case-library', component: CaseLibrary, title: '案例库' },

      // 工作台子页面路由
      { path: 'consultation-list', component: ConsultationListComponent, title: '咨询列表' },
      { path: 'assignment-list', component: AssignmentListComponent, title: '待派单列表' },
      { path: 'exception-list', component: ExceptionListComponent, title: '异常项目列表' },
    
    ]
  },

  // 设计师路由
  {
    path: 'designer',
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: DesignerDashboard, title: '设计师工作台' },
      { path: 'project-detail/:id', component: DesignerProjectDetail, title: '项目详情' },
      { path: 'personal-board', component: PersonalBoard, title: '个人看板' }
    ]
  },

  // 组长路由
  {
    path: 'team-leader',
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: TeamLeaderDashboard, title: '组长工作台' },
      { path: 'team-management', component: TeamManagementComponent, title: '团队管理' },
      { path: 'quality-management', component: QualityManagementComponent, title: '质量管理' },
      { path: 'knowledge-base', component: KnowledgeBaseComponent, title: '知识库与能力复制' },
      { path: 'workload-calendar', component: WorkloadCalendarComponent, title: '负载日历' },
      // 新增：复用设计师项目详情作为组长查看页面（含审核/同步能力）
      { path: 'project-detail/:id', component: DesignerProjectDetail, title: '项目详情' }
    ]
  },

  // 财务路由
  {
    path: 'finance',
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: FinanceDashboard, title: '财务工作台' },
      { path: 'project-records', component: ProjectRecords, title: '项目流水' },
      { path: 'reconciliation', component: Reconciliation, title: '对账与结算' },
      { path: 'reports', component: Reports, title: '财务报表' }
    ]
  },

  // 人事/行政路由
  {
    path: 'hr',
    component: HrLayout,
    children: [
      { path: 'dashboard', component: HrDashboard, title: '人事看板' },
      { path: 'employee-records', component: EmployeeRecords, title: '员工档案' },
      { path: 'attendance', component: Attendance, title: '考勤管理' },
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' }
    ]
  },

  // 管理员路由
  {
    path: 'admin',
    component: AdminLayout,
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: AdminDashboard, title: '总览看板' },
      
      // 项目管理相关路由
      { path: 'project-management', component: ProjectManagement, title: '项目管理' },
      
      // 用户与角色管理相关路由
      { path: 'user-management', component: UserManagement, title: '用户与角色管理' },
      
      // 新增：设计师、客户、财务管理
      { path: 'designers', component: Designers, title: '设计师管理' },
      { path: 'customers', component: Customers, title: '客户管理' },
      { path: 'finance', component: FinancePage, title: '财务管理' },
      
      // 系统设置相关路由
      { path: 'system-settings', component: SystemSettings, title: '系统设置' },
      
      // 系统日志相关路由
      { path: 'logs', component: Logs, title: '系统日志' },
      
      // API集成管理相关路由
      { path: 'api-integrations', component: ApiIntegrations, title: 'API集成管理' }
    ]
  },

  // 默认路由重定向到登录页
  { path: '', component: LoginPage, pathMatch: 'full' },
  { path: '**', redirectTo: '/customer-service/dashboard' }
];