瀏覽代碼

增加返回状态码错误异常处理

TheLittlePrince 6 年之前
父節點
當前提交
12eb13ac09
共有 7 個文件被更改,包括 286 次插入230 次删除
  1. 14 3
      src/axios/index.js
  2. 23 23
      src/components/MenuComponent.vue
  3. 32 11
      src/components/SuperComponent.vue
  4. 99 75
      src/pages/home/SchoolManager.vue
  5. 98 102
      src/router/index.js
  6. 4 4
      src/store/getters.js
  7. 16 12
      src/store/modules/user.js

+ 14 - 3
src/axios/index.js

@@ -2,6 +2,8 @@ import axios from 'axios'
 import qs from 'qs'
 import util from '@/js/util'
 import { TIME_OUT } from '@/config'
+import router from '@/router';
+import { Message } from 'element-ui'
 
 // 网络请求前拦截器
 axios.interceptors.request.use(resquest => {
@@ -28,8 +30,17 @@ axios.interceptors.response.use(response => {
 // 数据统一处理来自网络及服务器的错误
 function checkStatus (response) {
     if (response && response.status === 200 || response && response.status === 304){
+        Message.success('请求成功')
         return response.data
-    } else {
+    }
+    if (response && response.status === 401){
+        sessionStorage.removeItem("accessToken")
+        router.replace({
+            path: '/' // 到登录页重新获取token
+        })
+        Message.error('登陆失效,请重新登录')
+    }  else {
+        Message.error('网络错误')
         return response && response.statusText || '网络错误'
     }
 }
@@ -41,8 +52,8 @@ function checkCode (response) {
     }
     return response
 }
-let accessToken = sessionStorage.getItem("accessToken")
-// let accessToken = "jAf6LV0HJJiIvhgvIHCM2t10GW7lHt5VAUE13pmj2lLEWlzQyNqx9dbVG0aXpTvn"
+// let accessToken = sessionStorage.getItem("accessToken")
+let accessToken = "evbOfyzBDlwwi2Tn8KTc5h3sWKsbrpbiazL7wYh7vyTs9KtJ1vANq6j3DmOwFjbL"
 
 // export default ({method = 'post', url = '', params = {}}) => {
 // 	return new Promise((resolve, reject) => {

+ 23 - 23
src/components/MenuComponent.vue

@@ -7,7 +7,6 @@
     <!-- v-show="roles.indexOf(item.id) >= 0" -->
     <el-col
       :span="2"
-      v-show="roles.indexOf(item.id) >= 0"
       v-for="(item, index) of menuData"
       :key="item.index"
       @click.native="secondNavClick(item,index)"
@@ -44,35 +43,35 @@ export default {
        BASE_URL: "https://xt.sharingschool.com/upload/",
       menuData: [
         {
-          id: "1",
+          id: "2",
           name: "校区群管理员",
           href: "SchoolManager"
         },
         {
-          id: "1",
+          id: "2",
           name: " 在线批改老师",
           href: "TeacherApporval"
         },
-        {
-          id: "2",
-          name: "",
-          href: "TeacherPay"
-        },
-        {
-          id: "1",
-          name: "校区管理员",
-          href: "SuperAdmin"
-        },
-        {
-          id: "1",
-          name: " 批改老师注册审核",
-          href: "CheckTeacherAudit"
-        },
-        {
-          id: "1",
-          name: "批改老师薪酬表",
-          href: "CheckTeacherPay"
-        }
+        // {
+        //   id: "3",
+        //   name: "",
+        //   href: "TeacherPay"
+        // },
+        // {
+        //   id: "1",
+        //   name: "校区管理员",
+        //   href: "SuperAdmin"
+        // },
+        // {
+        //   id: "1",
+        //   name: " 批改老师注册审核",
+        //   href: "CheckTeacherAudit"
+        // },
+        // {
+        //   id: "3",
+        //   name: "批改老师薪酬表",
+        //   href: "CheckTeacherPay"
+        // }
       ],
       checkindex: 0
     };
@@ -172,6 +171,7 @@ export default {
   font-size: 14px;
   color: #666666;
   display: inline-block;
+  cursor: pointer;
 }
 .out-img {
   width: 16px;

+ 32 - 11
src/components/SuperComponent.vue

@@ -10,17 +10,19 @@
 
       </el-col>
 
-      <el-col :span="3"  :offset="10">
-        <div class="login">
-          <img class="userstyle" src="../assets/img/user.jpg"/>
-          <span>李老师</span>
-          <i class="el-icon-caret-bottom"></i>
-        </div>
-        <div class="out">
-          <img src="../assets/img/out.png" alt="" class="out-img">
-          <span>退出</span>
-        </div>
-      </el-col>
+      <el-col :span="4" :offset="2">
+      <div class="login">   
+        <img  class="userstyle"  :src="BASE_URL + avatar" alt="">
+        <!-- <img class="userstyle" src="../assets/img/user.jpg"> -->
+        <span>{{name}}</span>
+        <i class="el-icon-caret-bottom"></i>
+      </div>
+      <div class="out">
+        <img src="../assets/img/out.png" alt class="out-img">
+        <span @click="Loginout">退出</span>
+      </div>
+    </el-col>
+    <el-col :span="1"></el-col>
   </el-col>
 </template>
 
@@ -33,6 +35,7 @@ export default {
   // },
   data() {
     return {
+         BASE_URL: "https://xt.sharingschool.com/upload/",
       menuData: [ {
     id: "2",
     name: "校区管理员",
@@ -66,6 +69,24 @@ export default {
     secondNavClick(val, index) {
       this.$router.push("/super/" + val.href);
       this.checkindex = index;
+    },
+     //  账号管理、退出登录
+    Loginout() {
+      this.$confirm("您确定退出吗?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          localStorage.removeItem("accessToken");
+          this.$store.dispatch("LogOut").then(() => {
+            location.reload(); // 为了重新实例化vue-router对象 避免bug
+          });
+        })
+        .catch(() => {
+          // console.log(err)
+          this.$message("已取消操作!");
+        });
     }
   },
   computed: {

+ 99 - 75
src/pages/home/SchoolManager.vue

@@ -23,7 +23,7 @@
           </el-col>
           <el-col :span="4">
             <div class="main-header-item">
-              <span>分配批改作业:{{monitorTeacherList.unCorrectCount}}份</span>
+              <span>分配批改作业:{{monitorTeacherList.unCorrectCount}}份</span>
               <span @click="isShow(monitorTeacherList,2)" class="main-header-link">去分配</span>
             </div>
           </el-col>
@@ -65,6 +65,7 @@
               v-model="filters.MaxtimeValue"
               value-format="yyyy-MM-dd HH:mm:ss"
               type="date"
+                @change="InfoWatch"
               placeholder="选择日期"
             ></el-date-picker>
           </div>
@@ -122,23 +123,32 @@
                       <el-button type="warning" plain>去检查</el-button>
                     </div>
                   </div>
+                     <!-- 分页显示 -->
+            <el-pagination
+            background
+            @size-change="handleSizeChange3"
+            @current-change="pageChange3"
+            :page-sizes="[10, 20, 30, 40]"
+             layout="total, sizes, prev, pager, next, jumper"
+             :total= parseInt(TeacherHomeworkList.pages)
+            ></el-pagination>
                 </div>
               </div>
             </div>
             <!-- 分页显示 -->
-            <!-- <el-pagination
+            <el-pagination
             background
             @size-change="handleSizeChange"
             @current-change="pageChange"
             :page-sizes="[10, 20, 30, 40]"
              layout="total, sizes, prev, pager, next, jumper"
-           :total="TeacherHomeworkList.pages"
-            ></el-pagination>-->
+             :total= parseInt(monitorTeacherList.pages)
+            ></el-pagination>
             <!-- <div style="float:right;margin-left:15px;">
             <el-button @click="myVisible = false" size="small">取 消</el-button>
             <el-button type="primary" size="small" @click="submit">确定</el-button>
-          </div>
-            <div style="clear:both;"></div>-->
+          </div> -->
+            <div style="clear:both;"></div>
           </el-col>
         </el-row>
       </el-col>
@@ -184,7 +194,8 @@
           <el-col :span="4">
             <div class="block">
               <el-date-picker
-                v-model="filters.MaxtimeValue"
+               @change="InfoWatchDay"
+                v-model="filters1.MaxtimeValue"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 type="date"
                 placeholder="选择日期"
@@ -221,19 +232,19 @@
               </div>
             </div>
             <!-- 分页显示 -->
-            <!-- <el-pagination
+            <el-pagination
             background
-            @size-change="handleSizeChange"
-            @current-change="pageChange"
+            @size-change="handleSizeChange1"
+            @current-change="pageChange1"
             :page-sizes="[10, 20, 30, 40]"
              layout="total, sizes, prev, pager, next, jumper"
-           :total="TeacherHomeworkList.pages"
-            ></el-pagination>-->
+              :total= parseInt(DayTeacherList.pages)
+            ></el-pagination>
             <!-- <div style="float:right;margin-left:15px;">
             <el-button @click="myVisible = false" size="small">取 消</el-button>
             <el-button type="primary" size="small" @click="submit">确定</el-button>
-          </div>
-            <div style="clear:both;"></div>-->
+          </div> -->
+            <div style="clear:both;"></div>
           </el-col>
         </el-row>
       </el-col>
@@ -279,7 +290,8 @@
           <el-col :span="4">
             <div class="block">
               <el-date-picker
-                v-model="filters.MaxtimeValue"
+               @change="InfoWatchMoth"
+                v-model="filters2.MaxtimeValue"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 type="date"
                 placeholder="选择日期"
@@ -340,19 +352,19 @@
               </div>
             </div>
             <!-- 分页显示 -->
-            <!-- <el-pagination
+            <el-pagination
             background
-            @size-change="handleSizeChange"
-            @current-change="pageChange"
+            @size-change="handleSizeChange2"
+            @current-change="pageChange2"
             :page-sizes="[10, 20, 30, 40]"
              layout="total, sizes, prev, pager, next, jumper"
-           :total="TeacherHomeworkList.pages"
-            ></el-pagination>-->
+           :total= parseInt(MothTeacherList.pages)
+            ></el-pagination>
             <!-- <div style="float:right;margin-left:15px;">
             <el-button @click="myVisible = false" size="small">取 消</el-button>
             <el-button type="primary" size="small" @click="submit">确定</el-button>
-          </div>
-            <div style="clear:both;"></div>-->
+          </div> -->
+            <div style="clear:both;"></div>
           </el-col>
         </el-row>
       </el-col>
@@ -403,6 +415,7 @@
           <div>所有未批改作业</div>
         </div>
         <div>
+          <!-- UnallotHomeworkInfo -->
           <div class="tr-set" v-for="(v, k) of TeacherHomeworkList.list" :key="k">
             <div class="tr-secon">{{k+1}}</div>
             <div class="tr-secon" style="width:50px;">
@@ -419,12 +432,16 @@
               <el-button type="success">去分配</el-button>
             </div>
           </div>
+            <el-pagination
+            background
+            @size-change="handleSizeChange3"
+            @current-change="pageChange3"
+            :page-sizes="[10, 20, 30, 40]"
+             layout="total, sizes, prev, pager, next, jumper"
+             :total= parseInt(TeacherHomeworkList.pages)
+            ></el-pagination>
         </div>
-        <!-- <el-table :data="tableData" style="width: 100%">
-          <el-table-column prop="date" label="日期" width="180"></el-table-column>
-          <el-table-column prop="name" label="姓名" width="180"></el-table-column>
-          <el-table-column prop="address" label="地址"></el-table-column>
-        </el-table>-->
+  
       </div>
     </div>
     <!-- 老师详情弹框 -->
@@ -560,32 +577,8 @@ export default {
           text: "当月"
         }
       ],
-      dataList: [
-        {
-          img: "../../assets/img/user.jpg",
-          names: "阿三",
-          number: "3",
-          time: "14:22",
-          allTime: "14:22",
-          rate: "222",
-          status: "22"
-        },
-        {
-          img: "../../assets/img/user.jpg",
-          names: "阿三",
-          number: "3",
-          time: "14:22",
-          allTime: "14:22",
-          rate: "222",
-          status: "22"
-        }
-      ],
       filters: {
         //超级管理员的当天数据
-        actvNm: "",
-        actvCrtUserId: "",
-        actvType: "",
-        actvSmallType: "",
         // 排序
         MaxtimeValue: "",
         OptionsValue: "",
@@ -599,10 +592,6 @@ export default {
       },
       filters1: {
         //超级管理员的当天数据
-        actvNm: "",
-        actvCrtUserId: "",
-        actvType: "",
-        actvSmallType: "",
         // 排序
         MaxtimeValue: "",
         OptionsValue: "",
@@ -616,10 +605,19 @@ export default {
       },
       filters2: {
         //超级管理员的当月数据
-        actvNm: "",
-        actvCrtUserId: "",
-        actvType: "",
-        actvSmallType: "",
+        // 排序
+        MaxtimeValue: "",
+        OptionsValue: "",
+        gradesValue: "",
+        inputValue: "",
+        pageNo: 1,
+        pageSize: 10,
+        count: 0,
+        orderField: "",
+        orderAD: ""
+      },
+        filters3: {
+        //超级管理员查看学员列表
         // 排序
         MaxtimeValue: "",
         OptionsValue: "",
@@ -633,7 +631,8 @@ export default {
       },
       homeworkLIst: {
         pageNo: 1,
-        pageSize: 10
+        pageSize: 10,
+        teacherId:""
       },
       allotList: {
         Allotgarde: "",
@@ -718,6 +717,7 @@ export default {
     },
     // 查看老师批改作业列表
     async TeacherHomework(v) {
+      this.homeworkLIst.teacherId =  v.teacherId
       this.$store.dispatch("TeacherHomeworkList", {
         teacherId: v.teacherId,
         maxCreateTime: this.filters.MaxtimeValue,
@@ -725,6 +725,15 @@ export default {
         pageSize: this.homeworkLIst.pageSize
       });
     },
+       // 分页查看老师批改作业列表
+    async TeacherHomeworkfy() {
+      this.$store.dispatch("TeacherHomeworkList", {
+        teacherId: this.homeworkLIst.teacherId,
+        maxCreateTime: this.filters.MaxtimeValue,
+        pageNo: this.homeworkLIst.pageNo,
+        pageSize: this.homeworkLIst.pageSize
+      });
+    },
     // 可分配老师列表
     async TeacherAllot(v) {
       this.$store.dispatch("TeacherAllotList", {
@@ -735,7 +744,7 @@ export default {
         pageSize: this.allotList.pageSize
       });
     },
-    // 批改作业列表列表
+    // 批改作业列表列表
     async UnallotHomework() {
       this.$store.dispatch("UnallotHomeworkList", {
         maxCreateTime: this.filters.MaxtimeValue,
@@ -763,7 +772,6 @@ export default {
       this.$store.dispatch("GetStudentDetail", {
         vipId: v.vipId,
       });
-        debugger
     },
     selectTitle(k) {
       console.log(k);
@@ -825,11 +833,6 @@ export default {
         }
       }
     },
-    // 分页
-    pageChange(val) {
-      this.filters.pageNo = val;
-      this.InfoWatch();
-    },
     changeDateSlot(dateSlot) {
       if (dateSlot) {
         this.filters.startDate = dateSlot[0];
@@ -859,20 +862,41 @@ export default {
       this.filters.pageSize = val;
       this.InfoWatch();
     },
+      handleSizeChange1(val) {
+      this.filters1.pageSize = val;
+      this.InfoWatchDay();
+    },
+      handleSizeChange2(val) {
+      this.filters2.pageSize = val;
+      this.InfoWatchMoth();
+    },
+      handleSizeChange3(val) {
+      this.homeworkLIst.pageSize = val;
+      this.TeacherHomeworkfy();
+    },
+      // 分页
+    pageChange(val) {
+      this.filters.pageNo = val;
+      this.InfoWatch();
+    },  // 分页
+    pageChange1(val) {
+      this.filters1.pageNo = val;
+      this.InfoWatchDay();
+    },  // 分页
+    pageChange2(val) {
+      this.filters2.pageNo = val;
+      this.InfoWatchMoth();
+    },
+      pageChange3(val) {
+      this.homeworkLIst.pageNo = val;
+      this.TeacherHomeworkfy();
+    },
     // 排序
     sortChange(sort) {
       this.filters.orderField = sort.prop;
       this.filters.orderAD = sort.order != null ? sort.order : "";
       this.itemListReshow();
     },
-    clearSearch() {
-      this.filters.actvNm = null;
-      this.filters.actvCrtUserId = null;
-      this.filters.actvType = null;
-      this.filters.actvSmallType = null;
-      this.filtersActvType = [];
-      this.createDateSlot = null;
-    }
     // 获取创建人列表
     // async getUserNameList() {
     //   let {

+ 98 - 102
src/router/index.js

@@ -9,9 +9,9 @@ import Error404 from "@/pages/Error404";
 import SchoolManager from "@/pages/home/SchoolManager";
 import TeacherApporval from "@/pages/home/TeacherApporval";
 import TeacherPay from "@/pages/home/TeacherPay";
-import CheckTeacherAudit from "@/pages/home/CheckTeacherAudit";
-import CheckTeacherPay from "@/pages/home/CheckTeacherPay";
-import SuperAdmin from "@/pages/home/SuperAdmin";
+import CheckTeacherAudit from "@/pages/Super/CheckTeacherAudit";
+import CheckTeacherPay from "@/pages/Super/CheckTeacherPay";
+import SuperAdmin from "@/pages/Super/SuperAdmin";
 import Redirect_uri from "@/pages/aikmt/Redirect_uri"; //微信登陆路由重定向页面
 Vue.use(Router);
 
@@ -32,86 +32,34 @@ export const constantRouterMap =
       name: "微信认证重定向页",
       component: Redirect_uri
     },
-    {
-      path: "/super",
-      component: Super,
-    },
-    //  {
-    //    path: "/super",
-    //    component: Super,
-    //    children:[
-    //      {
-    //        path: "",
-    //        redirect: "SuperAdmin"
-    //      },
-    //      {
-    //        path: "SuperAdmin",
-    //        name: "SuperAdmin",
-    //        component: SuperAdmin,
-    //        meta: { title: '超级管理员', roles: ['2'] }
-    //      },
-    //      {
-    //        path: "CheckTeacherAudit",
-    //        name: "CheckTeacherAudit",
-    //        component: CheckTeacherAudit,
-    //        meta: { title: '批改老师注册审核', roles: ['2'] }
-    //      },
-    //      {
-    //        path: "CheckTeacherPay",
-    //        name: "CheckTeacherPay",
-    //        component: CheckTeacherPay,
-    //        meta: { title: '批改老师薪酬表', roles: ['2'] }
-    //      },
-    //    ]
-    //  },
-    //   {
-    //    path: "/home",
-    //    component: Home,
-    //    children: [
-    //      {
-    //        path: "",
-    //        redirect: "SchoolManager"
-    //      },
-    //      {
-    //        path: "SchoolManager",
-    //        name: "SchoolManager",
-    //        component: SchoolManager,
-    //        meta: { title: '校区管理员', roles: ['2'] }
-    //      },
-    //      {
-    //        path: "TeacherApporval",
-    //        name: "TeacherApporval",
-    //        component: TeacherApporval,
-    //        meta: { title: '教师审核', roles: ['2'] }
-
-    //      },
-    //      {
-    //        path: "TeacherPay",
-    //        name: "TeacherPay",
-    //        component: TeacherPay,
-    //        meta: { title: '教师薪酬管理', roles: ['1'] }
-    //      },
-    //      {
-    //        path: "*",
-    //        name: "找不到页面",
-    //        component: Error404
-    //      }
-    //    ]
-    //  },
      {
-       path: "*",
-       name: "错误页面",
-       component: Error
-     }
-
-  ]
-export default new Router({
-  routes: constantRouterMap
-})
-
-// 异步挂载的路由
-// 动态需要根据权限加载的路由表
-export const asyncRouterMap = [
+       path: "/super",
+       component: Super,
+       children:[
+         {
+           path: "",
+           redirect: "SuperAdmin"
+         },
+         {
+           path: "SuperAdmin",
+           name: "SuperAdmin",
+           component: SuperAdmin,
+           meta: { title: '超级管理员', roles: ['1'] }
+         },
+         {
+           path: "CheckTeacherAudit",
+           name: "CheckTeacherAudit",
+           component: CheckTeacherAudit,
+           meta: { title: '批改老师注册审核', roles: ['2'] }
+         },
+         {
+           path: "CheckTeacherPay",
+           name: "CheckTeacherPay",
+           component: CheckTeacherPay,
+           meta: { title: '批改老师薪酬表', roles: ['2'] }
+         },
+       ]
+     },
       {
        path: "/home",
        component: Home,
@@ -124,13 +72,13 @@ export const asyncRouterMap = [
            path: "SchoolManager",
            name: "SchoolManager",
            component: SchoolManager,
-           meta: { title: '校区管理员', roles: ['1'] }
+           meta: { title: '校区管理员', roles: ['2'] }
          },
          {
            path: "TeacherApporval",
            name: "TeacherApporval",
            component: TeacherApporval,
-           meta: { title: '在线批改老师', roles: ['1'] }
+           meta: { title: '在线批改老师', roles: ['2'] }
 
          },
          {
@@ -139,25 +87,73 @@ export const asyncRouterMap = [
            component: TeacherPay,
            meta: { title: '教师薪酬管理', roles: ['1'] }
          },
-        {
-          path: "SuperAdmin",
-          name: "SuperAdmin",
-          component: SuperAdmin,
-          meta: { title: '超级管理员', roles: ['1'] }
-        },
-        {
-          path: "CheckTeacherAudit",
-          name: "CheckTeacherAudit",
-          component: CheckTeacherAudit,
-          meta: { title: '批改老师注册审核', roles: ['1'] }
-        },
-        {
-          path: "CheckTeacherPay",
-          name: "CheckTeacherPay",
-          component: CheckTeacherPay,
-          meta: { title: '批改老师薪酬表', roles: ['1'] }
-        },
+         {
+           path: "*",
+           name: "找不到页面",
+           component: Error404
+         }
        ]
      },
+     {
+       path: "*",
+       name: "错误页面",
+       component: Error
+     }
+
+  ]
+export default new Router({
+  routes: constantRouterMap
+})
+
+// 异步挂载的路由
+// 动态需要根据权限加载的路由表
+export const asyncRouterMap = [
+    //   {
+    //    path: "/home",
+    //    component: Home,
+    //    children: [
+    //      {
+    //        path: "",
+    //        redirect: "SchoolManager"
+    //      },
+    //      {
+    //        path: "SchoolManager",
+    //        name: "SchoolManager",
+    //        component: SchoolManager,
+    //        meta: { title: '校区管理员', roles: ['2'] }
+    //      },
+    //      {
+    //        path: "TeacherApporval",
+    //        name: "TeacherApporval",
+    //        component: TeacherApporval,
+    //        meta: { title: '在线批改老师', roles: ['2'] }
+
+    //      },
+    //      {
+    //        path: "TeacherPay",
+    //        name: "TeacherPay",
+    //        component: TeacherPay,
+    //        meta: { title: '教师薪酬管理', roles: ['3'] }
+    //      },
+    //     {
+    //       path: "SuperAdmin",
+    //       name: "SuperAdmin",
+    //       component: SuperAdmin,
+    //       meta: { title: '超级管理员', roles: ['2'] }
+    //     },
+    //     {
+    //       path: "CheckTeacherAudit",
+    //       name: "CheckTeacherAudit",
+    //       component: CheckTeacherAudit,
+    //       meta: { title: '批改老师注册审核', roles: ['1'] }
+    //     },
+    //     {
+    //       path: "CheckTeacherPay",
+    //       name: "CheckTeacherPay",
+    //       component: CheckTeacherPay,
+    //       meta: { title: '批改老师薪酬表', roles: ['3'] }
+    //     },
+    //    ]
+    //  },
 ]
 

+ 4 - 4
src/store/getters.js

@@ -6,12 +6,12 @@ const getters = {
   routers: state => state.permission.routers,
   addRouters: state => state.permission.addRouters,
   roles: state => state.user.roles,
-  monitorTeacherList: state => state.user.monitorTeacherList,
-  TeacherHomeworkList: state => state.user.TeacherHomeworkList,
+  monitorTeacherList: state => state.user.monitorTeacherList || {},
+  TeacherHomeworkList: state => state.user.TeacherHomeworkList || {},
   TeacherAllotList: state => state.user.TeacherAllotList,
   TeacherAllotstatus: state => state.user.TeacherAllotstatus,
-  DayTeacherList: state => state.user.dayTeacherList,
-  MothTeacherList: state => state.user.mothTeacherList,
+  DayTeacherList: state => state.user.dayTeacherList || {},
+  MothTeacherList: state => state.user.mothTeacherList || {},
   UnallotHomeworkInfo: state => state.user.UnallotHomeworkList,
   GetTeacherDetail: state => state.user.GetTeacherDetail,
   GetStudentDetail: state => state.user.GetStudentDetail,

+ 16 - 12
src/store/modules/user.js

@@ -104,13 +104,19 @@ const user = {
                     Message.success('登录成功')
                    dispatch('GetInfo').then(res => { // 拉取用户信息
                         const roles = res.data.role 
-                        dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
-                          console.log('addrouters', getters.addRouters)
-                          router.addRoutes(getters.addRouters) // 动态添加可访问路由表
-                          console.log(router)
+                        if (roles == 1) {
                           router.push("/home");
-                          // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
-                        })
+                        }
+                        if (roles == 2) {
+                          router.push("/super");
+                        }
+                        // dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
+                        //   console.log('addrouters', getters.addRouters)
+                        //   router.addRoutes(getters.addRouters) // 动态添加可访问路由表
+                        //   console.log(router)
+                        //   router.push("/home");
+                        //   // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
+                        // })
                       }).catch(() => {
                         // dispatch('FedLogOut').then(() => {
                         //   Message.error('验证失败,请重新登录')
@@ -189,7 +195,6 @@ const user = {
       
       return new Promise((resolve, reject) => {
         axios.post(GetInfo, data).then((response = {}) => {
-          debugger
           const { data, code, msg } = response
           const { role, name, imgUrl } = data
           commit('SET_ROLES', role)
@@ -234,7 +239,7 @@ const user = {
       InfoWatchMoth({ commit, state }, data) {
         return new Promise((resolve, reject) => {
           axios.post(InfoWatchMoth, data).then(response => {
-            const data = response.data
+            const data = response.data || {}
             commit('SET_TEACHER_MOTH', data);
             resolve(response)
           }).catch(error => {
@@ -246,7 +251,7 @@ const user = {
      InfoWatchDay({ commit, state }, data) {
       return new Promise((resolve, reject) => {
         axios.post(InfoWatchDay, data).then(response => {
-          const data = response.data
+          const data = response.data || {}
           commit('SET_TEACHER_DAY', data);
           resolve(response)
         }).catch(error => {
@@ -308,7 +313,6 @@ const user = {
               axios.post(GetStudentDetail, data).then(response => {
                 const data = response.data || {}
                 commit('SET_GET_STUDENTDETAIL', data);
-                debugger
                 resolve(response)
               }).catch(error => {
                 reject(error)
@@ -333,7 +337,7 @@ const user = {
     SuperManagerList({ commit, state }, data) {
       return new Promise((resolve, reject) => {
         axios.post(SuperManagerList, data).then(response => {
-          const data = response.data
+          const data = response.data || {}
           commit('SET_SUPER_MANAGERLIST', data);
           resolve(response)
         }).catch(error => {
@@ -345,7 +349,7 @@ const user = {
     GetManagerDetail({ commit, state }, data) {
       return new Promise((resolve, reject) => {
         axios.post(GetManagerDetail, data).then(response => {
-          const data = response.data
+          const data = response.data || {}
           commit('SET_MANAGER_DETAIL', data);
           resolve(response)
         }).catch(error => {