import Vue from 'vue'; import VueRouter from 'vue-router'; import store from '@/store/index'; import { Notification } from 'element-ui'; Vue.use(VueRouter); const system = [ { path: '/train/batch/index', name: 'train_batch_index', meta: { title: '培训批次管理' }, component: () => import('@/views/train-batch/index.vue'), }, { path: '/dept/index', name: 'dept_index', meta: { title: '部门', sub: '管理' }, component: () => import('@/views/dept/index.vue'), }, { path: '/dept/detail', name: 'dept_detail', meta: { title: '部门', sub: '详情' }, component: () => import('@/views/dept/detail.vue'), }, { path: '/director/index', name: 'director_index', meta: { title: '班主任', sub: '管理' }, component: () => import('@/views/director/index.vue'), }, { path: '/director/detail', name: 'director_detail', meta: { title: '班主任', sub: '详情' }, component: () => import('@/views/director/detail.vue'), }, { path: '/director/shareInfo', name: 'director_shareInfo', meta: { title: '班主任', sub: '审核' }, component: () => import('@/views/director/shareInfo.vue'), }, { path: '/teacher/detail', name: 'teacher_detail', meta: { title: '教师', sub: '详情' }, component: () => import('@/views/teacher/detail.vue'), }, { path: '/teacher/index', name: 'teacher_index', meta: { title: '教师', sub: '管理' }, component: () => import('@/views/teacher/index.vue'), }, { path: '/teacher/printTea', meta: { title: '教师打印' }, component: () => import('@/views/teacher/printTea.vue'), }, { path: '/teacher/means', name: 'teacher_means', component: () => import('@/views/teacher/means.vue'), }, { path: '/teacher/verify', name: 'teacher_verify', meta: { title: '教师', sub: '审核页' }, component: () => import('@/views/teacher/verify.vue'), }, { path: '/school/index', name: 'school_index', meta: { title: '学校管理', sub: '' }, component: () => import('@/views/school/index.vue'), }, { path: '/school/detail', name: 'school_detail', meta: { title: '学校信息', sub: '' }, component: () => import('@/views/school/detail.vue'), }, { path: '/class/type', name: 'class_type', meta: { title: '班级类型管理' }, component: () => import('@/views/classes/type.vue'), }, { path: '/location/index', name: 'location_index', meta: { title: '地点', sub: '管理' }, component: () => import('@/views/location/index.vue'), }, { path: '/location/detail', name: 'location_detail', meta: { title: '地点', sub: '详情' }, component: () => import('@/views/location/detail.vue'), }, { path: '/bedroom/index', name: 'bedroom_index', meta: { title: '寝室', sub: '管理' }, component: () => import('@/views/bedroom/index.vue'), }, { path: '/bedroom/detail', name: 'bedroom_detail', meta: { title: '寝室', sub: '详情' }, component: () => import('@/views/bedroom/detail.vue'), }, { path: '/subject/index', name: 'subject_index', meta: { title: '科目', sub: '管理' }, component: () => import('@/views/subject/index.vue'), }, { path: '/subject/detail', name: 'subject_detail', meta: { title: '科目', sub: '详情' }, component: () => import('@/views/subject/detail.vue'), }, { path: '/work/detail', name: 'work_detail', meta: { title: '作业', sub: '详情' }, component: () => import('@/views/work/detail.vue'), }, { path: '/work/index', name: 'work_index', meta: { title: '作业', sub: '管理' }, component: () => import('@/views/work/index.vue'), }, { path: '/work/look', name: 'work_look', meta: { title: '作业题', sub: '管理' }, component: () => import('@/views/work/look.vue'), }, { path: '/duty/index', name: 'duty_index', meta: { title: '职责', sub: '说明' }, component: () => import('@/views/duty/index.vue'), }, { path: '/lesson/index', name: 'lesson_index', meta: { title: '课程模板管理', sub: '' }, component: () => import('@/views/lesson/index.vue'), }, { path: '/lesson/detail', name: 'lesson_detail', meta: { title: '课程模板', sub: '' }, component: () => import('@/views/lesson/detail.vue'), }, { path: '/questionnaire/index', name: 'questionnaire_index', meta: { title: '问卷', sub: '管理' }, component: () => import('@/views/questionnaire/index.vue'), }, { path: '/questionnaire/export/setting', name: 'questionnaire_export_setting', meta: { title: '问卷导出设置' }, component: () => import('@/views/questionnaire/export-setting.vue'), }, { path: '/questionnaire/detail', name: 'questionnaire_detail', meta: { title: '问卷', sub: '详情' }, component: () => import('@/views/questionnaire/detail.vue'), }, { path: '/questionstate/index', name: 'questionstate_index', meta: { title: '问卷进度管理', sub: '' }, component: () => import('@/views/questionstate/index.vue'), }, { path: '/itembank/detail', name: 'itembank_detail', meta: { title: '题库', sub: '详情' }, component: () => import('@/views/Itembank/detail.vue'), }, { path: '/itembank/index', name: 'itembank_index', meta: { title: '题库', sub: '管理' }, component: () => import('@/views/Itembank/index.vue'), }, // { // path: '/classes/index', // name: 'classes_index', // meta: { title: '班级', sub: '管理' }, // component: () => import('@/views/classes/index.vue'), // }, // { // path: '/classes/detail', // name: 'classes_detail', // meta: { title: '班级', sub: '详情' }, // component: () => import('@/views/classes/detail.vue'), // }, { path: '/setting', name: 'setting', meta: { title: '系统邮箱设置' }, component: () => import('@/views/setting/system-setting.vue'), }, ]; const newPlan = [ { path: '/plan/index', name: 'newPlan_index', meta: { title: '年度计划管理' }, component: () => import('@/views/new-plan/index.vue'), }, { path: '/plan/template', name: 'newPlan_template', meta: { title: '计划模板' }, component: () => import('@/views/new-plan/template.vue'), }, { path: '/plan/arrange', name: 'newPlan_arrange', meta: { title: '培训计划安排' }, component: () => import('@/views/new-plan/arrange/arrange.vue'), }, { path: '/plan/director', name: 'newPlan_director', meta: { title: '班主任计划安排' }, component: () => import('@/views/new-plan/arrange/director-arrange.vue'), }, { path: '/plan/school/num', name: 'newPlan_school_num', meta: { title: '学校人数安排' }, component: () => import('@/views/new-plan/arrange/school-num.vue'), }, { path: '/plan/school/time', name: 'newPlan_school_time', meta: { title: '学校参培时间' }, component: () => import('@/views/new-plan/arrange/school-time.vue'), }, { path: '/plan/school/name/list', name: 'newPlan_school_name_list', meta: { title: '学校上报名单管理' }, component: () => import('@/views/new-plan/deal-list.vue'), }, { path: '/plan/school/stu/export', name: 'newPlan_school_name_list', meta: { title: '学生名单导出' }, component: () => import('@/views/new-plan/stu-export.vue'), }, { path: '/plan/school', name: 'newPlan_school', meta: { title: '学校计划安排' }, component: () => import('@/views/new-plan/arrange/school-arrange.vue'), }, { path: '/plan/classes/detail', name: 'newPlan_classes_detail', meta: { title: '班级安排' }, component: () => import('@/views/new-plan/class/classes.vue'), }, { path: '/plan/classes/lesson', name: 'newPlan_classes_lesson', meta: { title: '排课管理' }, component: () => import('@/views/new-plan/class/lesson.vue'), }, { path: '/plan/classes/setting', name: 'newPlan_classes_setting', meta: { title: '班级设置' }, component: () => import('@/views/new-plan/class/setting.vue'), }, { path: '/plan/classes/bedroom', name: 'newPlan_classes_bedroom', meta: { title: '分寝' }, component: () => import('@/views/new-plan/class/bedroom.vue'), }, { path: '/plan/classes/namelist', name: 'newPlan_classes_namelist', meta: { title: '班级人员' }, component: () => import('@/views/new-plan/class/name-list.vue'), }, { path: '/plan/teacher/lesson', name: 'newPlan_teacher_lesson', meta: { title: '初步课程表' }, component: () => import('@/views/new-plan/teacher-lesson.vue'), }, { path: '/plan/teacher/plan', name: 'newPlan_teacher_plan', meta: { title: '教师上报课程' }, component: () => import('@/views/new-plan/teacher-plan.vue'), }, ]; const train = [ //班级设置需要处理,通知 { path: '/train/plan/classes', name: 'train_plan_classes', meta: { title: '学生分班' }, component: () => import('@/views/train-plan/classes.vue'), }, { path: '/train/plan/bedroom', name: 'train_plan_bedroom', meta: { title: '寝室管理' }, component: () => import('@/views/train-plan/bedroom.vue'), }, { path: '/train/plan/quest', name: 'train_plan_quest', meta: { title: '非常用问卷管理' }, component: () => import('@/views/train-plan/quest.vue'), }, // { // path: '/train/plan/lesson', // name: 'train_plan_lesson', // meta: { title: '课表管理管理' }, // component: () => import('@/views/train-plan/lesson.vue'), // }, { path: '/train/plan/term/lesson', name: 'train_plan_term_lesson', meta: { title: '期课表' }, component: () => import('@/views/train-plan/term-lesson.vue'), }, { path: '/train/plan/class/lesson', name: 'train_plan_class_lesson', meta: { title: '班课表' }, component: () => import('@/views/train-plan/class-lesson.vue'), }, { path: '/train/plan/remind', name: 'train_plan_remind', meta: { title: '通知' }, component: () => import('@/views/train-plan/remind.vue'), }, { path: '/train/plan/remind/detail', name: 'train_plan_remind_detail', meta: { title: '通知接收情况' }, component: () => import('@/views/train-plan/remind-detail.vue'), }, { path: '/student/index', name: 'student_index', meta: { title: '学生管理', sub: '' }, component: () => import('@/views/student/index.vue'), }, { path: '/student/detail', name: 'student_detail', meta: { title: '学生详情', sub: '' }, component: () => import('@/views/student/detail.vue'), }, //报表打印(部分) { path: '/train/plan/print', name: 'train_plan_print', meta: { title: '打印报表' }, component: () => import('@/views/train-plan/print.vue'), }, { path: '/certificaate/index', name: 'certificaate_index', meta: { title: '证书', sub: '管理' }, component: () => import('@/views/certificaate/index.vue'), }, { path: '/certificaate/detail', name: 'certificaate_detail', meta: { title: '证书', sub: '详情' }, component: () => import('@/views/certificaate/detail.vue'), }, { path: '/certificaate/look', name: 'certificaate_look', meta: { title: '证书', sub: '打印' }, component: () => import('@/views/certificaate/look.vue'), }, //报表打印结束 { path: '/train/plan/leave', name: 'train_plan_leave', meta: { title: '请假管理' }, component: () => import('@/views/train-plan/leave.vue'), }, { path: '/train/plan/attendance', name: 'train_plan_attendance', meta: { title: '考勤管理' }, component: () => import('@/views/train-plan/attendance.vue'), }, // 07-20新增 // 特殊班考勤管理 { path: '/train/plan/tsbattendance', name: 'train_plan_tsbattendance', meta: { title: '特殊班考勤管理' }, component: () => import('@/views/train-plan/tsbattendance.vue'), }, // 特殊班学生分寝管理 { path: '/train/plan/tsbbedroom', name: 'train_plan_tsbbedroom', meta: { title: '特殊班寝室管理' }, component: () => import('@/views/train-plan/tsbbedroom.vue'), }, { path: '/train/plan/score', name: 'train_plan_score', meta: { title: '学生成绩' }, component: () => import('@/views/train-plan/score.vue'), }, // 08-22 // 课程培训 { path: '/trainVidoe/index', name: 'trainVidoe_index', meta: { title: '课程培训' }, component: () => import('@/views/trainVidoe/index.vue'), }, { path: '/trainVidoe/detail', name: 'trainVidoe_detail', meta: { title: '课程培训' }, component: () => import('@/views/trainVidoe/detail.vue'), }, { path: '/trainVidoe/viewVideo', name: 'trainVidoe_viewVideo', meta: { title: '课程培训' }, component: () => import('@/views/trainVidoe/viewVideo.vue'), }, ]; const statistics = [ { path: '/statistics/question/index', name: 'statistics_question', meta: { title: '问卷统计' }, component: () => import('@/views/statistics/index.vue'), }, { path: '/statistics/question/detail', name: 'statistics_question_detail', meta: { title: '问卷统计' }, component: () => import('@/views/statistics/detail.vue'), }, { path: '/statistics/question/class', name: 'statistics_question_class', meta: { title: '问卷-按班级统计' }, component: () => import('@/views/statistics/class-index.vue'), }, { path: '/statistics/nostu', name: 'statistics_nostu', meta: { title: '问卷-未答学生统计' }, component: () => import('@/views/statistics/nostu.vue'), }, ]; const routes = [ { path: '', component: () => import('@/views/index.vue'), children: [ { path: '/', name: 'home', component: () => import('@/views/home.vue'), }, ...system, ...newPlan, ...train, ...statistics, { path: '/list', name: 'test_list', component: () => import('@/views/test/list.vue'), }, { path: '/detail', name: 'test_detail', component: () => import('@/views/test/detail.vue'), }, { path: '/receive/index', name: 'receive_index', meta: { title: '通知查看' }, component: () => import('@/views/receive/index.vue'), }, // 在线授课管理 { path: '/centerTeaching/index', name: 'centerTeaching_index', meta: { title: '直播讲课' }, component: () => import('@/views/centerTeaching/index.vue'), }, { path: '/centerTeaching/afterClass', name: 'centerTeaching_afterClass', meta: { title: '课后答疑' }, component: () => import('@/views/centerTeaching/afterClass.vue'), }, // 积分榜 { path: '/league/index', name: 'league_index', meta: { title: '课后答疑' }, component: () => import('@/views/league/index.vue'), }, // 09-24 { path: '/newspaper/index', name: 'newspaper_index', meta: { title: '新人才报' }, component: () => import('@/views/newspaper/index.vue'), }, ], }, { path: '/teacher/printTea', meta: { title: '教师打印预览' }, component: () => import('@/views/teacher/printTea.vue'), }, { path: '/yearPlan/index', name: 'yearPlan_index', meta: { title: '全年计划', sub: '管理' }, component: () => import('@/views/yearPlan/index.vue'), }, // { // path: '/student/name/card', // name: 'student_name_card', // meta: { title: '学生名签' }, // component: () => import('@/views/student/namCard.vue'), // }, // 教师甄选注册账号 { path: '/teaRegister', name: 'teaRegister', meta: { title: '教师注册', sub: '管理' }, component: () => import('@/views/register/teaRegister.vue'), }, { path: '/login', name: 'login', meta: { title: '登录', sub: '管理' }, component: () => import('@/views/register/login.vue'), }, ]; const router = new VueRouter({ mode: 'history', base: process.env.NODE_ENV === 'development' ? '' : 'center', routes, }); router.beforeEach((to, form, next) => { store.commit('setUser'); store.dispatch('setting/checkCache'); if (to.name === 'login') { next(); return; } let user = store.state.user; if (user) { if (user.type == process.env.VUE_APP_USER_TYPE) { console.log('已登录'); next(); } else { Notification({ title: '请重新登陆', message: `原因:非当前端用户,需要重新登陆`, type: 'warning', }); console.warn('非当前端用户,需要重新登陆'); next({ name: 'login' }); } } //下面是没登录的情况,需要跳转页面到用户未登录页 else next({ name: 'login' }); }); export default router;