From c6c82dc570830e806bef8aa638a63e9490dab765 Mon Sep 17 00:00:00 2001 From: fanluyan <754122931@qq.com> Date: Mon, 8 Jan 2024 14:19:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=94=B6=E8=97=8F=E5=A4=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../realTimeMonitor/components/siderBar.vue | 206 ++++++++++++------ 1 file changed, 142 insertions(+), 64 deletions(-) diff --git a/src/views/realTimeMonitor/components/siderBar.vue b/src/views/realTimeMonitor/components/siderBar.vue index 3455b0e..c8393bf 100644 --- a/src/views/realTimeMonitor/components/siderBar.vue +++ b/src/views/realTimeMonitor/components/siderBar.vue @@ -170,7 +170,7 @@ export default { console.log(this.role); this.getRadio(); //获取列表在线离线全部 this.getLineTreeList(); //获取树状图 - this.treeStatustimer = setInterval(this.getLineTreeStatus, 60000); // 每10秒刷新数据 + this.treeStatustimer = setInterval(this.getLineTreeStatus, 60000); // 每60秒刷新数据 EventBus.$on("treelist", this.getLineTreeStatus); }, methods: { @@ -188,27 +188,60 @@ export default { if (this.filterText !== "") { this.$refs.tree.filter(this.filterText); } else { - getdyTreeListJoggle({ type: this.zzradio }) - .then((res) => { - console.log(res); - this.lineTreeData = res.data.list; - this.isfavorList = res.data.favorlist; - this.lineTreeData.unshift({ - id: 0, - name: "收藏夹", - bsManufacturer: "收藏夹", - list: this.isfavorList, + if (this.role == 4) { + getzzdyTreeList({ type: this.zzradio, lineid: 127 }) + .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); //代码错误、请求失败捕获 }); - 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); //一定要加这个选中了否则样式没有出来 + } else { + getdyTreeListJoggle({ type: this.zzradio }) + .then((res) => { + console.log(res); + this.lineTreeData = res.data.list; + this.isfavorList = res.data.favorlist; + this.lineTreeData.unshift({ + id: 0, + name: "收藏夹", + bsManufacturer: "收藏夹", + list: this.isfavorList, + }); + 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); //代码错误、请求失败捕获 }); - }) - .catch((err) => { - console.log(err); //代码错误、请求失败捕获 - }); + } } }, handleFilter() { @@ -231,55 +264,100 @@ export default { //获取树状图列表 getLineTreeList() { console.log(this.zzradio); - getdyTreeListJoggle({ type: this.zzradio }) - .then((res) => { - this.lineTreeData = res.data.list; - this.isfavorList = res.data.favorlist; - this.lineTreeData.unshift({ - id: 0, - name: "收藏夹", - bsManufacturer: "收藏夹", - list: this.isfavorList, - }); - this.onlineNum = res.data.onlineNum; - this.totalNum = res.data.totalNum; - this.currentData = JSON.parse(localStorage.getItem("currentData")); - this.lineTreeData.forEach((node) => { - if (node.list) { - node.list.forEach((child) => { - this.defaultExpandedKeys.push(child.id); - }); + if (this.role == 4) { + getzzdyTreeList({ type: this.zzradio, lineid: 127 }) + .then((res) => { + this.lineTreeData = res.data.list; + this.onlineNum = res.data.onlineNum; + this.totalNum = res.data.totalNum; + this.currentData = JSON.parse(localStorage.getItem("currentData")); + this.lineTreeData.forEach((node) => { + if (node.list) { + node.list.forEach((child) => { + this.defaultExpandedKeys.push(child.id); + }); + } else { + this.defaultExpandedKeys.push(node.id); + } + }); + this.defaultExpandedKeys = + JSON.parse(localStorage.getItem("defaultKey")) !== null + ? JSON.parse(localStorage.getItem("defaultKey")) + : []; //获取保存的defaultKey ; + + console.log(this.defaultExpandedKeys); + if (this.lineTreeData[0].list[0].list.length > 0) { + } + if ( + this.currentData !== null && + Object.keys(this.currentData).length !== 0 + ) { + this.currentNodekey = this.currentData.id; + this.handleNodeClick(this.currentData); } else { - this.defaultExpandedKeys.push(node.id); + this.currentData = this.lineTreeData[0]; //第一个选中的数据 + this.currentNodekey = this.lineTreeData[0].id; //第一个数据 + this.handleNodeClick(this.currentData); } + this.$nextTick(() => { + this.$refs.tree.setCurrentKey(this.currentNodekey); //一定要加这个选中了否则样式没有出来 + this.scrollView(); + }); + }) + .catch((err) => { + console.log(err); //代码错误、请求失败捕获 }); - this.defaultExpandedKeys = - JSON.parse(localStorage.getItem("defaultKey")) !== null - ? JSON.parse(localStorage.getItem("defaultKey")) - : this.defaultExpandedKeys; //获取保存的defaultKey ; + } else { + getdyTreeListJoggle({ type: this.zzradio }) + .then((res) => { + this.lineTreeData = res.data.list; + this.isfavorList = res.data.favorlist; + this.lineTreeData.unshift({ + id: 0, + name: "收藏夹", + bsManufacturer: "收藏夹", + list: this.isfavorList, + }); + this.onlineNum = res.data.onlineNum; + this.totalNum = res.data.totalNum; + this.currentData = JSON.parse(localStorage.getItem("currentData")); + this.lineTreeData.forEach((node) => { + if (node.list) { + node.list.forEach((child) => { + this.defaultExpandedKeys.push(child.id); + }); + } else { + this.defaultExpandedKeys.push(node.id); + } + }); + this.defaultExpandedKeys = + JSON.parse(localStorage.getItem("defaultKey")) !== null + ? JSON.parse(localStorage.getItem("defaultKey")) + : this.defaultExpandedKeys; //获取保存的defaultKey ; - console.log(this.defaultExpandedKeys); - // if (this.lineTreeData[0].list[0].list.length > 0) { - // } - if ( - this.currentData !== null && - Object.keys(this.currentData).length !== 0 - ) { - this.currentNodekey = this.currentData.id; - this.handleNodeClick(this.currentData); - } else { - this.currentData = this.lineTreeData[0]; //第一个选中的数据 - this.currentNodekey = this.lineTreeData[0].id; //第一个数据 - this.handleNodeClick(this.currentData); - } - this.$nextTick(() => { - this.$refs.tree.setCurrentKey(this.currentNodekey); //一定要加这个选中了否则样式没有出来 - this.scrollView(); + console.log(this.defaultExpandedKeys); + // if (this.lineTreeData[0].list[0].list.length > 0) { + // } + if ( + this.currentData !== null && + Object.keys(this.currentData).length !== 0 + ) { + this.currentNodekey = this.currentData.id; + this.handleNodeClick(this.currentData); + } else { + this.currentData = this.lineTreeData[1]; //第一个选中的数据 + this.currentNodekey = this.lineTreeData[1].id; //第一个数据 + this.handleNodeClick(this.currentData); + } + this.$nextTick(() => { + this.$refs.tree.setCurrentKey(this.currentNodekey); //一定要加这个选中了否则样式没有出来 + this.scrollView(); + }); + }) + .catch((err) => { + console.log(err); //代码错误、请求失败捕获 }); - }) - .catch((err) => { - console.log(err); //代码错误、请求失败捕获 - }); + } }, //点击当前选中的treenode