diff --git a/src/store/getters.js b/src/store/getters.js index 2e891cd..a013ad8 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -16,7 +16,7 @@ const getters = { sidebarRouters:state => state.permission.sidebarRouters, dictMap: state => state.dict.dictMap, - productCategories: state => state.dict.productCategories, - brandList: state => state.dict.brandList, + productCategories: state => state.mall.productCategories, + brandList: state => state.mall.brandList, } export default getters diff --git a/src/store/index.js b/src/store/index.js index a289862..635eb72 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,6 +7,7 @@ import permission from './modules/permission' import settings from './modules/settings' import getters from './getters' import dict from "@/store/modules/dict"; +import mall from "@/store/modules/mall"; Vue.use(Vuex) @@ -17,7 +18,8 @@ const store = new Vuex.Store({ tagsView, permission, settings, - dict + dict, + mall }, getters }) diff --git a/src/store/modules/dict.js b/src/store/modules/dict.js index ebf2453..87086ef 100644 --- a/src/store/modules/dict.js +++ b/src/store/modules/dict.js @@ -1,25 +1,16 @@ import {allByTypes} from "@/api/system/dict/data"; import {dict_types} from "@/config/business"; -import {listPmsProductCategory} from "@/api/pms/productCategory"; -import {allBrand} from "@/api/pms/brand"; + const dict = { state: { dictMap: {}, - productCategories: [], - brandList: [] }, mutations: { SET_DICT_MAP: (state, map) => { state.dictMap = map }, - SET_PRODUCT_CATEGORIES: (state, value) => { - state.productCategories = value - }, - SET_BRAND_LIST: (state, value) => { - state.brandList = value - }, }, actions: { loadDictionaries({ commit, state }, force = false) { @@ -41,22 +32,6 @@ const dict = { commit('SET_DICT_MAP', map) }) }, - loadProductCategories({ commit, state }, force = false) { - if (!force && state.productCategories.length > 0) { - return Promise.resolve(); - } - return listPmsProductCategory({}).then(res => { - commit('SET_PRODUCT_CATEGORIES', res); - }) - }, - loadBrandList({ commit, state }, force = false) { - if (!force && state.brandList.length > 0) { - return Promise.resolve(); - } - return allBrand({}).then(res => { - commit('SET_BRAND_LIST', res); - }) - }, } } diff --git a/src/store/modules/mall.js b/src/store/modules/mall.js new file mode 100644 index 0000000..f7e468f --- /dev/null +++ b/src/store/modules/mall.js @@ -0,0 +1,40 @@ +import {listPmsProductCategory} from "@/api/pms/productCategory"; +import {allBrand} from "@/api/pms/brand"; + +const state = { + productCategories: [], + brandList: [] +} +const mutations = { + SET_PRODUCT_CATEGORIES: (state, value) => { + state.productCategories = value + }, + SET_BRAND_LIST: (state, value) => { + state.brandList = value + }, +} +const actions = { + loadProductCategories({ commit, state }, force = false) { + if (!force && state.productCategories.length > 0) { + return Promise.resolve(); + } + return listPmsProductCategory({}).then(res => { + commit('SET_PRODUCT_CATEGORIES', res); + }) + }, + loadBrandList({ commit, state }, force = false) { + if (!force && state.brandList.length > 0) { + return Promise.resolve(); + } + return allBrand({}).then(res => { + commit('SET_BRAND_LIST', res); + }) + }, + +} +export default { + namespaced: true, + state, + mutations, + actions +} \ No newline at end of file diff --git a/src/views/components/BrandSelect.vue b/src/views/components/BrandSelect.vue index 03b1be9..7e06144 100644 --- a/src/views/components/BrandSelect.vue +++ b/src/views/components/BrandSelect.vue @@ -24,7 +24,7 @@ export default { } }, created() { - this.$store.dispatch('loadBrandList') + this.$store.dispatch('mall/loadBrandList') } } diff --git a/src/views/components/ProdCategory.vue b/src/views/components/ProdCategory.vue index 9fd7ef9..726ffbf 100644 --- a/src/views/components/ProdCategory.vue +++ b/src/views/components/ProdCategory.vue @@ -55,7 +55,7 @@ export default { } }, created() { - this.$store.dispatch('loadProductCategories') + this.$store.dispatch('mall/loadProductCategories') } } diff --git a/src/views/pms/product/index.vue b/src/views/pms/product/index.vue index 0686c10..a7ac6f6 100644 --- a/src/views/pms/product/index.vue +++ b/src/views/pms/product/index.vue @@ -1,6 +1,10 @@