提交 0dcfcc50 作者: 施汉文

fix(reportPopup): 修复举报抽屉关闭事件重入问题

上级 3919afc3
......@@ -345,7 +345,8 @@
serverNameList: [],
searchUserOption: [],
eco_user_list: [], // 生态运营人员列表
initialFormSnapshot: '' // 举报抽屉缓存:打开时快照,用于关闭时对比是否有修改
initialFormSnapshot: '', // 举报抽屉缓存:打开时快照,用于关闭时对比是否有修改
isClosing: false // 关闭重入守卫:el-drawer 在 visible 被程序置 false 时会再次 emit close,避免 close() 二次执行
}
},
watch: {
......@@ -353,6 +354,8 @@
// 举报抽屉缓存:组件由父级 :show.sync 常驻挂载,mounted 仅首次执行,
// 故「重置/恢复缓存/快照基线」必须放 show 的 false→true 跳变(不能放 mounted)。
if (newVal === true && oldVal === false) {
// 关闭重入守卫复位:重新打开抽屉时允许下一次正常关闭
this.isClosing = false
if (this.reportInfo && this.reportInfo.id) {
// 编辑/重新提交态:mounted 已回填表单,此处仅重新拉取生态运营
this.$nextTick(() => {
......@@ -787,6 +790,9 @@
})
},
close() {
// 关闭重入守卫:el-drawer 的 visible 监听器在程序置 false 时会再次 emit close,
// 自定义取消/返回未经过 el-drawer 的 hide(),closed 一直为 false,故 close() 会被重入。
if (this.isClosing) return
// 举报抽屉缓存:关闭时检测是否有未提交的修改
const hasChanges = JSON.stringify(this.reportForm) !== this.initialFormSnapshot
if (hasChanges) {
......@@ -796,14 +802,17 @@
type: 'warning'
}).then(() => {
// 举报抽屉缓存:用户选择保存,存入 vuex
this.isClosing = true
this.$store.commit('game/set_reportDrawerCache', this.$clone(this.reportForm))
this.$emit('update:show', false)
}).catch(() => {
// 举报抽屉缓存:用户选择不保存,清除缓存
this.isClosing = true
this.$store.commit('game/clear_reportDrawerCache')
this.$emit('update:show', false)
})
} else {
this.isClosing = true
this.$emit('update:show', false)
}
},
......@@ -855,6 +864,8 @@
if (res.status_code === 1) {
this.$message.success('提交成功')
// 举报抽屉缓存:提交成功后清除缓存,并直接关闭(不走 close 的未保存确认逻辑)
// 置 isClosing 守卫:阻止 el-drawer 重入的 close() 二次弹确认 / 把刚清掉的缓存又写回
this.isClosing = true
this.$store.commit('game/clear_reportDrawerCache')
this.$emit('update:show', false)
if (this.reportInfo && this.reportInfo.id) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论