/* eslint-disable no-empty */ import { branchQueryPage } from '@/api/specialSetting' import { getSubject } from '@/api/buildTeam' /** * * 为避免重复请求全局参数,将需要使用的全局参数放到vuex中缓存 * * 使用: * * 按照需要直接使用 this.$store.dispatch('action', force: Bool 是否强制刷新) * * 直接从this.$store.state.name 中获取数据 */ export default { state: { branchs: [], subjects: [], }, mutations: { commit_branchs: (state, branchs) => { state.branchs = branchs }, commit_subjects: (state, subjects) => { state.subjects = subjects }, }, actions: { async setBranchs({ commit, state }, force) { if (!state.branchs.length || force === true) { try { const res = await branchQueryPage({rows: 9999}) commit('commit_branchs', res.data.rows) } catch (error) {} } }, async setSubject({ commit, state }, force) { if (!state.subjects.length || force === true) { try { const res = await getSubject({rows: 9999}) commit('commit_subjects', res.data.rows) } catch (error) {} } } } }