import {getDicts} from "@/api/dict/data"; import {list as getSubjectList} from "@/api/webApi/subject"; import {list as getKnowledgeTree} from "@/api/webApi/knowledge"; import {ieVideoKnowledge, ieVideoSubjects, videoList} from "@/api/webApi/webVideo"; import {getEquivalentScore, yfydList, yfydLocations, yfydModes, yfydYears} from "@/api/webApi/webQue"; import {getVoluntaryData} from "@/api/webApi/volunteer"; import {getAllMajor, getMajorByName} from "@/api/webApi/collegemajor"; import {fillTreeChildCount, fillTreeParentBridge} from "@/utils/tree-helper"; import {getSizeOfObject} from "@/utils"; export const cacheActions = { getDicts: { type: Symbol('GET_DICTS'), handler: async function (type) { const {data} = await getDicts(type) return data } }, getSubjectList: { type: Symbol('GET_SUBJECT_LIST'), handler: async () => { const {rows} = await getSubjectList() return rows } }, getKnowledgeTree: { type: Symbol("GET_KNOWLEDGE_TREE"), handler: async (params) => { const {data} = await getKnowledgeTree(params) return data } }, getVideoSubjects: { type: Symbol('GET_VIDEO_SUBJECTS'), handler: async () => { const {rows} = await ieVideoSubjects({type: 1}) return rows } }, getVideoKnowledge: { type: Symbol('GET_VIDEO_KNOWLEDGE'), handler: async (params) => { return await ieVideoKnowledge(params) } }, getVideoOfKnowledge: { type: Symbol('GET_VIDEO_OF_KNOWLEDGE'), handler: async (params) => { return await videoList(params) } }, // voluntary data getVoluntaryData: async (params) => { const {data} = await getVoluntaryData(params) return data }, // 一分一段 getSectionLocations: async (params) => { const {rows} = await yfydLocations(params) // 用于mx-condition时,包一层方便控制 return rows.map(l => ({text: l, value: l})) }, getSectionYears: async (params) => { const {rows} = await yfydYears(params) // 用于mx-condition时,包一层方便控制 return rows.map(y => ({text: y, value: y})) }, getSectionModes: async (params) => { const {rows} = await yfydModes(params) return rows }, getSectionList: async (params) => { return await yfydList(params) }, getEquivalentScore: async (params) => { return await getEquivalentScore(params) }, // 专业树 getMajorTree: { type: Symbol('GET_ALL_MAJORS'), handler: async (payload) => { const api = payload?.name ? getMajorByName : getAllMajor const {data} = await api(payload) const dataSize = getSizeOfObject(data) // add parent bridge to tree nodes fillTreeParentBridge(data) // fill childCount fillTreeChildCount(data) return {data, dataSize} } } }