import api from '@/api/api'

const getters = {
  sidebar: state => state.app.sidebar,
  size: state => state.app.size,
  device: state => state.app.device,
  visitedViews: state => state.tagsView.visitedViews,
  cachedViews: state => state.tagsView.cachedViews,
  token: state => state.user.token,
  avatar: state => state.user.avatar,
  name: state => state.user.name,
  introduction: state => state.user.introduction,
  userId: state => state.user.userId,
  roles: state => state.user.roles,
  permissions: state => state.user.permissions,
  permission_routes: state => state.permission.routes,
  topbarRouters: state => state.permission.topbarRouters,
  defaultRoutes: state => state.permission.defaultRoutes,
  sidebarRouters: state => state.permission.sidebarRouters,
  roleList(state) {
    if (!state.dict.roleList.length) {
      api.obtainRoleList({ status: 1 }).then(res => {
        state.dict.roleList = res.rows
      })
    }
    return state.dict.roleList
  },
  educationType(state) {
    if (!state.dict.educationType.length) {
      api.inquireCourseEducationType({ status: 1 }).then(res => {
        state.dict.educationType = res.rows
      })
    }
    return state.dict.educationType
  },
  projectType(state) {
    if (!state.dict.projectType.length) {
      api.inquireCourseProjectType({ status: 1 }).then(res => {
        state.dict.projectType = res.rows
      })
    }
    return state.dict.projectType
  },
  businessLevel(state) {
    if (!state.dict.businessLevel.length) {
      api.inquirebusinessList({ status: 1 }).then(res => {
        state.dict.businessLevel = res.rows
      })
    }
    return state.dict.businessLevel
  },
  sujectType(state) {
    if (!state.dict.sujectType.length) {
      api.inquireCourseSubject({ status: 1 }).then(res => {
        state.dict.sujectType = res.rows
      })
    }
    return state.dict.sujectType
  },
  Professional(state) {
    if (!state.dict.Professional.length) {
      api.inquireCourseMajor({ status: 1 }).then(res => {
        state.dict.Professional = res.rows
      })
    }
    return state.dict.Professional
  },
  schoolList(state) {
    if (!state.dict.schoolList.length) {
      api.inquireUserSchool({ status: 1 }).then(res => {
        state.dict.schoolList = res.rows
      })
    }
    return state.dict.schoolList
  },
  courseExamine(state) {
    if (!state.dict.courseExamine.length) {
      api.inquireCourseExamine({ status: 1 }).then(res => {
        state.dict.courseExamine = res.rows
      })
    }
    return state.dict.courseExamine
  },
  certificate(state) {
    if (!state.dict.certificate.length) {
      api.inquireBaseCertificate({ status: 1 }).then(res => {
        state.dict.certificate = res.rows
      })
    }
    return state.dict.courseExamine
  },
  labelList(state) {
    if (!state.dict.labelList.length) {
      api.inquireCourseLabelList({ status: 1 }).then(res => {
        state.dict.labelList = res.rows
      })
    }
    return state.dict.labelList
  },
  payList(state) {
    if (!state.dict.payList.length) {
      api.inquirepayaislelist({ status: 1 }).then(res => {
        state.dict.payList = res.rows
      })
    }
    return state.dict.payList
  },
  paypayee(state) {
    if (!state.dict.paypayee.length) {
      api.inquirepaypayee({ status: 1 }).then(res => {
        state.dict.paypayee = res.rows
      })
    }
    return state.dict.paypayee
  },
  paysource(state) {
    if (!state.dict.paysource.length) {
      api.inquirepaysource({ status: 1 }).then(res => {
        state.dict.paysource = res.rows
      })
    }
    return state.dict.paysource
  },
  payvisit(state) {
    if (!state.dict.payvisit.length) {
      api.inquirepayvisit({ status: 1 }).then(res => {
        state.dict.payvisit = res.rows
      })
    }
    return state.dict.payvisit
  },
  payserve(state) {
    if (!state.dict.payserve.length) {
      api.inquirepayserve({ status: 1 }).then(res => {
        state.dict.payserve = res.rows
      })
    }
    return state.dict.payserve
  },
  paysupply(state) {
    if (!state.dict.paysupply.length) {
      api.inquirepaysupply({ status: 1 }).then(res => {
        state.dict.paysupply = res.rows
      })
    }
    return state.dict.paysupply
  },
  paynature(state) {
    if (!state.dict.paynature.length) {
      api.inquirepaynature({ status: 1 }).then(res => {
        state.dict.paynature = res.rows
      })
    }
    return state.dict.paynature
  },
  paycost(state) {
    if (!state.dict.paycost.length) {
      api.inquirepaycost({ status: 1 }).then(res => {
        state.dict.paycost = res.rows
      })
    }
    return state.dict.paycost
  },
  paperexam(state) {
    if (!state.dict.paperexam.length) {
      api.inquirepaperexamList({ status: 1 }).then(res => {
        state.dict.paperexam = res.rows
      })
    }
    return state.dict.paperexam
  },
  areas(state) {
    if (!state.dict.areas.length) {
      api.inquireapplyAreas({ status: 1, areaType: 1 }).then(res => {
        state.dict.areas = res.rows
      })
    }
    return state.dict.areas
  },
  cityList(state) {
    if (!state.dict.cityList.length) {
      api.inquireapplyCityList({ status: 1, areaType: 2 }).then(res => {
        state.dict.cityList = res.rows
      })
    }
    return state.dict.cityList
  },

}
export default getters
