import { GET_UUIONID_TOKEN,GET_TOKEN,GET_VERIFICATION_CODE,GET_PHONE_TOKEN,GetInfo,InfoWatch,InfoWatchDay,
  InfoWatchMoth,TeacherHomeworkList,TeacherAllotList,
  TeacherAllot,UnallotHomeworkList,GetTeacherDetail,
  GetStudentDetail,GetManagerDetail,Downgrade,SuperManagerList,
  SuperApplyTeacherList,ApplyOperate,GetTeacherSalaryList,DealCorrectTeacher,
  GetAllotManagerList,AllotTeacherToManager,HomeworkRecoveryList,errorWarning,errorDetail,logout,
  CheckHomeworkStatus,FindSubjectCharts,GetRemindCount,GetKnowledgeTeacherSalaryList,AllTeacherInfoList,MonitorKnowTeacherList, MonitorKnowTeacherOneDayList,UnmatchHomeworkList,
  MonitorKnowTeacherOneMonthList
  } from '@/api'
  import { IMG_BASE_URL, APPOR_BASE_URL } from "@/config";
// import { getToken, setToken, removeToken } from '@/utils/auth'
import axios from '@/axios'
import router from "@/router"
import { Message } from 'element-ui'
const user = {
  state: {
    token:[],
    name: '',
    avatar: '',
    roles: [],
    monitorTeacherList:[],
    dayTeacherList:[],
    mothTeacherList:[],
    TeacherHomeworkList:[],
    TeacherAllotList:[],
    TeacherAllotstatus:false,
    UnallotHomeworkList:[],
    GetTeacherDetail:[],
    GetStudentDetail:[],
    getManagerList:[],
    getManagerDetail:[],
    applyTeacherList:[],
    getTeacherSalaryList:[],
    getTeacherIdStatus:"",
    getAllotManagerList:"",
    homeworkRecoveryList:[],
    BeforetoTeacherAllotCode:"",
    BeforetoTeacherstatues:"",
    errorWarningList:[],
    errorDetailList:[],
    pictureIndex:0,
    InfoTeacherstatues:"",
    GetTeacherstatues:"",
		getRemindCount:"",
    ApporingTeacherstatues:"",
    currtHomeworkStatus:"",
    FindSubjectCharts:[],
    FindSubjectmathCharts:[],
    FindSubjectEngCharts:[],
    AllFindSubjectEngCharts:[],
    GetKnowledgeTeacherSalaryList:[],
		AllTeacherInfoList:[]
  },

  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_NAME: (state, name) => {
      state.name = name
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
    SET_ROLES: (state, roles) => {
      state.roles = roles
    },
    SET_TEACHER: (state, monitorTeacherList) => {
      state.monitorTeacherList = monitorTeacherList
    },
    SET_TEACHER_DAY: (state, dayTeacherList) => {
      state.dayTeacherList = dayTeacherList
    },
    SET_TEACHER_MOTH: (state, mothTeacherList) => {
      state.mothTeacherList = mothTeacherList
    },
    SET_TEACHER_HOMELISt: (state, TeacherHomeworkList) => {
      state.TeacherHomeworkList = TeacherHomeworkList
    },
    SET_TEACHER_ALLOTIST: (state, TeacherAllotList) => {
      state.TeacherAllotList = TeacherAllotList
    },
    SET_ALLOTIST_STATUS: (state, TeacherAllotstatus) => {
      state.TeacherAllotstatus = TeacherAllotstatus
    },
    SET_UNALLOT_HONELIST: (state, UnallotHomeworkList) => {
      state.UnallotHomeworkList = UnallotHomeworkList
    },
    SET_GET_TEACHERDETAIL: (state, GetTeacherDetail) => {
      state.GetTeacherDetail = GetTeacherDetail
    },
    SET_GET_STUDENTDETAIL: (state, GetStudentDetail) => {
      state.GetStudentDetail = GetStudentDetail
    },
    SET_SUPER_MANAGERLIST:(state, getManagerList) => {
      state.getManagerList = getManagerList
    },
    SET_MANAGER_DETAIL:(state, getManagerDetail) => {
      state.getManagerDetail = getManagerDetail
    },
    SET_DOWNGRADE:(state, downgrade) => {
      state.downgrade = downgrade
    },
    SET_APPLY_TEACHER_LIST:(state, applyTeacherList) => {
      state.applyTeacherList = applyTeacherList
    },
    SET_APPLY_OPERATE:(state,applyOperate) => {
      state.applyOperate = applyOperate
    },
    SET_TEACHER_SALARY_LIST:(state,getTeacherSalaryList) => {
      state.getTeacherSalaryList = getTeacherSalaryList
    },
    SET_HOMEWORK_RECOVERY_LIST:(state,homeworkRecoveryList) => {
      state.homeworkRecoveryList = homeworkRecoveryList
    },
    SET_CLOSE_OR_OPENID:(state,getTeacherIdStatus) => {
      state.getTeacherIdStatus = getTeacherIdStatus
    },
    SET_MANAGERLIST_ALLOTIST:(state,getAllotManagerList) => {
      state.getAllotManagerList = getAllotManagerList
    },
    SET_GET_SUCCESS_CODE:(state,BeforetoTeacherAllotCode) => {
      state.BeforetoTeacherAllotCode = BeforetoTeacherAllotCode
    },
    SET_GET_SUCCESS_TEACHER:(state,BeforetoTeacherstatues) => {
      state.BeforetoTeacherstatues = BeforetoTeacherstatues
    },
    SET_GET_SUCCESS_TEACHERINFO_STUS:(state,InfoTeacherstatues) => {
      state.InfoTeacherstatues = InfoTeacherstatues
    },
    SET_APPORING_STATUS:(state,ApporingTeacherstatues) => {
      state.ApporingTeacherstatues = ApporingTeacherstatues
    },
    SET_GET_SUCCESS_MANAGER_DETAIL:(state,GetTeacherstatues) => {
      state.GetTeacherstatues = GetTeacherstatues
    },
    SET_ERROR_WARING:(state,errorWarningList) => {
      state.errorWarningList = errorWarningList
    },
		SET_GET_REMIND_COUNT:(state,getRemindCount) => {
		  state.getRemindCount = getRemindCount
		},
    SET_ERROR_DETAIL:(state,errorDetailList) => {
      // console.log(errorDetailList)
      state.errorDetailList = errorDetailList
    },
    SET_ERROR_INDEX:(state,pictureIndex) => {
      console.log(pictureIndex)
      state.pictureIndex = pictureIndex
    },
    SET_CURRT_HOMEWORK_STATUS:(state,currtHomeworkStatus) => {
      state.currtHomeworkStatus = currtHomeworkStatus
    },
    FIND_SUBJECT_CHARTS:(state,FindSubjectCharts) => {
      state.FindSubjectCharts = FindSubjectCharts
    },
    FIND_SUBJECTMATH_CHARTS:(state,FindSubjectmathCharts) => {
      state.FindSubjectmathCharts = FindSubjectmathCharts
    },
    FIND_SUBJECTENG_CHARTS:(state,FindSubjectEngCharts) => {
      state.FindSubjectEngCharts = FindSubjectEngCharts
    },
    FIND_AllJECTENG_CHARTS:(state,AllFindSubjectEngCharts) => {
      state.AllFindSubjectEngCharts = AllFindSubjectEngCharts
    },
    SET_UNALLOT_TEACHER_SALARY:(state,GetKnowledgeTeacherSalaryList) => {
      state.GetKnowledgeTeacherSalaryList = GetKnowledgeTeacherSalaryList
    },
		SET_ALL_TEACHER_INFO_LIST:(state,AllTeacherInfoList) => {
		  state.AllTeacherInfoList = AllTeacherInfoList
		},
  },

  actions: {
      //   unionid登录
      //  获取TOKEN
       UnionidLogin({ state, commit, dispatch }, data) {
        console.log(data);
        axios.Tokenpost(GET_UUIONID_TOKEN, data).then(res => {
          if (res && res.code == '999') {
            const data = res.data
            const accessToken = data.accessToken
            const unionid = localStorage.getItem("unionid")
            commit('SET_TOKEN', data);
            localStorage.setItem("accessToken",data.accessToken)
                   dispatch('GetInfo').then(res => { // 拉取用户信息
                        const roles = res.data.role
                        const isBanned = res.data.isBanned
                        const userId = res.data.userId
                        localStorage.setItem("userId",userId)
                        if (isBanned == 0) {
                          if (roles == 0) {
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid  +
                            "&state=" + 0);
                            Message.error('无用户角色，请先注册')
                          }
                          if (roles == 1) {
                            Message.success('在线批改老师角色登录成功')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                          }
                          if (roles == 2) {
                            Message.success('学习管理员角色登录成功')
                            router.push("/home");
                            // router.push({path: '/home', replace: true})
                          }
                          if (roles == 3) {
                            Message.success('超级管理员角色登录成功')
                            router.push("/super");
                            // router.push({path: '/super', replace: true})
                          }
                          if (roles == 4) {
                            Message.success('匹配知识点老师老师角色登录成功')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                          }
                          if (roles == 5) {
                            Message.success('质检员角色登录成功')
                            router.push("/Qualityinspector");
                          }
                        } if (isBanned == 1) {
                          localStorage.removeItem("accessToken");
                          Message.error('您已被封号')
                          window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                        }
                      }).catch(() => {
                        localStorage.removeItem("accessToken");
                          Message.error('用户信息验证失败,请重新登录')
                      })
          } else {
            Message.error('验证失败,请重新登录')
                    router.push("/");
          }
        })
      },
       // 手机号验证码登陆
         //  获取TOKEN
      PhoneCodeLogin({ state, commit, dispatch }, data) {
        console.log(data);
        axios.Tokenpost(GET_PHONE_TOKEN, data).then(res => {
          if (res && res.code == '999') {
            const data = res.data
            console.log("获取Code" + data)
            const accessToken = data.accessToken
            commit('SET_TOKEN', data);
            localStorage.setItem("accessToken",data.accessToken)
                   dispatch('GetInfo').then(res => { // 拉取用户信息
                    console.log("获取Code拉取用户信息" + res)
                        const roles = res.data.role
                        const userId = res.data.userId
                        const isBanned = res.data.isBanned
                        const unionid = res.data.unionid
                        localStorage.setItem("unionid",unionid)
                        localStorage.setItem("userId",userId)
                        if (isBanned == 0) {
                          if (roles == 0) {
                            Message.error('无用户角色，请先注册')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid +
                            "&state=" + 0);
                          }
                          if (roles == 1) {
                            Message.success('在线批改老师角色登录成功')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                          }
                          if (roles == 2) {
                            Message.success('学习管理员角色登录成功')
                            router.push("/home");
                            // router.push({path: '/home', replace: true})
                            
                          }
                          if (roles == 3) {
                            Message.success('超级管理员角色登录成功')
                            router.push("/super");
                            // router.push({path: '/super', replace: true})
                            
                          }
                          if (roles == 4) {
                            Message.success('匹配知识点老师老师角色登录成功')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                            
                          }
                          if (roles == 5) {
                            Message.success('质检员角色登录成功')
                            router.push("/Qualityinspector");
                          }
                        } if (isBanned == 1) {
                          localStorage.removeItem("accessToken");
                          Message.error('您已被封号')
                          window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                        }
                      }).catch(() => {
                        localStorage.removeItem("accessToken");
                          Message.error('用户信息验证失败,请重新登录')
                      })
          } else {
            Message.error('验证失败,请重新登录')
                    router.push("/");
          }
        })
      },
      // 微信授权登陆
       //获取TOKEN
      GET_TOKEN({ state, commit, dispatch }, data) {
        console.log(data);
        axios.Tokenpost(GET_TOKEN, data).then(res => {
          if (res && res.code == '999') {
            const data = res.data
            console.log("获取Code" + data)
            const accessToken = data.accessToken
            commit('SET_TOKEN', data);
            localStorage.setItem("accessToken",data.accessToken)
                   dispatch('GetInfo').then(res => { // 拉取用户信息
                    console.log("获取Code拉取用户信息" + res)
                        const roles = res.data.role
                        const userId = res.data.userId
                        const isBanned = res.data.isBanned
                        const unionid = res.data.unionid
                        localStorage.setItem("unionid",unionid)
                        localStorage.setItem("userId",userId)
                        if (isBanned == 0) {
                          if (roles == 0) {
                            Message.error('无用户角色，请先注册')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid +
                            "&state=" + 0);
                          }
                          if (roles == 1) {
                            Message.success('在线批改老师角色登录成功')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                          }
                          if (roles == 2) {
                            Message.success('学习管理员角色登录成功')
                            router.push("/home");
                            // router.push({path: '/home', replace: true})
                            
                          }
                          if (roles == 3) {
                            Message.success('超级管理员角色登录成功')
                            router.push("/super");
                            // router.push({path: '/super', replace: true})
                            
                          }
                          if (roles == 4) {
                            Message.success('匹配知识点老师老师角色登录成功')
                            localStorage.removeItem("accessToken");
                            window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                            
                          }
                          if (roles == 5) {
                            Message.success('质检员角色登录成功')
                            router.push("/Qualityinspector");
                          }
                        } if (isBanned == 1) {
                          localStorage.removeItem("accessToken");
                          Message.error('您已被封号')
                          window.open(APPOR_BASE_URL + '?unionid=' + unionid);
                        }
                      }).catch(() => {
                        localStorage.removeItem("accessToken");
                          Message.error('用户信息验证失败,请重新登录')
                      })
          } else {
            Message.error('验证失败,请重新登录')
                    router.push("/");
          }
        })
      },
      // 获取手机验证码
      GetVerficationCode({ commit, state }, data) {
        return new Promise((resolve, reject) => {
          axios.Tokenpost(GET_VERIFICATION_CODE, data).then((response = {}) => {
              if (response.code === '999'){
                Message.success(response.msg)
              }
            resolve(response)
          }).catch(error => {
            reject(error)
          })
        })
      },
    // 获取用户信息
    GetInfo({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(GetInfo, data).then((response = {}) => {
          const { data, code, msg } = response
          const { role, name, imgUrl } = data
          commit('SET_ROLES', role)
          commit('SET_NAME', name)
          commit('SET_AVATAR', imgUrl)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 校区管理员数据监控
    InfoWatch({ commit, state }, data) {
      // commit('SET_TEACHER', [])
      return new Promise((resolve, reject) => {
        axios.post(InfoWatch, data).then(response => {
          const data = response.data || {}
          commit('SET_TEACHER', data);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
     // 校区管理员数据监控知识点匹配老师
     InfoKonwTeacherWatch({ commit, state }, data) {
      // commit('SET_TEACHER', [])
      return new Promise((resolve, reject) => {
        axios.post(MonitorKnowTeacherList, data).then(response => {
          const data = response.data || {}
          commit('SET_TEACHER', data);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
      // 校区管理员当月数据
      InfoWatchMoth({ commit, state }, data) {
        commit('SET_TEACHER_MOTH', [])
        return new Promise((resolve, reject) => {
          axios.post(InfoWatchMoth, data).then(response => {
            const data = response.data || {}
            commit('SET_TEACHER_MOTH', data);
            resolve(response)
          }).catch(error => {
            reject(error)
          })
        })
      },
        // 校区管理员当月数据（匹配知识点老师）
        MonitorKnowTeacherOneMonthInfo({ commit, state }, data) {
          commit('SET_TEACHER_MOTH', [])
          return new Promise((resolve, reject) => {
            axios.post(MonitorKnowTeacherOneMonthList, data).then(response => {
              const data = response.data || {}
              commit('SET_TEACHER_MOTH', data);
              resolve(response)
            }).catch(error => {
              reject(error)
            })
          })
        },
     // 校区管理员当天数据
     InfoWatchDay({ commit, state }, data) {
      commit('SET_TEACHER_DAY', [])
      return new Promise((resolve, reject) => {
        axios.post(InfoWatchDay, data).then(response => {
          const data = response.data || {}
          commit('SET_TEACHER_DAY', data);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
     // 校区管理员当天数据（匹配知识点老师）
     MonitorKnowTeacherOneDayInfo({ commit, state }, data) {
      commit('SET_TEACHER_DAY', [])
      return new Promise((resolve, reject) => {
        axios.post(MonitorKnowTeacherOneDayList, data).then(response => {
          const data = response.data || {}
          commit('SET_TEACHER_DAY', data);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
     // 查看老师批改作业列表
    TeacherHomeworkList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(TeacherHomeworkList, data).then(response => {
          const data = response.data || {}
          commit('SET_TEACHER_HOMELISt', data);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
        // 质检当前作业状态
        CheckCurrHomeworkStatus({ commit, state }, data) {
          return new Promise((resolve, reject) => {
            axios.post(CheckHomeworkStatus, data).then(response => {
              const data = response.data || {}
              if (response.code === '999'){
                if (data.status == 3){
                  commit('SET_CURRT_HOMEWORK_STATUS',new Date());
                  resolve(response)
                }
                if (data.status == 1){
                  Message.error("当前作业还未批改，请手动刷新当前作业列表！")
                  resolve(response)
                }
                if (data.status == 2){
                  Message.error("当前作业正在批改中，请手动刷新当前作业列表！")
                  resolve(response)
                }
              }
              if (response.code === '000'){
                Message.error(response.msg)
                resolve(response)
              }
            }).catch(error => {
              reject(error)
            })
          })
        },
       // 查看可分配老师列表
       TeacherAllotList({ commit, state }, data) {
        return new Promise((resolve, reject) => {
          axios.post(TeacherAllotList, data).then(response => {
            const data = response.data || {}
            if (response.code === '999'){
              commit('SET_TEACHER_ALLOTIST', data);
              resolve(response)
            }
            if (response.code === '000'){
              Message.error(response.msg)
                commit('SET_APPORING_STATUS',new Date());
              resolve(response)
            }
            if (response.code === "") {
              Message.error("出了点小问题，噢噢。。。")
            }
          }).catch(error => {
            reject(error)
          })
        })
      },
       // 查看可分配小组列表
       GetAllotManagerList({ commit, state }, data) {
        return new Promise((resolve, reject) => {
          axios.post(GetAllotManagerList, data).then(response => {
            const data = response.data || {}
            commit('SET_MANAGERLIST_ALLOTIST', data);
            resolve(response)
          }).catch(error => {
            reject(error)
          })
        })
      },
          // 分配老师到管理员名下
          AllotTeacherToManager({ commit, state }, data) {
            return new Promise((resolve, reject) => {
              axios.post(AllotTeacherToManager, data).then(response => {
                const data = response || {}
                if (data.code === "999"){
                  // debugger
                  commit('SET_CLOSE_OR_OPENID', new Date());
                  Message.success('分配成功')
                }
                // resolve(response)
              }).catch(error => {
                reject(error)
              })
            })
          },
            // 管理员查看科目报表数据
      FindSubjectChartsLists({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(FindSubjectCharts, data).then((response = {}) => {
          const data = response.data.chartList || {}
          if (response.code === "999"){
            commit('FIND_AllJECTENG_CHARTS', data);
            commit('FIND_SUBJECT_CHARTS', data[0]);
            commit('FIND_SUBJECTMATH_CHARTS', data[1]);
            commit('FIND_SUBJECTENG_CHARTS', data[2]);
          }
        }).catch(error => {
          reject(error)
        })
      })
    },
    // GetKnowledgeTeacherSalaryList
    GetKnowledgeTeacherSalaryInfo({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(GetKnowledgeTeacherSalaryList, data).then(response => {
          const data = response.data || {}
          if (response.code === "999"){
            // debugger
            commit('SET_UNALLOT_TEACHER_SALARY', data);
          }
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
		// 老师资料表
		AllTeacherInfoList({ commit, state }, data) {
		  return new Promise((resolve, reject) => {
		    axios.post(AllTeacherInfoList, data).then(response => {
		      const data = response.data || {}
		      if (response.code === "999"){
		        // debugger
		        commit('SET_ALL_TEACHER_INFO_LIST', data);
		      }
		      resolve(response)
		    }).catch(error => {
		      reject(error)
		    })
		  })
		},

        // 未批改作业列表
        UnallotHomeworkList({ commit, state }, data) {
          return new Promise((resolve, reject) => {
            axios.post(UnallotHomeworkList, data).then(response => {
              const data = response.data || {}
              commit('SET_UNALLOT_HONELIST', data);
              resolve(response)
            }).catch(error => {
              reject(error)
            })
          })
        },
         // 未匹配作业列表
         UnmatchHomeworkList({ commit, state }, data) {
          return new Promise((resolve, reject) => {
            axios.post(UnmatchHomeworkList, data).then(response => {
              const data = response.data || {}
              commit('SET_UNALLOT_HONELIST', data);
              resolve(response)
            }).catch(error => {
              reject(error)
            })
          })
        },
           // 查看老师详情
           GetTeacherDetail({ commit, state }, data) {
            return new Promise((resolve, reject) => {
              axios.post(GetTeacherDetail, data).then(response => {
                const data = response || {}
                if (data.code === '999'){
                  commit('SET_GET_SUCCESS_TEACHERINFO_STUS',new Date());
                  commit('SET_GET_TEACHERDETAIL', data.data);
                  resolve(response)
                }
              }).catch(error => {
                reject(error)
              })
            })
          },
           // 查看学生详情
           GetStudentDetail({ commit, state }, data) {
            return new Promise((resolve, reject) => {
              axios.post(GetStudentDetail, data).then(response => {
                const data = response.data || {}
                commit('SET_GET_STUDENTDETAIL', data);
                resolve(response)
              }).catch(error => {
                reject(error)
              })
            })
          },
         // 分配老师
         toTeacherAllot({ commit, state }, data) {
          return new Promise((resolve, reject) => {
            axios.post(TeacherAllot, data).then(response => {
              const data = response || {}
              if (data.code === '999'){
                // debugger
                commit('SET_GET_SUCCESS_TEACHER',new Date());
                resolve(response)
                Message.success('分配成功')
              } else {
                Message.error(data.msg)
              }
            }).catch(error => {
              reject(error)
            })
          })
        },
            // 校区管理员去批改前分配老师
            BeforetoTeacherAllot({ commit, state }, data) {
              return new Promise((resolve, reject) => {
                axios.post(TeacherAllot, data).then(response => {
                  const data = response || {}
                  if (data.code === '999'){
                    commit('SET_GET_SUCCESS_CODE',new Date());
                    // Message.success('分配成功')
                  }
                  if (response.code === '000'){
                    Message.error(response.msg)
                      commit('SET_APPORING_STATUS',new Date());
                    resolve(response)
                  }
                }).catch(error => {
                  reject(error)
                })
              })
            },
    // 登出
    // 查看超级管理员校区列表
    SuperManagerList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(SuperManagerList, data).then(response => {
          const data = response.data || {}
          commit('SET_SUPER_MANAGERLIST', data);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 查看校区管理员详情
    GetManagerDetail({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(GetManagerDetail, data).then(response => {
          const data = response.data || {}
          // commit('SET_GET_SUCCESS_MANAGER_DETAIL',new Date());
          commit('SET_GET_SUCCESS_TEACHERINFO_STUS',new Date());
          commit('SET_MANAGER_DETAIL', data);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
      // 报错警告
      GeterrorWarning({ commit, state }, data) {
        return new Promise((resolve, reject) => {
          axios.post(errorWarning, data).then(response => {
            const data = response.data || {}
            commit('SET_ERROR_WARING', data);
            resolve(response)
          }).catch(error => {
            reject(error)
          })
        })
      },
        // 报错详情
        GeterrorDetail({ commit, state }, data) {
          return new Promise((resolve, reject) => {
            axios.post(errorDetail, data).then(response => {
              const data = response.data.list || {}
              // debugger
              commit('SET_ERROR_DETAIL', data);
               commit('SET_ERROR_INDEX', 0);
              resolve(response)
            }).catch(error => {
              reject(error)
            })
          })
        },
    // 处理在线批改老师（解封）
    OpenIdTeacher({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(DealCorrectTeacher, data).then(response => {
          const data = response || {}
          if (data.code === "999"){
            commit('SET_CLOSE_OR_OPENID', new Date());
            Message.success(data.msg)
          }
          else {
            Message.error("出错了")
          }
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
      // 处理在线批改老师（升级）
      RepushTeacher({ commit, state }, data) {
        return new Promise((resolve, reject) => {
          axios.post(DealCorrectTeacher, data).then(response => {
            const data = response || {}
            if (data.code === "999"){
              commit('SET_CLOSE_OR_OPENID', new Date());
              Message.success(data.msg)
            }
            else {
              Message.error("出错了")
            }
            resolve(response)
          }).catch(error => {
            reject(error)
          })
        })
      },
        // 处理在线批改老师（封号）
    CloseIdTeacher({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(DealCorrectTeacher, data).then(response => {
          const data = response || {}
          if (data.code === "999"){
            commit('SET_CLOSE_OR_OPENID', new Date());
            Message.success(data.msg)
          }
          else {
            Message.error("出错了")
          }
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
     // 校区管理员降级
     Downgrade({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(Downgrade, data).then(response => {
          const data = response.data
          commit('SET_DOWNGRADE',  new Date());
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    //查看申请批改老师列表
    SuperApplyTeacherList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(SuperApplyTeacherList, data).then(response => {
          const data = response || {}
          if (data.code === "999"){
            commit('SET_APPLY_TEACHER_LIST', data.data);
            commit('SET_GET_SUCCESS_TEACHERINFO_STUS',new Date());
          }
          else {
            Message.error("出错了")
          }
          // const data = response.data || { }
          // commit('SET_APPLY_TEACHER_LIST', data);

          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    //申请审批操作
    ApplyOperate({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(ApplyOperate, data).then(response => {
          // const data = response.data
          // commit('SET_APPLY_OPERATE', data);
          // debugger
          const data = response || {}
          if (data.code === "999"){
            commit('SET_GET_SUCCESS_MANAGER_DETAIL',new Date());
            commit('SET_CLOSE_OR_OPENID', new Date());
            Message.success(data.msg)
          }
          else {
            Message.error("出错了")
          }
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    //老师薪酬列表
    GetTeacherSalaryList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(GetTeacherSalaryList, data).then(response => {
          const data = response.data || { }
          commit('SET_TEACHER_SALARY_LIST', data);
          // debugger
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    //作业回收站列表
    HomeworkRecoveryList({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.post(HomeworkRecoveryList, data).then(response => {
          const data = response.data || { }
          commit('SET_HOMEWORK_RECOVERY_LIST', data);
          // debugger
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
		//获取提醒次数
		toTeacherAllotInfo({ commit, state }, data) {
			// debugger
		  return new Promise((resolve, reject) => {
		    axios.post(GetRemindCount, data).then(response => {
		      const data = response.data || { }
		      commit('SET_GET_REMIND_COUNT', data);
		      resolve(response)
		    }).catch(error => {
		      reject(error)
		    })
		  })
		},
    // 登出getTeacherSalaryList
    LogOut({ commit, state }, data) {
      return new Promise((resolve, reject) => {
        axios.Tokenpost(logout, data).then(response => {
          const data = response || {}
          if (data.code === "999"){
          localStorage.removeItem("accessToken");
          commit('SET_TOKEN', '')
          commit('SET_ROLES', [])
          Message.success('退出成功')
          router.push("/");
          }
          else {
            Message.error("出错了")
          }
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 前端 登出
    // FedLogOut({ commit }) {
    //   return new Promise(resolve => {
    //     commit('SET_TOKEN', '')
    //     removeToken()
    //     resolve()
    //   })
    // }
  }
}

export default user
