更新左侧树状图60s更新状态

wp1.0
fanluyan 1 year ago
parent 88edc135a9
commit bd9b11294c

@ -101,6 +101,7 @@ export default {
currentData: {}, // currentData: {}, //
currentNodekey: "", //, currentNodekey: "", //,
role: "", role: "",
treeStatustimer: null,
}; };
}, },
components: {}, components: {},
@ -125,6 +126,7 @@ export default {
console.log(this.role); console.log(this.role);
this.getRadio(); //线线 this.getRadio(); //线线
this.getLineTreeList(); // this.getLineTreeList(); //
this.treeStatustimer = setInterval(this.getLineTreeStatus, 60000); // 10
}, },
methods: { methods: {
//radio //radio
@ -137,38 +139,9 @@ export default {
//tree //tree
getLineTreeStatus() { getLineTreeStatus() {
console.log("点击了刷新"); console.log("点击了刷新");
if (this.filterText !== "") { if (this.filterText !== "") {
this.$refs.tree.filter(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 { } else {
getdyTreeListJoggle({ type: this.zzradio }) getdyTreeListJoggle({ type: this.zzradio })
.then((res) => { .then((res) => {
@ -176,30 +149,15 @@ export default {
this.lineTreeData = res.data.list; this.lineTreeData = res.data.list;
this.onlineNum = res.data.onlineNum; this.onlineNum = res.data.onlineNum;
this.totalNum = res.data.totalNum; this.totalNum = res.data.totalNum;
if (this.zzradio == 0) { this.currentData = JSON.parse(localStorage.getItem("currentData"));
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.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.currentData.id); // this.$refs.tree.setCurrentKey(this.currentData.id); //
this.scrollView();
}); });
}
}) })
.catch((err) => { .catch((err) => {
console.log(err); // console.log(err); //
}); });
} }
}
}, },
handleFilter() { handleFilter() {
// 500 // 500
@ -358,6 +316,11 @@ export default {
} }
}, },
}, },
beforeDestroy() {
//
clearInterval(this.treeStatustimer);
this.treeStatustimer = null;
},
}; };
</script> </script>
<style lang="less"> <style lang="less">

Loading…
Cancel
Save