import { listCategory } from '@/api/wms/category'; const state = { categoryList: [] }; const mutations = { SET_CATEGORY_LIST(state, list) { state.categoryList = list; } }; const actions = { getCategoryList({ state, commit }) { if (state.categoryList.length > 0) { return Promise.resolve(state.categoryList); } return listCategory().then(res => { commit('SET_CATEGORY_LIST', res.rows || []); return res.rows || []; }); } }; export default { namespaced: true, state, mutations, actions };