feat: panel 编辑删除 抽取到 vuex

This commit is contained in:
zhangyu
2021-12-08 15:09:01 +08:00
parent fc18190944
commit 20a1d2b843
4 changed files with 56 additions and 2 deletions

View File

@@ -66,9 +66,10 @@ export default {
},
editChart () {
this.$emit('edit-chart', this.chartInfo)
this.$store.dispatch('dispatchEditChart', this.chartInfo)
},
removeChart () {
this.$emit('delChart', this.chartInfo)
},
duplicate () {

View File

@@ -326,6 +326,7 @@ export default {
immediate: true,
handler (n) {
this.editChart = JSON.parse(JSON.stringify(n))
console.log(this.editChart)
if (this.editChart.groupId === -1) {
this.editChart.groupId = ''
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Vuex from 'vuex'
import user from './user'
import panel from './panel'
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
user
user,
panel
},
state: {
/* 监听对象变化,用于顶部菜单与底部内容的同步 */

View File

@@ -0,0 +1,50 @@
const panel = {
state: {
showRightBox: false,
chart: '',
delChart: false
},
mutations: {
setShowRightBox (state, flag) {
state.showRightBox = flag
},
setChart (state, chart) {
state.chart = chart
},
setDelChart (state, flag) {
state.chart = flag
},
clean (state) {
state.showRightBox = false
state.chart = ''
state.delChart = false
}
},
getters: {
getShowRightBox (state) {
return state.showRightBox
},
getChart (state) {
return state.chart
},
getDelChart (state) {
return state.delChart
}
},
actions: {
dispatchShowRightBox (flag) {
this.store.commit('setShowRightBox', flag)
},
dispatchChart (chart) {
this.store.commit('setShowRightBox', chart)
},
dispatchDelChart (flag) {
this.store.commit('setChart', flag)
},
dispatchEditChart (chart) {
this.store.commit('setShowRightBox', true)
this.store.commit('setChart', chart)
}
}
}
export default panel