/* 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 } } } }