feat: panel 编辑删除 抽取到 vuex
This commit is contained in:
@@ -66,9 +66,10 @@ export default {
|
|||||||
},
|
},
|
||||||
editChart () {
|
editChart () {
|
||||||
this.$emit('edit-chart', this.chartInfo)
|
this.$emit('edit-chart', this.chartInfo)
|
||||||
|
this.$store.dispatch('dispatchEditChart', this.chartInfo)
|
||||||
},
|
},
|
||||||
removeChart () {
|
removeChart () {
|
||||||
|
this.$emit('delChart', this.chartInfo)
|
||||||
},
|
},
|
||||||
duplicate () {
|
duplicate () {
|
||||||
|
|
||||||
|
|||||||
@@ -326,6 +326,7 @@ export default {
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
handler (n) {
|
handler (n) {
|
||||||
this.editChart = JSON.parse(JSON.stringify(n))
|
this.editChart = JSON.parse(JSON.stringify(n))
|
||||||
|
console.log(this.editChart)
|
||||||
if (this.editChart.groupId === -1) {
|
if (this.editChart.groupId === -1) {
|
||||||
this.editChart.groupId = ''
|
this.editChart.groupId = ''
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import user from './user'
|
import user from './user'
|
||||||
|
import panel from './panel'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
user
|
user,
|
||||||
|
panel
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
/* 监听对象变化,用于顶部菜单与底部内容的同步 */
|
/* 监听对象变化,用于顶部菜单与底部内容的同步 */
|
||||||
|
|||||||
50
nezha-fronted/src/store/panel.js
Normal file
50
nezha-fronted/src/store/panel.js
Normal 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
|
||||||
Reference in New Issue
Block a user