selects.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. /**
  7. *
  8. * 为避免重复请求全局参数,将需要使用的全局参数放到vuex中缓存
  9. *
  10. * 使用:
  11. *
  12. * 按照需要直接使用 this.$store.dispatch('action', force: Bool 是否强制刷新)
  13. *
  14. * 直接从this.$store.state.name 中获取数据
  15. */
  16. export default {
  17. state: {
  18. branchs: [],
  19. subjects: [],
  20. teachers: [],
  21. schools: [],
  22. vipGroupCategory: [],
  23. educations:[]
  24. },
  25. mutations: {
  26. commit_branchs: (state, branchs) => {
  27. state.branchs = branchs
  28. },
  29. commit_subjects: (state, subjects) => {
  30. state.subjects = subjects
  31. },
  32. commit_teachers: (state, teachers) => {
  33. state.teachers = teachers.map(teacher=>{
  34. return {
  35. ...teacher,
  36. id:teacher.id,
  37. userId:teacher.id,
  38. userName:teacher.realName,
  39. realName:teacher.realName
  40. }
  41. })
  42. },
  43. commit_schools: (state, schools) => {
  44. state.schools = schools
  45. },
  46. commit_vip_group_category: (state, vipGroupCategory) => {
  47. state.vipGroupCategory = vipGroupCategory
  48. },
  49. commit_educations:(state,educations)=>{
  50. state.educations = educations
  51. }
  52. },
  53. actions: {
  54. async setBranchs ({ commit, state }, force) {
  55. if (!state.branchs.length || force === true) {
  56. try {
  57. const res = await getEmployeeOrgan()
  58. commit('commit_branchs', res.data)
  59. } catch (error) { }
  60. }
  61. },
  62. async setSubjects ({ commit, state }, force) {
  63. if (!state.subjects.length || force === true) {
  64. try {
  65. const res = await getSubject({rows: 9999, tenantId: '1'})
  66. commit('commit_subjects', res.data)
  67. } catch (error) { }
  68. }
  69. },
  70. async setTeachers ({ commit, state }, force) {
  71. if (!state.teachers.length || force === true) {
  72. try {
  73. const res = await getTeacher()
  74. commit('commit_teachers', res.data)
  75. } catch (error) { }
  76. }
  77. },
  78. async setSchools ({ commit, state }, force) {
  79. if (!state.schools.length || force === true) {
  80. try {
  81. const res = await getSchool()
  82. commit('commit_schools', res.data)
  83. } catch (error) { }
  84. }
  85. },
  86. async setVipGroupCategory ({ commit, state }, force) {
  87. if (!state.vipGroupCategory.length || force === true) {
  88. try {
  89. const res = await vipGroupCategory()
  90. commit('commit_vip_group_category', res.data)
  91. } catch (error) { }
  92. }
  93. },
  94. async setEducations({commit,state},force){
  95. if (!state.educations.length || force === true) {
  96. try {
  97. const res = await findEducationUsers()
  98. commit('commit_educations', res.data)
  99. } catch (error) { }
  100. }
  101. }
  102. }
  103. }