mall相关vuex从dict抽出,独立

master
zhaochencheng 3 years ago
parent ab42544586
commit 6802b1991d

@ -16,7 +16,7 @@ const getters = {
sidebarRouters:state => state.permission.sidebarRouters, sidebarRouters:state => state.permission.sidebarRouters,
dictMap: state => state.dict.dictMap, dictMap: state => state.dict.dictMap,
productCategories: state => state.dict.productCategories, productCategories: state => state.mall.productCategories,
brandList: state => state.dict.brandList, brandList: state => state.mall.brandList,
} }
export default getters export default getters

@ -7,6 +7,7 @@ import permission from './modules/permission'
import settings from './modules/settings' import settings from './modules/settings'
import getters from './getters' import getters from './getters'
import dict from "@/store/modules/dict"; import dict from "@/store/modules/dict";
import mall from "@/store/modules/mall";
Vue.use(Vuex) Vue.use(Vuex)
@ -17,7 +18,8 @@ const store = new Vuex.Store({
tagsView, tagsView,
permission, permission,
settings, settings,
dict dict,
mall
}, },
getters getters
}) })

@ -1,25 +1,16 @@
import {allByTypes} from "@/api/system/dict/data"; import {allByTypes} from "@/api/system/dict/data";
import {dict_types} from "@/config/business"; import {dict_types} from "@/config/business";
import {listPmsProductCategory} from "@/api/pms/productCategory";
import {allBrand} from "@/api/pms/brand";
const dict = { const dict = {
state: { state: {
dictMap: {}, dictMap: {},
productCategories: [],
brandList: []
}, },
mutations: { mutations: {
SET_DICT_MAP: (state, map) => { SET_DICT_MAP: (state, map) => {
state.dictMap = map state.dictMap = map
}, },
SET_PRODUCT_CATEGORIES: (state, value) => {
state.productCategories = value
},
SET_BRAND_LIST: (state, value) => {
state.brandList = value
},
}, },
actions: { actions: {
loadDictionaries({ commit, state }, force = false) { loadDictionaries({ commit, state }, force = false) {
@ -41,22 +32,6 @@ const dict = {
commit('SET_DICT_MAP', map) 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);
})
},
} }
} }

@ -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
}

@ -24,7 +24,7 @@ export default {
} }
}, },
created() { created() {
this.$store.dispatch('loadBrandList') this.$store.dispatch('mall/loadBrandList')
} }
} }
</script> </script>

@ -55,7 +55,7 @@ export default {
} }
}, },
created() { created() {
this.$store.dispatch('loadProductCategories') this.$store.dispatch('mall/loadProductCategories')
} }
} }
</script> </script>

@ -1,6 +1,10 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium" class="ry_form"> <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium" class="ry_form">
<el-form-item label="上架状态" prop="publishStatus">
<DictRadio v-model="queryParams.publishStatus" @change="handleQuery" size="small"
:radioData="dict.type.pms_publish_status" :showAll="'all'"/>
</el-form-item>
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
@ -37,12 +41,6 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="上架状态" prop="publishStatus">
<el-select v-model="queryParams.publishStatus" placeholder="请选择上架状态0->下架1->上架" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item class="flex_one tr"> <el-form-item class="flex_one tr">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -105,6 +103,7 @@ import {delPmsProduct, listPmsProduct} from "@/api/pms/product";
export default { export default {
name: "PmsProduct", name: "PmsProduct",
dicts: ['pms_publish_status'],
data() { data() {
return { return {
// //

@ -241,7 +241,7 @@ export default {
}); });
} }
p.then(() => { p.then(() => {
this.$store.dispatch('loadProductCategories', true) this.$store.dispatch('mall/loadProductCategories', true)
}) })
} }
}); });

Loading…
Cancel
Save