From 92a26b9cbef4d5c57a1f5a2f5b11dd84d1524491 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Wed, 29 Dec 2021 16:18:46 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E4=BC=98=E5=8C=96=E5=A4=8D?= =?UTF-8?q?=E5=88=B6chart=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/bottomBox/tabs/panelTabNew.vue | 47 +++++++++++++++++-- .../src/components/page/dashboard/panel.vue | 5 ++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue index 8fa7c2257..59bc37310 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue @@ -362,12 +362,49 @@ export default { } }, // 编辑图表信息,打开编辑弹窗 - editChart (data) { - if (!data.param) { - data.param = { url: '', threshold: '' } + editChart (data, copy) { + if (copy) { + this.chart = JSON.parse(JSON.stringify(data)) + this.chart.x = 0 + this.chart.y = 0 + this.chart.panelId = this.showPanel.id + this.chart.panelName = this.showPanel.name + this.chart.id = '' + this.chart.elements.forEach((item) => { + item.id = '' + item.chartId = '' + delete item.seq + }) + if (this.chart.datasource !== 'metrics' && this.chart.datasource !== 'log') { + delete this.chart.elements + } + } else { + this.rightBox.loading = true + this.$get('visual/panel/chart/' + data.id).then(res => { + this.rightBox.loading = false + if (res.code === 200) { + const chartData = res.data.data + this.chart = JSON.parse(JSON.stringify(chartData)) + this.chart.panelId = this.showPanel.id + this.chart.panelName = this.showPanel.name + this.chart.param = JSON.parse(this.chart.param) + if (!this.chart.groupId || this.chart.groupId == -1) { + this.chart.groupId = '' + } + if (this.chart.type == 'table') { + const arr = this.chart.param.indexs ? this.chart.param.indexs.split(',') : [] + this.chart.param.tags = arr.map((item) => { + return { + text: item, + tiClasses: ['ti-valid'] + } + }) + } + } else { + this.$message.error(res.msg) + } + }) } - this.chart = JSON.parse(JSON.stringify(data)) - this.rightBox.chart.show = true }, // 移除图表:弹出确认框询问 delChart (data, from) { diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 3599e90dc..9080bbe2b 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -416,6 +416,8 @@ export default { editChart (data, copy) { if (copy) { this.chart = JSON.parse(JSON.stringify(data)) + this.chart.x = 0 + this.chart.y = 0 this.chart.panelId = this.showPanel.id this.chart.panelName = this.showPanel.name this.chart.id = '' @@ -424,6 +426,9 @@ export default { item.chartId = '' delete item.seq }) + if (this.chart.datasource !== 'metrics' && this.chart.datasource !== 'log') { + delete this.chart.elements + } } else { this.rightBox.loading = true this.$get('visual/panel/chart/' + data.id).then(res => {