getDataList.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { queryAllOrgan } from "../../api/dashboard"
  2. const loadings = {}
  3. const filterOrganId = [36, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 54, 55, 56]
  4. const state = {
  5. allBranch: []
  6. }
  7. const mutations = {
  8. commit_all_branch: (state, allBranch) => {
  9. state.allBranch = allBranch
  10. }
  11. }
  12. const actions = {
  13. async setAllBranch({
  14. commit,
  15. state
  16. }, force) {
  17. if ((!state.allBranch.length || force === true) && !loadings.commit_all_branch) {
  18. loadings.commit_all_branch = await queryAllOrgan()
  19. try {
  20. const res = await loadings.commit_all_branch
  21. const result = res.data
  22. let tempOrgan = []
  23. // 过滤不会显示的分部
  24. result.forEach(item => {
  25. if (!filterOrganId.includes(item.id)) {
  26. tempOrgan.push(item)
  27. }
  28. })
  29. commit('commit_all_branch', tempOrgan)
  30. } catch (error) {
  31. //
  32. }
  33. loadings.commit_all_branch = false
  34. }
  35. },
  36. }
  37. export default {
  38. namespaced: true,
  39. state,
  40. mutations,
  41. actions
  42. }