diff --git a/src/views/realTimeMonitor/components/carouselChart.vue b/src/views/realTimeMonitor/components/carouselChart.vue index 10d159e..f680e65 100644 --- a/src/views/realTimeMonitor/components/carouselChart.vue +++ b/src/views/realTimeMonitor/components/carouselChart.vue @@ -421,6 +421,26 @@ export default { if (data.channelId) { this.getPointList(data); } + const items = this.$refs.scrollBox.querySelectorAll(".smallPic"); + const selectedItem = items[i]; + const selectedItemLeft = selectedItem.offsetLeft; + const scrollContainer = this.$refs.scrollBox; + const scrollContainerWidth = scrollContainer.offsetWidth; + const selectedItemWidth = selectedItem.offsetWidth; + + // 计算滚动距离,确保选中的元素在滚动容器内完整显示 + let scrollDistance = + selectedItemLeft - (scrollContainerWidth - selectedItemWidth) / 2; + if (scrollDistance < 0) { + scrollDistance = 0; + } else if ( + scrollDistance + scrollContainerWidth > + scrollContainer.scrollWidth + ) { + scrollDistance = scrollContainer.scrollWidth - scrollContainerWidth; + } + // 调整滚动容器的scrollLeft + scrollContainer.scrollLeft = scrollDistance; }, loadImage() { console.log("loading"); @@ -649,6 +669,7 @@ export default { // flex-direction: column; height: calc(100% - 32px); box-sizing: border-box; + .radioBox { position: absolute; top: 8px; diff --git a/src/views/realTimeMonitor/components/siderBar.vue b/src/views/realTimeMonitor/components/siderBar.vue index 6953282..a7d3d79 100644 --- a/src/views/realTimeMonitor/components/siderBar.vue +++ b/src/views/realTimeMonitor/components/siderBar.vue @@ -160,7 +160,7 @@ export default { //获取当前选中的radio getRadio() { console.log(this.zzradio); - this.filterText = ""; + //this.filterText = ""; localStorage.setItem("radio", JSON.stringify(this.zzradio)); this.getLineTreeStatus(); }, @@ -169,7 +169,29 @@ export default { console.log("点击了刷新"); if (this.filterText !== "") { - this.$refs.tree.filter(this.filterText); + 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); //一定要加这个选中了否则样式没有出来 + this.$refs.tree.filter(this.filterText); + }); + }) + .catch((err) => { + console.log(err); //代码错误、请求失败捕获 + }); } else { getdyTreeListJoggle({ type: this.zzradio }) .then((res) => {