From 11b65327589b432383832337c6ec52504f3b46e0 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 5 Jul 2022 11:43:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E4=BF=AE=E6=94=B9panel=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=88=87=E6=8D=A2=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E4=BB=A5=E5=8F=8A=20=E8=A1=A8=E8=BE=BE=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/components/chart/panelChart.vue | 7 ++++--- nezha-fronted/src/components/page/dashboard/panel.vue | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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) {