import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@/layout/index.vue'),
    redirect: '/enterprise/companyInfo',
    children: [
      // 企业账户模块
      {
        path: '/enterprise',
        name: 'Enterprise',
        redirect: '/enterprise/companyInfo',
        meta: { title: '企业账户', icon: 'User' },
        children: [
          {
            path: 'companyInfo',
            name: 'CompanyInfo',
            component: () => import('@/views/enterprise/companyInfo/index.vue'),
            meta: { title: '企业信息' }
          },
          {
            path: 'companyInfo/edit',
            name: 'CompanyInfoEdit',
            component: () => import('@/views/enterprise/companyInfo/edit.vue'),
            meta: { title: '完善企业信息', hidden: true }
          },
          {
            path: 'securitySetting',
            name: 'SecuritySetting',
            component: () => import('@/views/enterprise/securitySetting/index.vue'),
            meta: { title: '安全设置', hidden: true }
          },
          {
            path: 'purchaseHabit',
            name: 'PurchaseHabit',
            component: () => import('@/views/enterprise/purchaseHabit/index.vue'),
            meta: { title: '采购习惯', hidden: true }
          },
          {
            path: 'messageNotice',
            name: 'MessageNotice',
            component: () => import('@/views/enterprise/messageNotice/index.vue'),
            meta: { title: '消息通知' }
          },
          {
            path: 'addressManage',
            name: 'AddressManage',
            component: () => import('@/views/enterprise/addressManage/index.vue'),
            meta: { title: '地址管理' }
          },
          {
            path: 'invoiceManage',
            name: 'InvoiceManage',
            component: () => import('@/views/enterprise/invoiceManage/index.vue'),
            meta: { title: '发票抬头管理' }
          },
          {
            path: 'purchasePlan',
            name: 'PurchasePlan',
            component: () => import('@/views/enterprise/purchasePlan/index.vue'),
            meta: { title: '专属采购方案' }
          },
          {
            path: 'agreementSupply',
            name: 'AgreementSupply',
            component: () => import('@/views/enterprise/agreementSupply/index.vue'),
            meta: { title: '协议供货' }
          },
          {
            path: 'myCollection',
            name: 'MyCollection',
            component: () => import('@/views/enterprise/myCollection/index.vue'),
            meta: { title: '我的收藏' }
          },
          {
            path: 'purchaseHistory',
            name: 'PurchaseHistory',
            component: () => import('@/views/enterprise/purchaseHistory/index.vue'),
            meta: { title: '历史购买' }
          },
          {
            path: 'myFootprint',
            name: 'MyFootprint',
            component: () => import('@/views/enterprise/myFootprint/index.vue'),
            meta: { title: '我的足迹' }
          }
        ]
      },
      // 交易管理模块
      {
        path: '/trade',
        name: 'Trade',
        redirect: '/trade/orderManage',
        meta: { title: '交易管理', icon: 'ShoppingCart' },
        children: [
          {
            path: 'orderManage',
            name: 'OrderManage',
            component: () => import('@/views/trade/orderManage/index.vue'),
            meta: { title: '订单管理' }
          },
          {
            path: 'orderManage/detail/:orderNo',
            name: 'OrderDetail',
            component: () => import('@/views/trade/orderManage/detail.vue'),
            meta: { title: '订单详情', hidden: true }
          },
          {
            path: 'orderAudit',
            name: 'OrderAudit',
            component: () => import('@/views/trade/orderAudit/index.vue'),
            meta: { title: '审核订单' }
          },
          {
            path: 'afterSale',
            name: 'AfterSale',
            component: () => import('@/views/trade/afterSale/index.vue'),
            meta: { title: '售后服务' }
          },
          {
            path: 'batchOrder',
            name: 'BatchOrder',
            component: () => import('@/views/trade/batchOrder/index.vue'),
            meta: { title: '批量下单' }
          },
          {
            path: 'orderEvaluation',
            name: 'OrderEvaluation',
            component: () => import('@/views/trade/orderEvaluation/index.vue'),
            meta: { title: '订单评价' }
          }
        ]
      },
      // 组织管理模块
      {
        path: '/organization',
        name: 'Organization',
        redirect: '/organization/personalInfo',
        meta: { title: '组织管理', icon: 'OfficeBuilding' },
        children: [
          {
            path: 'personalInfo',
            name: 'PersonalInfo',
            component: () => import('@/views/organization/personalInfo/index.vue'),
            meta: { title: '个人信息' }
          },
          {
            path: 'deptManage',
            name: 'DeptManage',
            component: () => import('@/views/organization/deptManage/index.vue'),
            meta: { title: '部门管理' }
          },
          {
            path: 'staffManage',
            name: 'StaffManage',
            component: () => import('@/views/organization/staffManage/index.vue'),
            meta: { title: '人员管理' }
          },
          {
            path: 'roleManage',
            name: 'RoleManage',
            component: () => import('@/views/organization/roleManage/index.vue'),
            meta: { title: '角色管理' }
          },
          {
            path: 'approvalFlow',
            name: 'ApprovalFlow',
            component: () => import('@/views/organization/approvalFlow/index.vue'),
            meta: { title: '审批流程' }
          },
          {
            path: 'approvalFlow/create',
            name: 'ApprovalFlowCreate',
            component: () => import('@/views/organization/approvalFlow/create.vue'),
            meta: { title: '新建审批', hidden: true }
          },
          {
            path: 'groupEnterprise',
            name: 'GroupEnterprise',
            component: () => import('@/views/organization/groupEnterprise/index.vue'),
            meta: { title: '集团关联企业' }
          }
        ]
      },
      // 成本管理模块
      {
        path: '/cost',
        name: 'Cost',
        redirect: '/cost/itemExpense',
        meta: { title: '成本管理', icon: 'Money' },
        children: [
          {
            path: 'itemExpense',
            name: 'ItemExpense',
            component: () => import('@/views/cost/itemExpense/index.vue'),
            meta: { title: '分项费用' }
          },
          {
            path: 'quotaControl',
            name: 'QuotaControl',
            component: () => import('@/views/cost/quotaControl/index.vue'),
            meta: { title: '额度控制' }
          },
          {
            path: 'quotaControl/apply',
            name: 'QuotaApply',
            component: () => import('@/views/cost/quotaControl/apply.vue'),
            meta: { title: '额度申请', hidden: true }
          }
        ]
      },
      // 对账管理模块
      {
        path: '/reconciliation',
        name: 'Reconciliation',
        redirect: '/reconciliation/billManage',
        meta: { title: '对账管理', icon: 'Document' },
        children: [
          {
            path: 'billManage',
            name: 'BillManage',
            component: () => import('@/views/reconciliation/billManage/index.vue'),
            meta: { title: '对账单管理' }
          },
          {
            path: 'invoiceManage',
            name: 'ReconciliationInvoiceManage',
            component: () => import('@/views/reconciliation/invoiceManage/index.vue'),
            meta: { title: '开票管理' }
          }
        ]
      },
      // 增值服务模块
      {
        path: '/valueAdded',
        name: 'ValueAdded',
        redirect: '/valueAdded/maintenance',
        meta: { title: '增值服务', icon: 'Service' },
        children: [
          {
            path: 'maintenance',
            name: 'Maintenance',
            component: () => import('@/views/valueAdded/maintenance/index.vue'),
            meta: { title: '维保服务' }
          },
          {
            path: 'complaint',
            name: 'Complaint',
            component: () => import('@/views/valueAdded/complaint/index.vue'),
            meta: { title: '投诉与建议' }
          }
        ]
      },
      // 采购分析模块
      {
        path: '/analysis',
        name: 'Analysis',
        redirect: '/analysis/orderAnalysis',
        meta: { title: '采购分析', icon: 'DataAnalysis' },
        children: [
          {
            path: 'orderAnalysis',
            name: 'OrderAnalysis',
            component: () => import('@/views/analysis/orderAnalysis/index.vue'),
            meta: { title: '订单交易分析' }
          },
          {
            path: 'purchaseDetail',
            name: 'PurchaseDetail',
            component: () => import('@/views/analysis/purchaseDetail/index.vue'),
            meta: { title: '商品采购明细' }
          },
          {
            path: 'orderStatus',
            name: 'OrderStatus',
            component: () => import('@/views/analysis/orderStatus/index.vue'),
            meta: { title: '订单执行状态' }
          },
          {
            path: 'settlementStatus',
            name: 'SettlementStatus',
            component: () => import('@/views/analysis/settlementStatus/index.vue'),
            meta: { title: '对账结算状况' }
          },
          {
            path: 'deptPurchase',
            name: 'DeptPurchase',
            component: () => import('@/views/analysis/deptPurchase/index.vue'),
            meta: { title: '部门采购金额' }
          }
        ]
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
