selects.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* eslint-disable no-empty */
  2. // import { branchQueryPage } from '@/api/specialSetting'
  3. import { getSubject, getTeacher,findEducationUsers,getEmployeeOrgan } from '@/api/buildTeam'
  4. import { getSchool } from '@/api/systemManage'
  5. import { vipGroupCategory } from "@/api/vipSeting"
  6. import { findTechnician } from '@/api/repairManager'
  7. const loadings = {}
  8. /**
  9. *
  10. * 为避免重复请求全局参数,将需要使用的全局参数放到vuex中缓存
  11. *
  12. * 使用:
  13. *
  14. * 按照需要直接使用 this.$store.dispatch('action', force: Bool 是否强制刷新)
  15. *
  16. * 直接从this.$store.state.name 中获取数据
  17. */
  18. export default {
  19. state: {
  20. branchs: [],
  21. subjects: [],
  22. teachers: [],
  23. schools: [],
  24. vipGroupCategory: [],
  25. educations:[],
  26. technician: []
  27. },
  28. mutations: {
  29. commit_branchs: (state, branchs) => {
  30. state.branchs = branchs
  31. },
  32. commit_subjects: (state, subjects) => {
  33. state.subjects = subjects
  34. },
  35. commit_teachers: (state, teachers) => {
  36. state.teachers = teachers.map(teacher=>{
  37. return {
  38. ...teacher,
  39. id:teacher.id,
  40. userId:teacher.id,
  41. userName:teacher.realName,
  42. realName:teacher.realName
  43. }
  44. })
  45. },
  46. commit_schools: (state, schools) => {
  47. state.schools = schools
  48. },
  49. commit_vip_group_category: (state, vipGroupCategory) => {
  50. state.vipGroupCategory = vipGroupCategory
  51. },
  52. commit_educations: (state, educations)=>{
  53. state.educations = educations
  54. },
  55. commit_technician: (state, technician) => {
  56. state.technician = technician
  57. }
  58. },
  59. actions: {
  60. async setBranchs ({ commit, state }, force) {
  61. if ((!state.branchs.length || force === true) && !loadings.commit_branchs) {
  62. loadings.commit_branchs = true
  63. try {
  64. const res = await getEmployeeOrgan()
  65. commit('commit_branchs', res.data)
  66. } catch (error) { }
  67. loadings.commit_branchs = false
  68. }
  69. },
  70. async setSubjects ({ commit, state }, force) {
  71. if ((!state.subjects.length || force === true) && !loadings.commit_subjects) {
  72. loadings.commit_subjects = true
  73. try {
  74. const res = await getSubject({rows: 9999, tenantId: '1'})
  75. commit('commit_subjects', res.data)
  76. } catch (error) { }
  77. loadings.commit_subjects = false
  78. }
  79. },
  80. async setTeachers ({ commit, state }, force) {
  81. if ((!state.teachers.length || force === true) && !loadings.commit_teachers) {
  82. loadings.commit_teachers = true
  83. try {
  84. const res = await getTeacher()
  85. commit('commit_teachers', res.data)
  86. } catch (error) { }
  87. loadings.commit_teachers = false
  88. }
  89. },
  90. async setSchools ({ commit, state }, force) {
  91. if ((!state.schools.length || force === true) && !loadings.commit_schools) {
  92. loadings.commit_schools = true
  93. try {
  94. const res = await getSchool()
  95. commit('commit_schools', res.data)
  96. } catch (error) { }
  97. loadings.commit_schools = false
  98. }
  99. },
  100. async setVipGroupCategory ({ commit, state }, force) {
  101. if ((!state.vipGroupCategory.length || force === true) && !loadings.commit_vip_group_category) {
  102. loadings.commit_vip_group_category = true
  103. try {
  104. const res = await vipGroupCategory()
  105. commit('commit_vip_group_category', res.data)
  106. } catch (error) { }
  107. loadings.commit_vip_group_category = false
  108. }
  109. },
  110. async setEducations({commit,state},force){
  111. if ((!state.educations.length || force === true) && !loadings.commit_educations) {
  112. loadings.commit_educations = true
  113. try {
  114. const res = await findEducationUsers()
  115. commit('commit_educations', res.data)
  116. } catch (error) { }
  117. loadings.commit_educations = false
  118. }
  119. },
  120. async setTechnician({commit,state},force){
  121. if ((!state.educations.length || force === true) && !loadings.commit_technician) {
  122. loadings.commit_technician = true
  123. try {
  124. const res = await findTechnician()
  125. commit('commit_technician', res.data)
  126. } catch (error) {}
  127. loadings.commit_technician = false
  128. }
  129. }
  130. }
  131. }