Commit 5519c273 by 姜雷

修改分离组件store

parent 6ec36260
import { mapGetters, mapActions } from 'vuex';
import store from './store';
export default {
......@@ -7,8 +6,13 @@ export default {
type: Number,
},
},
data() {
return {
storeIndex: 0,
};
},
created() {
store.install(this.$store);
this.storeIndex = store.install(this.$store);
},
mounted() {
if (this.dashboardArea && !this.dashboardArea.length) {
......@@ -25,10 +29,19 @@ export default {
},
},
computed: {
...mapGetters('dashboardArea', ['dashboardArea']),
dashboardArea() {
return this.$store.getters[
`dashboardArea${this.storeIndex}/dashboardArea`
];
},
},
methods: {
...mapActions('dashboardArea', ['fetchDashboardAreaList']),
fetchDashboardAreaList(entity) {
return this.$store.dispatch(
`dashboardArea${this.storeIndex}/fetchDashboardAreaList`,
entity
);
},
getAreaName(id) {
let item = this.dashboardArea.find(area => area.id === id);
if (item) {
......
import areaStroe from './areaStore';
let index = 0;
export default {
install(store) {
if (!store.state.base) {
......@@ -7,11 +9,15 @@ export default {
state: {},
});
}
if (!store.state.base.dashboardArea) {
store.registerModule(['base', 'dashboardArea'], areaStroe);
if (!store.state.base['dashboardArea' + index]) {
store.registerModule(['base', 'dashboardArea' + index], areaStroe);
} else {
index++;
store.registerModule(['base', 'dashboardArea' + index], areaStroe);
}
return index;
},
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