import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/pagemonitor',
  },
  {
    path: '/pageBox',
    component: () => import('@/views/pageBox/index.vue'),
    redirect: '/pagemonitor',
    children: [
      {
        path: '/pagemonitor',
        name: 'pagemonitor',
        meta: { title: '运营监控数据可视化' },
        component: () => import('@/views/pageMonitor/index.vue'),
      },
      {
        path: '/pagescheduling',
        name: 'pagescheduling',
        meta: { title: '护理人员排班' },
        component: () => import('@/views/pageScheduling/index.vue'),
      },
      {
        path: '/pageoperation',
        name: 'pageoperation',
        meta: { title: '首台率数据总览' },
        component: () => import('@/views/pageOperation/index.vue'),
      },
      {
        path: '/pageroom',
        name: 'pageroom',
        meta: { title: '手术间利用率' },
        component: () => import('@/views/pageRoom/index.vue'),
      },
    ],
  },
  {
    path: '/waitList/:groupIndex?',
    name: 'waitList',
    meta: { title: '家属等候大屏' },
    component: () => import('@/views/waitList/index.vue'),
  },
  {
    path: '/scheduleList/:groupIndex?',
    name: 'scheduleList',
    meta: { title: '手术排程' },
    component: () => import('@/views/scheduleList/index.vue'),
  },
  {
    path: '/melon',
    name: 'melon',
    meta: { title: '手术排程' },
    component: () => import('@/views/pageMelon/index.vue'),
  },
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  next();
});

export default router;
