修改bug 52615 征求意见:添加数据完成后 页面需要自动刷新 现在是手动刷新
This commit is contained in:
+2
-1
@@ -46,7 +46,8 @@ import 'vant/lib/index.css';
|
||||
//vant
|
||||
|
||||
import animate from 'animate.css'
|
||||
|
||||
import tool from './utils/tool'
|
||||
Vue.use(tool)
|
||||
// 引入路由器
|
||||
import router from './router'
|
||||
// 路由解析器
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
function dispatchEventStroage() {
|
||||
const signSetItem = localStorage.setItem
|
||||
localStorage.setItem = function(key, val) {
|
||||
let setEvent = new Event('setItemEvent')
|
||||
setEvent.key = key
|
||||
setEvent.newValue = val
|
||||
window.dispatchEvent(setEvent)
|
||||
signSetItem.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
export default dispatchEventStroage
|
||||
|
||||
Reference in New Issue
Block a user