From b527f54500806ca10ca55ee1bf1e7292e17b5cb1 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 5 Jan 2023 17:53:42 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-2494=20=20feat=EF=BC=9A=20=E5=A4=84?= =?UTF-8?q?=E7=90=86chart=20rules=20=E4=BC=98=E5=8C=96=E6=9C=AA=E7=94=9F?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/bottomBox/tabs/panelTabNew.vue | 38 +++++++++++++++---- .../src/components/common/js/tools.js | 12 +++--- .../components/common/mixin/editRigthBox.js | 4 +- .../common/rightBox/alertRuleBox.vue | 14 ++++++- .../common/rightBox/chart/chartRightBox.vue | 6 ++- .../src/components/page/alert/alertRule.vue | 4 +- .../src/components/page/dashboard/panel.vue | 16 +++++++- nezha-fronted/src/store/panel.js | 2 +- 8 files changed, 75 insertions(+), 21 deletions(-) diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue index 90c29683c..321afec36 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue @@ -16,7 +16,7 @@
- { + this.$refs.addChartModal.isStable = 'stable' }) }, addChartByTemp () { @@ -441,6 +452,9 @@ export default { } }) } + this.$nextTick(() => { + this.$refs.addChartModal.isStable = 'stable' + }) } else { this.$message.error(res.msg) } @@ -774,6 +788,12 @@ export default { } }) }, + addChartBefore () { + this.$store.dispatch('dispatchEditChart', { + chart: '', + type: 'add' + }) + }, disposeChart () { const chartInfo = this.$store.getters.getChart const groupId = this.$store.getters.getGroupId @@ -882,6 +902,8 @@ export default { handler (n) { if (n) { this.disposeChart() + } else { + this.$refs.addChartModal.isStable = 'instability' } } }, diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index 15d89cee0..158f25ad7 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -13,8 +13,8 @@ export const clickoutside = { const unsavedChange = localStorage.getItem('nz-unsaved-change') let oldValue try { - oldValue = JSON.parse(JSON.stringify(binding.value.obj)) - el.__newValue__ = oldValue + el.__oldValue__ = JSON.parse(JSON.stringify(binding.value.obj)) + el.__newValue__ = el.__oldValue__ } catch (e) { } @@ -37,10 +37,9 @@ export const clickoutside = { if (!flag) { return false } - if (oldValue) { - console.log(oldValue, el.__newValue__) + if ( el.__oldValue__) { // const newValue = JSON.parse(JSON.stringify(binding.value.obj)) - if (unsavedChange == 'on' && !isEqual(oldValue, el.__newValue__) && !el.isShow) { + if (unsavedChange == 'on' && !isEqual( el.__oldValue__, el.__newValue__) && !el.isShow) { el.isShow = true MessageBox.confirm(i18n.t('tip.confirmCancel'), { confirmButtonText: i18n.t('tip.yes'), @@ -75,6 +74,9 @@ export const clickoutside = { }, 100) }, update (el, binding, vnode) { + if (binding.arg && binding.arg != 'stable') { + el.__oldValue__ = JSON.parse(JSON.stringify(binding.value.obj)) + } el.__newValue__ = binding.value.obj }, unbind (el, binding) { diff --git a/nezha-fronted/src/components/common/mixin/editRigthBox.js b/nezha-fronted/src/components/common/mixin/editRigthBox.js index 85198f626..7cf365ff7 100644 --- a/nezha-fronted/src/components/common/mixin/editRigthBox.js +++ b/nezha-fronted/src/components/common/mixin/editRigthBox.js @@ -9,7 +9,9 @@ export default { emit: '' }, closeMessage: null, - uuid: getUUID() + uuid: getUUID(), + isStable: 'instability', + stableTime: null } }, mounted () { diff --git a/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue b/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue index 8851bf20c..daa3efd48 100644 --- a/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertRuleBox.vue @@ -1,5 +1,5 @@