NEZ-2712 fix:点击chart编辑按钮未对内容操作的情况下退出出现更改保存提示

This commit is contained in:
zhangyu
2023-03-17 14:38:32 +08:00
parent a5c8d3958a
commit 51ec11b82a
3 changed files with 8 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ export const clickoutside = {
const unsavedChange = localStorage.getItem('nz-unsaved-change')
try {
el.__oldValue__ = JSON.parse(JSON.stringify(binding.value.obj))
el.__oldData__ = JSON.parse(JSON.stringify(binding.value.oldData))
el.__newValue__ = el.__oldValue__
} catch (e) {
@@ -38,7 +39,8 @@ export const clickoutside = {
}
if (el.__oldValue__) {
// const newValue = JSON.parse(JSON.stringify(binding.value.obj))
if (unsavedChange == 'on' && !isEqual(el.__oldValue__, el.__newValue__) && !el.isShow) {
const oldData = el.__oldData__ || el.__oldValue__
if (unsavedChange == 'on' && !isEqual(oldData, el.__newValue__) && !el.isShow) {
el.isShow = true
MessageBox.confirm(i18n.t('tip.confirmCancel'), {
confirmButtonText: i18n.t('tip.yes'),
@@ -79,6 +81,7 @@ export const clickoutside = {
}
}
el.__newValue__ = binding.value.obj
el.__oldData__ = binding.value.oldData
},
unbind (el, binding) {
// 解除事件监听

View File

@@ -11,7 +11,8 @@ export default {
closeMessage: null,
uuid: getUUID(),
isStable: 'instability',
stableTime: null
stableTime: null,
oldData: {}
}
},
mounted () {

View File

@@ -1,5 +1,5 @@
<template>
<div v-clickoutside:[isStable]="{obj: editChart, func:clickOutside}" :class="boxClass" class="right-box right-box-chart">
<div v-clickoutside:[isStable]="{obj: editChart,oldData: oldData, func:clickOutside}" :class="boxClass" class="right-box right-box-chart">
<transition v-if="from !== 'chartTemp'" name="right-box">
<!-- <panel-box v-if="!showPanel.type" ref="panelBox2" :panel="panel" @reload="panelReload"></panel-box>-->
</transition>
@@ -602,6 +602,7 @@ export default {
}
}
this.editChart = obj
this.oldData = this.$loadsh.cloneDeep(obj)
if (this.stableTime) {
clearTimeout(this.stableTime)
this.stableTime = null