Quellcode durchsuchen

fix: 详情页面bug修改

chenzhen2 vor 2 Jahren
Ursprung
Commit
0272352710

Datei-Diff unterdrückt, da er zu groß ist
+ 26 - 0
public/images/ipdImages/shangeyun_logo.svg


+ 44 - 21
src/views/choiceSpace/choiceSpace.vue

@@ -80,7 +80,14 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, nextTick, onMounted, reactive, toRefs } from "vue";
+import {
+  defineComponent,
+  getCurrentInstance,
+  nextTick,
+  onMounted,
+  reactive,
+  toRefs,
+} from "vue";
 import { useRoute, useRouter, onBeforeRouteUpdate } from "vue-router";
 import { Search, TreeSelect, Popup, Checkbox, Toast } from "vant";
 import {
@@ -110,6 +117,7 @@ export default defineComponent({
     VanCheckbox: Checkbox,
   },
   setup() {
+    const proxyGlobal: any = getCurrentInstance();
     const route: any = useRoute();
     const router: any = useRouter();
     const userInfo: any = getUserInfo();
@@ -346,6 +354,7 @@ export default defineComponent({
       },
       // 保存空间
       saveWorkSpace(params: any) {
+        proxyGlobal.proxy.$loadingStart(0);
         saveWorkSpace(params).then((res) => {
           proxyData.querySpaceList();
           // router.push({ name: "setMainSpace" });
@@ -359,26 +368,32 @@ export default defineComponent({
             macAddress: proxyData.userInfo.mac, //类型:String  必有字段  备注:mac地址
           },
         };
-        checkWorkSpace(params).then((res) => {
-          let resData: any = res;
-          let data: any = [];
-          if (resData.result === "success") {
-            data = resData?.content ?? [];
-          } else {
-            data = [];
-          }
-          if (data.length > 1) {
-            // router.push({ name: "setMainSpace" });
-            setTimeout(() => {
-              router.push({ name: "setMainSpace" });
-            }, 1000);
-          } else {
-            router.push({
-              name: "envmonitor",
-              query: { spaceId: data[0].spaceId },
-            });
-          }
-        });
+        checkWorkSpace(params)
+          .then((res) => {
+            let resData: any = res;
+            let data: any = [];
+            if (resData.result === "success") {
+              data = resData?.content ?? [];
+            } else {
+              data = [];
+            }
+            if (data.length > 1) {
+              // router.push({ name: "setMainSpace" });
+              setTimeout(() => {
+                proxyGlobal.proxy.$loadinngEnd();
+                router.push({ name: "setMainSpace" });
+              }, 1000);
+            } else {
+              proxyGlobal.proxy.$loadinngEnd();
+              router.push({
+                name: "envmonitor",
+                query: { spaceId: data[0].spaceId },
+              });
+            }
+          })
+          .catch(() => {
+            proxyGlobal.proxy.$loadinngEnd();
+          });
       },
       // 选择建筑
       checkBuilding(index: any) {
@@ -423,6 +438,9 @@ export default defineComponent({
               } else {
                 item.checked = false;
               }
+              if (item.spaceId === proxyData.spaceId) {
+                item.checked = true;
+              }
             });
             // 不搜索的时候数据备份一下
             if (!query) {
@@ -452,7 +470,12 @@ export default defineComponent({
         };
         proxyData.getPadSpaceList(query);
       },
+      spaceId: "",
       init() {
+        let spaceId: any = route.query.spaceId;
+        proxyData.spaceId = spaceId;
+        let projectId: any = route.query.id;
+        store.commit(UserMutationTypes.SET_PROJECT_ID, projectId);
         proxyData.getDefaultLocation();
       },
     });

+ 54 - 69
src/views/envmonitor/detail.vue

@@ -161,7 +161,7 @@ export default defineComponent({
       active: "",
       activeItem: activeItem,
       titleList: titleList,
-      query: query,
+      query: props.query ? props.query : query,
       parseImgUrl: parseImgUrl,
       /**
        * 加载loading
@@ -324,6 +324,7 @@ export default defineComponent({
         let xData: any = chartData.map((item: any) => {
           return item.time;
         });
+        let max: any = Math.max(...seriesData);
         if (xData && xData.length) {
           if (proxyData.checkIsData(seriesData)) {
             let options = {
@@ -358,7 +359,7 @@ export default defineComponent({
               yAxis: [
                 {
                   type: "value",
-                  max: chartMax,
+                  // max: chartMax,
                   axisTick: {
                     show: false,
                   },
@@ -381,89 +382,56 @@ export default defineComponent({
               ],
               series: [
                 {
-                  markLine: {
-                    symbol: "none",
-                    data: [
-                      {
-                        name: "均线",
-                        type: "max",
-                        yAxis: chartMax,
-                        lineStyle: {
-                          normal: {
-                            color: "red",
-                            width: 2,
-                            type: "solid",
+                  markLine:
+                    max >= chartMax
+                      ? {
+                          symbol: "none",
+                          data: [
+                            {
+                              name: "均线",
+                              type: "max",
+                              yAxis: chartMax,
+                              lineStyle: {
+                                normal: {
+                                  color: "red",
+                                  width: 2,
+                                  type: "solid",
+                                },
+                              },
+                            },
+                          ],
+                          label: {
+                            normal: {
+                              show: true,
+                              position: "middle",
+                              textStyle: {
+                                fontSize: 12,
+                                fontWeight: 600,
+                              },
+                            },
                           },
-                        },
-                      },
-                    ],
-                    label: {
-                      normal: {
-                        show: true,
-                        position: "middle",
-                        textStyle: {
-                          fontSize: 12,
-                          fontWeight: 600,
-                        },
-                      },
-                    },
-                  },
+                        }
+                      : {},
                   name: "CO₂",
                   type: "line",
                   smooth: true,
                   symbol: "circle",
                   symbolSize: 5,
                   showSymbol: false,
-                  lineStyle: {
-                    width: 2,
-                    color: new (echarts as any).graphic.LinearGradient(
-                      1,
-                      0,
-                      0,
-                      0,
-                      [
-                        {
-                          offset: 0,
-                          color: "rgba(229, 87, 79, 1)",
-                        },
-                        {
-                          offset: 0.5,
-                          color: "rgba(229, 87, 79, 1)",
-                        },
-                        {
-                          offset: 0.6,
-                          color: "rgba(79, 128, 255, 1)",
-                        },
-                        {
-                          offset: 1,
-                          color: "rgba(79, 128, 255, 1)",
-                        },
-                      ],
-                      false
-                    ),
-                  },
                   areaStyle: {
                     color: new (echarts as any).graphic.LinearGradient(
                       0,
-                      0,
                       1,
                       0,
+                      0,
                       [
                         {
                           offset: 0,
                           color: "rgba(79, 128, 255, 0.1)",
                         },
                         {
-                          offset: 0.5,
-                          color: "rgba(79, 128, 255, 0.3)",
-                        },
-                        {
-                          offset: 0.6,
-                          color: "rgba(229, 87, 79, 0.1)",
-                        },
-                        {
                           offset: 1,
-                          color: "rgba(229, 87, 79, 0.3)",
+                          color: "rgba(79, 128, 255, 0.6)",
                         },
                       ],
                       false
@@ -695,13 +663,26 @@ export default defineComponent({
         let max = 0;
         switch (funcid) {
           case "CO2":
-            max = dayTarget && dayTarget[0] && dayTarget[0].co2Max;
+            for (let i = 0; i < dayTarget.length; i++) {
+              if (dayTarget[i].co2Max) {
+                max = dayTarget[i].co2Max;
+              }
+            }
             break;
           case "PM2d5":
-            max = dayTarget && dayTarget[0] && dayTarget[0].pm25Max;
+            for (let i = 0; i < dayTarget.length; i++) {
+              if (dayTarget[i].pm25Max) {
+                max = dayTarget[i].pm25Max;
+              }
+            }
             break;
           case "HCHO":
-            max = dayTarget && dayTarget[0] && dayTarget[0].hchoMax;
+            // max = dayTarget && dayTarget[0] && dayTarget[0].hchoMax;
+            for (let i = 0; i < dayTarget.length; i++) {
+              if (dayTarget[i].hchoMax) {
+                max = dayTarget[i].hchoMax;
+              }
+            }
             break;
           case "RH":
             max = 0;
@@ -720,6 +701,8 @@ export default defineComponent({
       props,
       (newProps: any) => {
         proxyData.query = JSON.parse(JSON.stringify(newProps.query));
+        proxyData.setActiveItem();
+        proxyData.queryAllData();
         // 设置当前选中的tab
       },
       {
@@ -728,6 +711,8 @@ export default defineComponent({
       }
     );
     onMounted(() => {
+      // proxyData.setActiveItem();
+      // proxyData.queryAllData();
       // const route: any = useRoute();
       // if (route.query) {
       //   proxyData.query = route.query;

+ 19 - 6
src/views/envmonitor/index.vue

@@ -3,9 +3,8 @@
     <div class="main-left">
       <div class="left-top">
         <img
-          v-show="outWeather.imgname"
-          :src="outWeather.imgname"
-          class="weather-icon"
+          class="logo-icon"
+          :src="parseImgUrl('ipdImages', 'shangeyun_logo.svg')"
           alt=""
         />
         <div class="left-time">
@@ -13,7 +12,13 @@
           <span>{{ nowWeek }}</span>
         </div>
         <div class="weather">
-          {{ outWeather.temperature ? outWeather.temperature : "--" }}℃
+          <img
+            v-show="outWeather.imgname"
+            :src="outWeather.imgname"
+            class="weather-icon"
+            alt=""
+          />
+          <span>{{ outWeather.temperature ? outWeather.temperature : "--" }}℃</span>
         </div>
         <div class="weixiin" @click="showContact">
           <img :src="parseImgUrl('ipdImages', 'weixin.svg')" />
@@ -1582,7 +1587,7 @@ export default defineComponent({
           criteria: {
             //类型:Object  必有字段  备注:无
             projectId: proxyData.userInfo.projectId,
-            spaceName:'',
+            spaceName: "",
             macAddress: proxyData.userInfo.mac, //类型:String  必有字段  备注:mac地址
           },
           orders: [
@@ -1741,7 +1746,7 @@ export default defineComponent({
       white-space: nowrap;
       text-overflow: ellipsis;
       -o-text-overflow: ellipsis;
-      img {
+      .logo-icon {
         display: inline-block;
         vertical-align: middle;
         width: 60px;
@@ -1751,6 +1756,11 @@ export default defineComponent({
       .weather-icon {
         width: 24px;
         height: 24px;
+        margin-right: 10px;
+        display: inline-block;
+        vertical-align: middle;
+      }
+      span {
         display: inline-block;
         vertical-align: middle;
       }
@@ -1777,8 +1787,11 @@ export default defineComponent({
       .weixiin {
         margin-left: 10px;
         img {
+          margin-right: 5px;
           width: 24px;
           height: 24px;
+          display: inline-block;
+          vertical-align: middle;
         }
       }
     }

+ 5 - 2
src/views/home/index.vue

@@ -163,7 +163,10 @@ export default defineComponent({
               // 直接去环境条件页面
               // setLocalProjectId(projectId)
               store.commit(UserMutationTypes.SET_PROJECT_ID, projectId);
-              router.push({ name: "envmonitor", query: { spaceId: spaceId } });
+              router.push({
+                name: "choiceSpace",
+                query: { id: projectId, spaceId: spaceId },
+              });
             } else if (projectId) {
               // 去选择项目页面
               store.commit(UserMutationTypes.SET_PROJECT_ID, projectId);
@@ -176,7 +179,7 @@ export default defineComponent({
             }
             proxyData.timer = setTimeout(() => {
               proxyData.getPadQrCodeStatus();
-            }, 500);
+            }, 1000);
           }
         });
       },