defineCacheActions.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import {getDicts} from "@/api/dict/data";
  2. import {list as getSubjectList} from "@/api/webApi/subject";
  3. import {list as getKnowledgeTree} from "@/api/webApi/knowledge";
  4. import {ieVideoKnowledge, ieVideoSubjects, videoList} from "@/api/webApi/webVideo";
  5. import {getEquivalentScore, yfydList, yfydLocations, yfydModes, yfydYears} from "@/api/webApi/webQue";
  6. import {getVoluntaryData} from "@/api/webApi/volunteer";
  7. import {getAllMajor, getMajorByName} from "@/api/webApi/collegemajor";
  8. import {fillTreeChildCount, fillTreeParentBridge} from "@/utils/tree-helper";
  9. import {getSizeOfObject} from "@/utils";
  10. export const cacheActions = {
  11. getDicts: {
  12. type: Symbol('GET_DICTS'),
  13. handler: async function (type) {
  14. const {data} = await getDicts(type)
  15. return data
  16. }
  17. },
  18. getSubjectList: {
  19. type: Symbol('GET_SUBJECT_LIST'),
  20. handler: async () => {
  21. const {rows} = await getSubjectList()
  22. return rows
  23. }
  24. },
  25. getKnowledgeTree: {
  26. type: Symbol("GET_KNOWLEDGE_TREE"),
  27. handler: async (params) => {
  28. const {data} = await getKnowledgeTree(params)
  29. return data
  30. }
  31. },
  32. getVideoSubjects: {
  33. type: Symbol('GET_VIDEO_SUBJECTS'),
  34. handler: async () => {
  35. const {rows} = await ieVideoSubjects({type: 1})
  36. return rows
  37. }
  38. },
  39. getVideoKnowledge: {
  40. type: Symbol('GET_VIDEO_KNOWLEDGE'),
  41. handler: async (params) => {
  42. return await ieVideoKnowledge(params)
  43. }
  44. },
  45. getVideoOfKnowledge: {
  46. type: Symbol('GET_VIDEO_OF_KNOWLEDGE'),
  47. handler: async (params) => {
  48. return await videoList(params)
  49. }
  50. },
  51. // voluntary data
  52. getVoluntaryData: async (params) => {
  53. const {data} = await getVoluntaryData(params)
  54. return data
  55. },
  56. // 一分一段
  57. getSectionLocations: async (params) => {
  58. const {rows} = await yfydLocations(params)
  59. // 用于mx-condition时,包一层方便控制
  60. return rows.map(l => ({text: l, value: l}))
  61. },
  62. getSectionYears: async (params) => {
  63. const {rows} = await yfydYears(params)
  64. // 用于mx-condition时,包一层方便控制
  65. return rows.map(y => ({text: y, value: y}))
  66. },
  67. getSectionModes: async (params) => {
  68. const {rows} = await yfydModes(params)
  69. return rows
  70. },
  71. getSectionList: async (params) => {
  72. return await yfydList(params)
  73. },
  74. getEquivalentScore: async (params) => {
  75. return await getEquivalentScore(params)
  76. },
  77. // 专业树
  78. getMajorTree: {
  79. type: Symbol('GET_ALL_MAJORS'),
  80. handler: async (payload) => {
  81. const api = payload?.name ? getMajorByName : getAllMajor
  82. const {data} = await api(payload)
  83. const dataSize = getSizeOfObject(data)
  84. // add parent bridge to tree nodes
  85. fillTreeParentBridge(data)
  86. // fill childCount
  87. fillTreeChildCount(data)
  88. return {data, dataSize}
  89. }
  90. }
  91. }