Commit 5519c273 by 姜雷

修改分离组件store

parent 6ec36260
import { mapGetters, mapActions } from 'vuex';
import store from './store'; import store from './store';
export default { export default {
...@@ -7,8 +6,13 @@ export default { ...@@ -7,8 +6,13 @@ export default {
type: Number, type: Number,
}, },
}, },
data() {
return {
storeIndex: 0,
};
},
created() { created() {
store.install(this.$store); this.storeIndex = store.install(this.$store);
}, },
mounted() { mounted() {
if (this.dashboardArea && !this.dashboardArea.length) { if (this.dashboardArea && !this.dashboardArea.length) {
...@@ -25,10 +29,19 @@ export default { ...@@ -25,10 +29,19 @@ export default {
}, },
}, },
computed: { computed: {
...mapGetters('dashboardArea', ['dashboardArea']), dashboardArea() {
return this.$store.getters[
`dashboardArea${this.storeIndex}/dashboardArea`
];
},
}, },
methods: { methods: {
...mapActions('dashboardArea', ['fetchDashboardAreaList']), fetchDashboardAreaList(entity) {
return this.$store.dispatch(
`dashboardArea${this.storeIndex}/fetchDashboardAreaList`,
entity
);
},
getAreaName(id) { getAreaName(id) {
let item = this.dashboardArea.find(area => area.id === id); let item = this.dashboardArea.find(area => area.id === id);
if (item) { if (item) {
......
import areaStroe from './areaStore'; import areaStroe from './areaStore';
let index = 0;
export default { export default {
install(store) { install(store) {
if (!store.state.base) { if (!store.state.base) {
...@@ -7,11 +9,15 @@ export default { ...@@ -7,11 +9,15 @@ export default {
state: {}, state: {},
}); });
} }
if (!store.state.base.dashboardArea) { if (!store.state.base['dashboardArea' + index]) {
store.registerModule(['base', 'dashboardArea'], areaStroe); store.registerModule(['base', 'dashboardArea' + index], areaStroe);
} else {
index++;
store.registerModule(['base', 'dashboardArea' + index], areaStroe);
} }
return index;
}, },
uninstall(store) { uninstall(store) {
store.unregisterModule(['base', 'dashboardArea']); store.unregisterModule(['base', 'dashboardArea' + index]);
}, },
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment