Browse Source

fix: 温度调节

chenzhen2 2 years ago
parent
commit
11834590cf
2 changed files with 106 additions and 33 deletions
  1. 104 31
      src/views/envmonitor/components/Air/manualIndex.vue
  2. 2 2
      src/views/envmonitor/index.vue

+ 104 - 31
src/views/envmonitor/components/Air/manualIndex.vue

@@ -7,9 +7,14 @@
           {{ airTemp ? airTemp : "--" }}
           <sup>℃</sup>
         </p>
-        <div class="show-all" @click.stop="showAll">
+        <div
+          class="show-all"
+          @click.stop="showAll"
+          v-if="equipList && equipList.length > 1"
+        >
           <van-icon :name="lightIcon" class="light-icon" />
-          <span>显示全部</span>
+          <span v-if="!showChild">显示全部</span>
+          <span v-else>收取全部</span>
         </div>
       </div>
       <div class="air-right">
@@ -27,7 +32,10 @@
       </div>
     </div>
     <!--温度调节-->
-    <template v-if="!showChild">
+    <div
+      v-if="!showChild"
+      :style="{ opacity: loadingAir || !airData.runStatus ? '0.4' : '1' }"
+    >
       <div class="air-control air-control-padding">
         <div class="control-box">
           <div class="temp-text">{{ airData.minTempSet }}℃</div>
@@ -141,7 +149,7 @@
           </div>
         </div>
       </div>
-    </template>
+    </div>
 
     <!--子设备-->
     <div class="air-child" v-if="showChild">
@@ -153,14 +161,29 @@
         <div class="open-title">
           <span>{{ childItem.localName }}</span>
           <Switch
-            @click="airChange"
+            @click="changeChildItemAir('switch', childItem, 'switch')"
+            :loading="
+              childItem.loadingTimer > 0 && childItem.loadingTimer <= 15
+                ? true
+                : false
+            "
+            :disabled="
+              childItem.loadingTimer > 0 && childItem.loadingTimer <= 15
+                ? true
+                : false
+            "
             :model-value="childItem.isOpen"
             class="child-switch"
             inactive-color="rgba(196, 196, 196, 0.4)"
             size="25px"
           />
         </div>
-        <div class="adjust-box">
+        <div
+          class="adjust-box"
+          :style="{
+            opacity: childItem.runStatus && childItem.isOpen ? '' : '0.3',
+          }"
+        >
           <div class="adjust-item">
             <van-icon
               name="arrow-up"
@@ -303,6 +326,7 @@ export default defineComponent({
       workMode: 0, //1=cold(制冷);2=hot(制热);3=wind(通风)
       gear: 0, //  风量
       isOpen: false, // 空调开关 true 是开
+      runStatus: 0, // 查询设备的真实状态
     };
     const feedbackTimer: any = null;
     const airTimer: any = null;
@@ -326,6 +350,7 @@ export default defineComponent({
       firstLoadingAir: true,
       domAirOpeen: domAirOpeen,
       feedbackTimer: feedbackTimer,
+      swiperIinit: false,
       parseImgUrl: parseImgUrl,
       part: 1,
       airData: airData,
@@ -362,6 +387,7 @@ export default defineComponent({
       },
       // 滑动
       endBoxSwiper() {
+        proxyData.swiperIinit = true;
         let handBox: any = document.querySelector("#handId");
         let barBox: any = document.querySelector("#barId");
         let sliderBox: any = document.querySelector("#sliderId");
@@ -437,10 +463,11 @@ export default defineComponent({
       setLoadingNumber() {
         let timer: any = setInterval(() => {
           proxyData.loadingTimer++;
-          if (proxyData.loadingTimer > 15) {
+          console.log(proxyData.loadingTimer);
+          if (proxyData.loadingTimer >= 15) {
             clearInterval(timer);
             proxyData.loadingAir = false;
-            proxyData.getAirInfoToTimer(3000);
+            proxyData.getAirInfoToTimer(0);
           }
         }, 1000);
       },
@@ -497,11 +524,52 @@ export default defineComponent({
       loadinngEnd() {
         proxyData.cotrolLoading = false;
       },
+      // 计算loading时间
+      setChildLoadingNumber(childItem: any) {
+        childItem.loadingTimer = 1;
+        let timer: any = setInterval(() => {
+          childItem.loadingTimer++;
+          if (childItem.loadingTimer >= 15) {
+            clearInterval(timer);
+            childItem.loadingTimer = 0;
+            proxyData.getAirInfoToTimer(0);
+          }
+          console.log("===");
+          console.log(childItem.loadingTimer);
+        }, 1000);
+      },
+      // 连续点击2秒内未点击才发指令
+      childDisabled(childItem: any, data: any) {
+        clearTimeout(childItem.timeOuter);
+        childItem.timeOuter = setInterval(() => {
+          childItem.num--;
+          if (childItem.num == 0) {
+            proxyData.setSpaceCondtioners(data);
+            clearTimeout(childItem.timeOuter);
+          }
+        }, 1000);
+      },
       // 子设备降低温度
       changeChildItemAir(btnType: any, childItem: any, symbol: any) {
-        proxyData.loadingStart();
+        if (!childItem.isOpen && btnType !== "switch") {
+          return;
+        }
         let arr: any = [];
-        if (btnType === "temp") {
+        if (btnType === "switch") {
+          if (childItem.loadingTimer >= 1 && childItem.loadingTimer <= 15) {
+            return;
+          }
+          childItem.isOpen = !childItem.isOpen;
+          proxyData.setChildLoadingNumber(childItem);
+          let obj: any = {
+            id: childItem.id, //类型:String  必有字段  备注:设备id
+            code: childItem.switchCode, //类型:String  必有字段  备注:编码 EquipSwtichSet
+            value: childItem.isOpen ? "1" : "0", //类型:String  必有字段  备注:值 0
+          };
+          arr.push(obj);
+          // loadig的状态
+        } else if (btnType === "temp") {
+          childItem.num = 2;
           if (
             childItem.tempSet <= proxyData.airData.minTempSet ||
             childItem.tempSet >= proxyData.airData.maxTempSet
@@ -513,13 +581,13 @@ export default defineComponent({
           } else if (symbol === "down") {
             childItem.tempSet = childItem.tempSet - 0.5;
           }
-
           let obj: any = {
             id: childItem.id, //类型:String  必有字段  备注:设备id
             code: childItem.tempSetCode, //类型:String  必有字段  备注:编码 EquipSwtichSet
             value: childItem.tempSet, //类型:String  必有字段  备注:值 0
           };
           arr.push(obj);
+          proxyData.childDisabled(childItem, arr);
         } else if (btnType === "gear") {
           if (symbol === "up") {
             if (childItem.gear >= 3) {
@@ -559,11 +627,10 @@ export default defineComponent({
         }
         console.log("====");
         console.log(arr);
-
-        // if (!proxyData.cotrolLoading) {
-        //   console.log("====")
-        //   console.log(arr)
-        // }
+        // 修改单个设备的状态
+        if (btnType !== "temp") {
+          proxyData.setSpaceCondtioners(arr);
+        }
       },
       // 改变设备状态
       setSpaceCondtioners(data: any) {
@@ -579,7 +646,7 @@ export default defineComponent({
       },
       // 改变空调状态
       changeZongAir(btnType: any, text: any) {
-        if (!this.airData.isOpen) return;
+        if (!airData.runStatus) return;
         let equpObj: any = proxyData.formatAirData(btnType, text);
         if (equpObj.value) {
           let data: any = [];
@@ -606,6 +673,8 @@ export default defineComponent({
         proxyData.airData.isOpen = !proxyData.airData.isOpen;
         proxyData.loadingAir = true;
         proxyData.loadingTimer = 0;
+        clearTimeout(proxyData.airTimer);
+        proxyData.setLoadingNumber();
         let data: any = [];
         proxyData.equipList.map((item: any) => {
           let obj: any = {
@@ -615,8 +684,6 @@ export default defineComponent({
           };
           data.push(obj);
         });
-        clearTimeout(proxyData.airTimer);
-        proxyData.setLoadingNumber();
         // 设备状态处理
         proxyData.setSpaceCondtioners(data);
       },
@@ -645,6 +712,7 @@ export default defineComponent({
             proxyData.airData.maxTempSet = data.maxTempSet;
             proxyData.airData.minTempSet = data.minTempSet;
             proxyData.airData.isOpen = data.runStatus ? true : false;
+            proxyData.airData.runStatus = data.runStatus;
             proxyData.airData.isAutoGear = data.isAutoGear;
             proxyData.airData.gear = data.gear;
             proxyData.airData.workMode = data.workMode;
@@ -652,7 +720,6 @@ export default defineComponent({
             // 设置子设备的状态
             proxyData.formateSetChildStatus();
             // 设置当前温度的位置
-            proxyData.setBarNowPerstion();
             if (proxyData.airData.isOpen) {
               proxyData.airData.airImg = parseImgUrl(
                 "page-officehome",
@@ -665,23 +732,29 @@ export default defineComponent({
               );
             }
 
-            if (data.equipList && data.equipList.length > 1) {
+            if (proxyData.airData.isOpen) {
+              if (!proxyData.swiperIinit) {
+                nextTick(() => {
+                  proxyData.endBoxSwiper();
+                  proxyData.setBarNowPerstion();
+                });
+              } else {
+                proxyData.setBarNowPerstion();
+              }
             }
+
             proxyData.getAirInfoToTimer(3000);
           })
           .catch(() => {});
       },
     });
-    nextTick(() => {
-      proxyData.endBoxSwiper();
-    }),
-      watch(props, (newProps: any) => {
-        if (newProps.spaceId) {
-        }
-        proxyData.temperature = props.temperature;
-        proxyData.userIsControl = newProps.userIsControl;
-        proxyData.forceOverTimeFlag = newProps.forceOverTimeFlag;
-      });
+    watch(props, (newProps: any) => {
+      if (newProps.spaceId) {
+      }
+      proxyData.temperature = props.temperature;
+      proxyData.userIsControl = newProps.userIsControl;
+      proxyData.forceOverTimeFlag = newProps.forceOverTimeFlag;
+    });
     onBeforeUnmount(() => {
       if (proxyData.airTimer) {
         clearTimeout(proxyData.airTimer);

+ 2 - 2
src/views/envmonitor/index.vue

@@ -50,7 +50,7 @@
           <div>
             {{ officeData.localName }}
           </div>
-          <div
+          <!-- <div
             v-if="
               officeData.isPassengerPass === true ||
               officeData.isPassengerPass === false
@@ -66,7 +66,7 @@
             />
             <span v-if="officeData.isPassengerPass">有人</span>
             <span v-if="!officeData.isPassengerPass">无人</span>
-          </div>
+          </div> -->
         </div>
         <div class="space-info">
           <div class="space-temp">