diff --git a/nezha-fronted/src/components/chart/chartHeader.vue b/nezha-fronted/src/components/chart/chartHeader.vue index 14b5dd365..21d4fd8e3 100644 --- a/nezha-fronted/src/components/chart/chartHeader.vue +++ b/nezha-fronted/src/components/chart/chartHeader.vue @@ -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 () { diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue index 8e349d61b..3087f7503 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue @@ -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 = '' } diff --git a/nezha-fronted/src/store/index.js b/nezha-fronted/src/store/index.js index 6094b6df7..ec9826625 100644 --- a/nezha-fronted/src/store/index.js +++ b/nezha-fronted/src/store/index.js @@ -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: { /* 监听对象变化,用于顶部菜单与底部内容的同步 */ diff --git a/nezha-fronted/src/store/panel.js b/nezha-fronted/src/store/panel.js new file mode 100644 index 000000000..e0fd8bc22 --- /dev/null +++ b/nezha-fronted/src/store/panel.js @@ -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