修改bug 52615 征求意见:添加数据完成后 页面需要自动刷新 现在是手动刷新

This commit is contained in:
zhangyichen
2022-04-19 15:21:39 +08:00
parent d24b00baee
commit 6ae0472109
3 changed files with 38 additions and 2 deletions
@@ -388,6 +388,7 @@ export default {
console.log(res.data.records);
this.total = res.data.total
this.spinShow = false
localStorage.setItem('refreshFlag', false)
}, e => {
})
},
@@ -557,6 +558,13 @@ export default {
},
handleQueryPdf(file){
window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + file.attId))
},
isVisible(e) {
if (e.target.visibilityState === "visible") {
this.getList()
} else if (e.target.visibilityState === "hidden") {
this.getList()
}
}
},
watch: {
@@ -572,6 +580,17 @@ export default {
...mapGetters(['refreshFlag'])
},
mounted() {
const that = this;
//监听缓存中指定key的值变化
window.addEventListener("setItemEvent",function(e){
//e.key : 是值发生变化的key
//例如 e.key==="token";
//e.newValue : 是可以对应的新值
if(e.key === "refreshFlag" && e.newValue === true){
this.getList()
}
})
document.addEventListener('visibilitychange', that.isVisible)
if (this.lawsStand) {
this.form = {
ideaId: this.lawsStand.id,
@@ -613,7 +632,10 @@ export default {
this.getList()
this.getIdeaKey()
this.getFileInfo()
}
},
destroyed() {
document.removeEventListener('visibilitychange', this.isVisible)
},
}
</script>