diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index eb70e7595..e75a2e935 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -172,10 +172,11 @@ export default { const step = bus.getStep(startTime, endTime) startTime = this.$stringTimeParseToUnix(startTime) endTime = this.$stringTimeParseToUnix(endTime) - if (!this.chartInfo.oldElements) { - this.chartInfo.oldElements = this.chartInfo.elements || [] + if (!this.chartInfo.oldElements) { // 创建一个备份 用于判断变量替换 能拿到原本变量的位置 + this.chartInfo.oldElements = this.chartInfo.elements ? JSON.parse(JSON.stringify(this.chartInfo.elements)) : [] } - this.chartInfo.elements = this.chartInfo.oldElements.map(item => { + this.chartInfo.elements = this.chartInfo.oldElements.filter(item => item.state) // 处理不显示的表达式 + this.chartInfo.elements = this.chartInfo.elements.map(item => { // 处理表达式的变量 const variables = this.variablesReplace(item.expression) this.myVariables.push(variables) return { diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 551f42686..d8022a0bd 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -348,7 +348,7 @@ export default { this.filter.searchName = '' // this.$refs.searchInput.select(); this.showPanel = val - this.variables = this.showPanel.param.variables + this.variables = this.$loadsh.get(this, 'showPanel.param.variables', []) || [] this.showPanel.type = 'dashboard' this.filter.panelId = this.showPanel.id this.panelId = this.showPanel.id @@ -785,7 +785,7 @@ export default { this.$message.error(response) } } - this.variables = this.showPanel.param.variables + this.variables = this.$loadsh.get(this, 'showPanel.param.variables', []) || [] }).catch((error) => { // console.log('error................'+JSON.stringify(error)); if (error) {