From 3c073186ef55baa082105ec64ba613f6cc91d002 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 5 Jul 2021 11:47:29 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=20chartBox=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E9=A1=B5=E9=9D=A2=E7=9A=84=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/mixin/rightBox.js | 17 +++++++++++++++++ .../src/components/page/dashboard/chartBox.vue | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 nezha-fronted/src/components/common/mixin/rightBox.js diff --git a/nezha-fronted/src/components/common/mixin/rightBox.js b/nezha-fronted/src/components/common/mixin/rightBox.js new file mode 100644 index 000000000..6b2ff3d2d --- /dev/null +++ b/nezha-fronted/src/components/common/mixin/rightBox.js @@ -0,0 +1,17 @@ +export default { + data () { + return { + isEdit: false + } + }, + mounted () { + if (this.isEdit) { + window.onbeforeunload = function () { + return window.confirm('还没有完成,确认退出吗?') + } + } + }, + beforeDestroy () { + window.onbeforeunload = null + } +} diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue index 8872413bd..42c636ece 100644 --- a/nezha-fronted/src/components/page/dashboard/chartBox.vue +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -499,6 +499,7 @@ import nezhaColor from '../../common/nezhaColor' import i18n from '../../common/i18n' import { fromRoute } from '@/components/common/js/constants' import diagram from '@/components/common/ChartDiagram/diagram' +import rightBoxMain from '@/components/common/mixin/rightBox' const rz = { methods: { rz (e) { @@ -519,7 +520,7 @@ export default { default: false } }, - mixins: [rz], + mixins: [rz, rightBoxMain], data () { return { fromRoute, @@ -1753,12 +1754,16 @@ export default { created () { this.getSuggestMetric() this.queryMetrics() + console.log(this.isEdit) }, watch: { chart: { deep: true, immediate: true, handler (n) { + if (n.id) { + this.isEdit = true + } if ((n.param && n.param.valueMapping) && (n.type === 'singleStat' || n.type === 'table')) { n.param.valueMapping.mapping.forEach(item => { this.showPicker.push({ bac: false, text: false })