diff --git a/src/main.js b/src/main.js index 1d3c216..5f7700f 100644 --- a/src/main.js +++ b/src/main.js @@ -47,18 +47,22 @@ const router = new VueRouter({ router.beforeEach((to, from, next) => { //NProgress.start(); let user = JSON.parse(sessionStorage.getItem('user')); - if (!user && to.path != '/login') { - if (/yyyfLoginBack/.test(to.path)) { + if (!user && to.path != '/login' && !/yyyfLoginBack/.test(to.path)) { + next({path: '/login'}) + } else if (user && to.path == '/login') { + if (user.userType == 3) { + next({name: 'Index'}) + } else { + next({path: '/yyyfLoginBack'})//next() + } + } else if (user && user.userType == 3 && to.path == '/yyyfLoginBack') {//学校管理员 + if (to.query && (to.query.userType == 1 || to.query.userType == 2)) { next() - // } else if (/train/.test(to.path)) {//暂时这么写,user是需要有值的,这里先方便页面 - // next() } else { - next({path: '/login'}) + next({name: 'Index'}) } - }else if(user && to.path =='/login'){ - next({name:'Index'}) - } else if (user && user.userType == 3 && to.path == '/yyyfLoginBack') { - next({name: 'Index'}) + } else if (user && (user.userType == 1 || user.userType == 2) && to.path == '/') { + next({path: '/yyyfLoginBack'})//next({path: '/login'}) } else { next() } diff --git a/src/views/TrainHome.vue b/src/views/TrainHome.vue index 4dd1d0b..cdf6f49 100644 --- a/src/views/TrainHome.vue +++ b/src/views/TrainHome.vue @@ -3,7 +3,7 @@ diff --git a/src/views/train/case-detail.vue b/src/views/train/case-detail.vue index 16ea81a..151b3aa 100644 --- a/src/views/train/case-detail.vue +++ b/src/views/train/case-detail.vue @@ -430,13 +430,14 @@ self.$message.error("判分设置模块总分不足100分!"); return; } - // userType 0学生 1教师 2管理员 - // if (self.formAction == 0 && self.$store.state.app.user.userType) { - // self.dataForm.isAdmin = self.$store.state.app.user.userType == 1 ? 0 : 1; - // } - if(this.formAction == 0){//新增 + let user = JSON.parse(sessionStorage.getItem('user')); + // userType 1教师 2超管 + if (self.formAction == 0 && user) { + self.dataForm.isAdmin = user.userType == 1 ? 0 : 1; + } + if(self.formAction == 0){//新增 Train.insertCase(self.dataForm).then(res => { - if (res.code == 200) { + if (res.status == 1) { // self.dataForm = Object.assign({}, self.dataForm, response.id); self.$message.success("操作成功!"); self.goBackList(); @@ -446,9 +447,9 @@ }).catch(error => { self.$message.error(error); }); - }else if(this.formAction == 1){//编辑 + }else if(self.formAction == 1){//编辑 Train.updateCase(self.dataForm).then(res => { - if (res.code == 200) { + if (res.status == 1) { self.$message.success("操作成功!"); self.goBackList(); } else { diff --git a/src/views/train/case-list.vue b/src/views/train/case-list.vue index 72ffe7d..9330d86 100644 --- a/src/views/train/case-list.vue +++ b/src/views/train/case-list.vue @@ -100,14 +100,14 @@ }); }, isShowEditOrDelBtn(row) { - // let userType = this.$store.state.user.userType; - // let projectType = row.isAdmin; - // if (userType == 1 && projectType == 1) {// 教师只能查看内置项目 - // return false; - // } - // if(userType==2 && projectType==0 ) {// 管理员只能查看教师项目 - // return false; - // } + let userType = JSON.parse(sessionStorage.getItem('user')).userType; + let projectType = row.isAdmin; + if (userType == 1 && projectType == 1) {// 教师只能查看内置项目 + return false; + } + if(userType== 2 && projectType==0 ) {// 管理员只能查看教师项目 + return false; + } return true; }, doNew() {// 新增 @@ -120,7 +120,7 @@ type: 'warning' }).then(() => { Train.delCase({id: row.id}).then((res) => { - if (res.code == 200) { + if (res.status == 1) { this.$message.success('删除成功!'); this.initList(); } else {