Переглянути джерело

页面跳转带参逻辑补全

yangxiao 3 роки тому
батько
коміт
7619158338

+ 29 - 1
src/components/coms/collapse/collapse-list.vue

@@ -118,6 +118,24 @@ export default {
       this.itemIndex = index;
       this.$emit("click", item);
     },
+    setDefaultActiveMenu(menu){
+      menu.forEach((pEle,pIndex)=>{
+
+        let findResult=pEle.children.find(cEle=>{
+          return cEle.wpId === this.wpId;
+        });
+
+        if (findResult) this.menuIndex=pIndex;
+
+        pEle.children.forEach((cEle,cIndex)=>{
+          if(cEle.id === this.wtId){
+            this.itemIndex=cIndex
+          }
+        });
+
+      });
+
+    }
   },
   // 生命周期钩子
   beforeCreate() {
@@ -129,13 +147,23 @@ export default {
   beforeMount() {
     // 渲染前
   },
-  mounted() {},
+  mounted() {
+    this.wpId = this.$route.params.wpId || "";
+    this.wtId = this.$route.params.wtId || "";
+    this.setDefaultActiveMenu(this.list);
+  },
   beforeUpdate() {
     // 数据更新前
   },
   updated() {
     // 数据更新后
   },
+
+  watch:{
+    list(res){
+      this.setDefaultActiveMenu(res)
+    }
+  }
 };
 </script>
 

+ 2 - 2
src/router/index.js

@@ -42,10 +42,10 @@ const routes = [
       path: 'box',
       component: () => import(/* webpackChunkName: "windsitebox" */ '../views/WindSite/pages/Box.vue'),
     }, {
-      path: 'info/:wpId', // 单机状态监视
+      path: 'info/:wpId/:wtId', // 单机状态监视
       component: () => import(/* webpackChunkName: "windsitebox" */ '../views/WindSite/pages/Info/Info.vue'),
     }, {
-      path: 'tower/:wpId',
+      path: 'tower/:wpId', // 测风塔
       component: () => import(/* webpackChunkName: "windsitetower" */ '../views/WindSite/pages/Tower.vue'),
     }, {
       path: 'inverter-info',

+ 4 - 4
src/views/WindSite/WindSite.vue

@@ -58,10 +58,10 @@ export default {
           icon: "svg-intranet-involvement",
           path: "/windsite/box",
         },*/,
-        {
-          icon: "svg-matrix",
-          path: "/windsite/info",
-        },
+        // {
+        //   icon: "svg-matrix",
+        //   path: "/windsite/info",
+        // },
         {
           icon: "svg-easy-compass",
           path: "/windsite/tower",

+ 8 - 6
src/views/WindSite/pages/Home/Home.vue

@@ -455,6 +455,8 @@ export default {
             res.data.fjjzmap.fjmap[0].forEach((ele) => {
               fjmap.push({
                 tag: ele.wtnum,
+                wtId: ele.wtId,
+                wpId: ele.wpId,
                 color: that.getColor(ele.fjzt),
               });
             });
@@ -462,7 +464,7 @@ export default {
             keys.forEach((key, keyIndex) => {
               res.data.glvos.forEach((ele) => {
                 Powertrend.value[keyIndex].value.push({
-                  text: "",
+                  text: new Date(ele.time).formatDate("yyyy-MM-dd"),
                   value: ele[key],
                 });
               });
@@ -524,7 +526,7 @@ export default {
           let dayLost = [];
           res.data.forEach((ele) => {
             dayLost.push({
-              text: ele.timestr,
+              text: new Date(ele.time).formatDate("yyyy-MM-dd"),
               value: ele.value1,
             });
           });
@@ -559,11 +561,11 @@ export default {
 
           res.data.forEach((ele) => {
             data[0].value.push({
-              text: ele.timestr,
+              text: new Date(ele.time).formatDate("yyyy-MM-dd"),
               value: ele.value1 || 0,
             });
             data[1].value.push({
-              text: ele.timestr,
+              text: new Date(ele.time).formatDate("yyyy-MM-dd"),
               value: ele.value2 || 0,
             });
           });
@@ -599,11 +601,11 @@ export default {
 
           res.data.forEach((ele) => {
             data[0].value.push({
-              text: ele.timestr,
+              text: new Date(ele.time).formatDate("yyyy-MM-dd"),
               value: ele.value1,
             });
             data[1].value.push({
-              text: ele.timestr,
+              text: new Date(ele.time).formatDate("yyyy-MM-dd"),
               value: ele.value2,
             });
           });

+ 8 - 1
src/views/WindSite/pages/Home/light-matrix.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="light-matrix-small">
-    <div class="card" v-for="(item, i) of list" :key="i" :class="item.color">
+    <div class="card" v-for="(item, i) of list" :key="i" :class="item.color" @click="jumpUrl(item.wpId, item.wtId)">
       {{ item.tag }}
     </div>
     <!-- 站位用 保证卡片布局最后一行不会有问题 -->
@@ -48,6 +48,13 @@ export default {
         this.$el.style.width = "1168px";
       }
     },
+
+    // 页面跳转
+    jumpUrl(wpId, wtId){
+      this.$router.push({
+        path: `/windsite/info/${wpId}/${wtId}`
+      });
+    }
   },
   // 生命周期钩子
   beforeCreate() {

+ 2 - 0
src/views/WindSite/pages/Info/Info.vue

@@ -156,6 +156,7 @@ export default {
             pEle.fjls[0].forEach((cEle) => {
               WindSites[pIndex].children.push({
                 id: cEle.wtId,
+                wpId: cEle.wpId,
                 text: cEle.wtnum,
                 color: that.getColor(cEle.fjzt),
               });
@@ -213,6 +214,7 @@ export default {
   created() {
     let that = this;
     that.wpId = that.$route.params.wpId;
+    that.wtId = that.$route.params.wtId || '';
     that.$nextTick(() => {
       that.requestData(false);
       that.timmer = setInterval(() => {

+ 1 - 1
src/views/WindSite/pages/Info/Warning.vue

@@ -106,7 +106,7 @@ export default {
         data.index = index;
 
         if (this.activeArray.length < index + 1) {
-          this.activeArray.push(false);
+          this.activeArray.push((!index ? true : false));
         }
 
         options.push({