123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /* eslint-disable no-empty */
- // import { branchQueryPage } from '@/api/specialSetting'
- import { getSubject, getTeacher,findEducationUsers,getEmployeeOrgan } from '@/api/buildTeam'
- import { getSchool } from '@/api/systemManage'
- import { vipGroupCategory } from "@/api/vipSeting"
- import { findTechnician } from '@/api/repairManager'
- const loadings = {}
- /**
- *
- * 为避免重复请求全局参数,将需要使用的全局参数放到vuex中缓存
- *
- * 使用:
- *
- * 按照需要直接使用 this.$store.dispatch('action', force: Bool 是否强制刷新)
- *
- * 直接从this.$store.state.name 中获取数据
- */
- export default {
- state: {
- branchs: [],
- subjects: [],
- teachers: [],
- schools: [],
- vipGroupCategory: [],
- educations:[],
- technician: []
- },
- mutations: {
- commit_branchs: (state, branchs) => {
- state.branchs = branchs
- },
- commit_subjects: (state, subjects) => {
- state.subjects = subjects
- },
- commit_teachers: (state, teachers) => {
- state.teachers = teachers.map(teacher=>{
- return {
- ...teacher,
- id:teacher.id,
- userId:teacher.id,
- userName:teacher.realName,
- realName:teacher.realName
- }
- })
- },
- commit_schools: (state, schools) => {
- state.schools = schools
- },
- commit_vip_group_category: (state, vipGroupCategory) => {
- state.vipGroupCategory = vipGroupCategory
- },
- commit_educations: (state, educations)=>{
- state.educations = educations
- },
- commit_technician: (state, technician) => {
- state.technician = technician
- }
- },
- actions: {
- async setBranchs ({ commit, state }, force) {
- if ((!state.branchs.length || force === true) && !loadings.commit_branchs) {
- loadings.commit_branchs = true
- try {
- state.branchsLoading = true
- const res = await getEmployeeOrgan()
- commit('commit_branchs', res.data)
- } catch (error) { }
- loadings.commit_branchs = false
- }
- },
- async setSubjects ({ commit, state }, force) {
- if ((!state.subjects.length || force === true) && !loadings.commit_subjects) {
- loadings.commit_subjects = true
- try {
- state.subjectsLoading = true
- const res = await getSubject({rows: 9999, tenantId: '1'})
- commit('commit_subjects', res.data)
- } catch (error) { }
- loadings.commit_subjects = false
- }
- },
- async setTeachers ({ commit, state }, force) {
- if ((!state.teachers.length || force === true) && !loadings.commit_teachers) {
- loadings.commit_teachers = true
- try {
- state.teachersLoading =true
- const res = await getTeacher()
- commit('commit_teachers', res.data)
- } catch (error) { }
- loadings.commit_teachers = false
- }
- },
- async setSchools ({ commit, state }, force) {
- if ((!state.schools.length || force === true) && !loadings.commit_schools) {
- loadings.commit_schools = true
- try {
- state.schoolsLoading = true
- const res = await getSchool()
- commit('commit_schools', res.data)
- } catch (error) { }
- loadings.commit_schools = false
- }
- },
- async setVipGroupCategory ({ commit, state }, force) {
- if ((!state.vipGroupCategory.length || force === true) && !loadings.commit_vip_group_category) {
- loadings.commit_vip_group_category = true
- try {
- state.vipGroupCategoryLoading = true
- const res = await vipGroupCategory()
- commit('commit_vip_group_category', res.data)
- } catch (error) { }
- loadings.commit_vip_group_category = false
- }
- },
- async setEducations({commit,state},force){
- if ((!state.educations.length || force === true) && !loadings.commit_educations) {
- loadings.commit_educations = true
- try {
- const res = await findEducationUsers()
- commit('commit_educations', res.data)
- } catch (error) { }
- loadings.commit_educations = false
- }
- },
- async setTechnician({commit,state},force){
- if ((!state.educations.length || force === true) && !loadings.commit_technician) {
- loadings.commit_technician = true
- try {
- const res = await findTechnician()
- commit('commit_technician', res.data)
- } catch (error) {}
- loadings.commit_technician = false
- }
- }
- }
- }
|