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

import LayoutView from '../views/layout/index.vue'
import backLayout from '../views/layout/back-layout.vue'
import LoginView from '../views/login/index.vue'
import MenuView from '../views/menu/index.vue'
import OrderView from '../views/order/index.vue'
import orderDetail from '../views/order/orderDetail.vue'
import ExitView from '../views/exit/index.vue'
import GoodsView from '../views/goods/index.vue'

export const routes: RouteRecordRaw[] = [
  { path: '/login', component: LoginView },
  {
    path: '/',
    redirect: '/font',
  },
  {
    path: '/font',
    component: LayoutView,
    redirect: '/font/menu',
    children: [
      { path: 'menu', component: MenuView },
      {
        path: 'order',
        children: [
          {
            path: 'orderList',
            component: OrderView,
          },
          {
            path: 'orderDetail',
            component: orderDetail,
          },
        ],
      },
      { path: 'exit', component: ExitView },
      { path: 'goods', component: GoodsView },
    ],
  },
  {
    path: '/back',
    redirect: '/back/dishManagement/dishCategory',
    component: backLayout,
    children:[
      // 菜品管理相关
      {
        path: 'dishManagement',
        name: 'DishManagement',
        meta: {
          title: '菜品管理',
          icon: 'Dish'
        },
        children: [
          { 
            path: 'dishCategory', 
            name: 'DishCategory',
            component: ()=>import('@/views/dishManagement/dishCategory.vue'),
            meta: {
              title: '菜品分类',
              icon: 'Dish'
            }
          },
          { 
            path: 'dishInfo', 
            name: 'DishInfo',
            component: ()=>import("@/views/dishManagement/dishInfo/index.vue"),
            meta: {
              title: '菜品信息',
              icon: 'Dish'
            }
          },
          // { 
          //   path: 'specificationManagement', 
          //   name: 'SpecificationManagement',
          //   component: OrderView,
          //   meta: {
          //     title: '规格管理',
          //     icon: 'Dish'
          //   }
          // },
        ],
      },
      // 桌子管理相关
      {
        path: 'tableManagement',
        name: 'TableManagement',
        meta: {
          title: '桌子管理',
          icon: 'Table'
        },
        children: [
          { 
            path: 'areaManagement', 
            name: 'AreaManagement',
            component: ()=>import("@/views/tableManagement/areaManagement.vue"),
            meta: {
              title: '区域管理',
              icon: 'Table'
            }
          },
          { 
            path: 'tableSettings', 
            name: 'TableSettings',
            component: ()=>import("@/views/tableManagement/tableSettings.vue"),
            meta: {
              title: '桌子设置',
              icon: 'Table'
            }
          },
        ],
      },
      { 
        path: 'materialManagement', 
        name: 'MaterialManagement',
        meta: {
          title: '物料管理',
          icon: 'Material'
        },
        children: [
          {
            path: 'materialList',
            name: 'MaterialList',
            component: ()=>import("@/views/materialManagement/materialList/index.vue"), // 假设这里有对应的材料列表视图组件
            meta: {
              title: '材料列表',
              icon: 'List'
            }
          },
          {
            path: 'purchaseOrder',
            name: 'PurchaseOrder',
            component: ()=>import("@/views/materialManagement/purchaseOrder/index.vue"), // 假设这里有对应的采购订单视图组件
            meta: {
              title: '采购订单',
              icon: 'Order'
            }
          }
        ]
      },
      { 
        path: 'orderManagement', 
        name: 'OrderManagement',
        component: OrderView,
        meta: {
          title: '订单管理',
          icon: 'Order'
        }
      },
      { 
        path: 'salesStatistics', 
        name: 'SalesStatistics',
        component: OrderView,
        meta: {
          title: '销售统计',
          icon: 'Statistics'
        }
      },
    ],
  },
  {
    path: '/test',
    name: 'Test',
    component: () => import('@/views/test/index.vue'),
  },
]

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

export default router
