diff --git a/src/views/realTimeMonitor/components/siderBar.vue b/src/views/realTimeMonitor/components/siderBar.vue index 43cd153..7705a68 100644 --- a/src/views/realTimeMonitor/components/siderBar.vue +++ b/src/views/realTimeMonitor/components/siderBar.vue @@ -101,6 +101,7 @@ export default { currentData: {}, //当前选中的数据 currentNodekey: "", //默认选中的节点树, role: "", + treeStatustimer: null, }; }, components: {}, @@ -125,6 +126,7 @@ export default { console.log(this.role); this.getRadio(); //获取列表在线离线全部 this.getLineTreeList(); //获取树状图 + this.treeStatustimer = setInterval(this.getLineTreeStatus, 60000); // 每10秒刷新数据 }, methods: { //获取当前选中的radio @@ -137,68 +139,24 @@ export default { //刷新tree列表 getLineTreeStatus() { console.log("点击了刷新"); + if (this.filterText !== "") { this.$refs.tree.filter(this.filterText); } else { - if (this.role == 4) { - getzzdyTreeList({ type: this.zzradio }) - .then((res) => { - console.log(res); - this.lineTreeData = res.data.list; - this.onlineNum = res.data.onlineNum; - this.totalNum = res.data.totalNum; - if (this.zzradio == 0) { - console.log("装置为离线"); - this.$nextTick(() => { - console.log(this.lineTreeData); - this.currentData = this.lineTreeData[0]; - console.log(this.currentData); - this.handleNodeClick(this.currentData); - this.$nextTick(() => { - this.$refs.tree.setCurrentKey(this.currentData.id); //一定要加这个选中了否则样式没有出来 - this.scrollView(); - }); - }); - } else { - this.$nextTick(() => { - this.$refs.tree.setCurrentKey(this.currentData.id); //一定要加这个选中了否则样式没有出来 - this.scrollView(); - }); - } - }) - .catch((err) => { - console.log(err); //代码错误、请求失败捕获 - }); - } else { - getdyTreeListJoggle({ type: this.zzradio }) - .then((res) => { - console.log(res); - this.lineTreeData = res.data.list; - this.onlineNum = res.data.onlineNum; - this.totalNum = res.data.totalNum; - if (this.zzradio == 0) { - console.log("装置为离线"); - this.$nextTick(() => { - console.log(this.lineTreeData); - this.currentData = this.lineTreeData[0]; - console.log(this.currentData); - this.handleNodeClick(this.currentData); - this.$nextTick(() => { - this.$refs.tree.setCurrentKey(this.currentData.id); //一定要加这个选中了否则样式没有出来 - this.scrollView(); - }); - }); - } else { - this.$nextTick(() => { - this.$refs.tree.setCurrentKey(this.currentData.id); //一定要加这个选中了否则样式没有出来 - this.scrollView(); - }); - } - }) - .catch((err) => { - console.log(err); //代码错误、请求失败捕获 + getdyTreeListJoggle({ type: this.zzradio }) + .then((res) => { + console.log(res); + this.lineTreeData = res.data.list; + this.onlineNum = res.data.onlineNum; + this.totalNum = res.data.totalNum; + this.currentData = JSON.parse(localStorage.getItem("currentData")); + this.$nextTick(() => { + this.$refs.tree.setCurrentKey(this.currentData.id); //一定要加这个选中了否则样式没有出来 }); - } + }) + .catch((err) => { + console.log(err); //代码错误、请求失败捕获 + }); } }, handleFilter() { @@ -358,6 +316,11 @@ export default { } }, }, + beforeDestroy() { + //清除定时器 + clearInterval(this.treeStatustimer); + this.treeStatustimer = null; + }, };