selects.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. state.branchsLoading = true
  65. const res = await getEmployeeOrgan()
  66. commit('commit_branchs', res.data)
  67. } catch (error) { }
  68. loadings.commit_branchs = false
  69. }
  70. },
  71. async setSubjects ({ commit, state }, force) {
  72. if ((!state.subjects.length || force === true) && !loadings.commit_subjects) {
  73. loadings.commit_subjects = true
  74. try {
  75. state.subjectsLoading = true
  76. const res = await getSubject({rows: 9999, tenantId: '1'})
  77. commit('commit_subjects', res.data)
  78. } catch (error) { }
  79. loadings.commit_subjects = false
  80. }
  81. },
  82. async setTeachers ({ commit, state }, force) {
  83. if ((!state.teachers.length || force === true) && !loadings.commit_teachers) {
  84. loadings.commit_teachers = true
  85. try {
  86. state.teachersLoading =true
  87. const res = await getTeacher()
  88. commit('commit_teachers', res.data)
  89. } catch (error) { }
  90. loadings.commit_teachers = false
  91. }
  92. },
  93. async setSchools ({ commit, state }, force) {
  94. if ((!state.schools.length || force === true) && !loadings.commit_schools) {
  95. loadings.commit_schools = true
  96. try {
  97. state.schoolsLoading = true
  98. const res = await getSchool()
  99. commit('commit_schools', res.data)
  100. } catch (error) { }
  101. loadings.commit_schools = false
  102. }
  103. },
  104. async setVipGroupCategory ({ commit, state }, force) {
  105. if ((!state.vipGroupCategory.length || force === true) && !loadings.commit_vip_group_category) {
  106. loadings.commit_vip_group_category = true
  107. try {
  108. state.vipGroupCategoryLoading = true
  109. const res = await vipGroupCategory()
  110. commit('commit_vip_group_category', res.data)
  111. } catch (error) { }
  112. loadings.commit_vip_group_category = false
  113. }
  114. },
  115. async setEducations({commit,state},force){
  116. if ((!state.educations.length || force === true) && !loadings.commit_educations) {
  117. loadings.commit_educations = true
  118. try {
  119. const res = await findEducationUsers()
  120. commit('commit_educations', res.data)
  121. } catch (error) { }
  122. loadings.commit_educations = false
  123. }
  124. },
  125. async setTechnician({commit,state},force){
  126. if ((!state.educations.length || force === true) && !loadings.commit_technician) {
  127. loadings.commit_technician = true
  128. try {
  129. const res = await findTechnician()
  130. commit('commit_technician', res.data)
  131. } catch (error) {}
  132. loadings.commit_technician = false
  133. }
  134. }
  135. }
  136. }