浏览代码

fix: 手动控制的bug修改

chenzhen2 2 年之前
父节点
当前提交
509a70d356
共有 2 个文件被更改,包括 239 次插入100 次删除
  1. 235 99
      src/views/envmonitor/components/Air/manualIndex.vue
  2. 4 1
      src/views/envmonitor/index.vue

+ 235 - 99
src/views/envmonitor/components/Air/manualIndex.vue

@@ -196,7 +196,24 @@
               @click="changeChildItemAir('temp', childItem, 'up')"
               class="adjust-icon"
             />
-            <span class="adjust-text">{{ childItem.tempSet }}</span>
+            <div class="adjust-text">
+              <div
+                class="value-wrap"
+                :style="{
+                  transform: valueHeight
+                    ? 'translateY(' + -childItem.sel * valueHeight + 'px)'
+                    : 'translateY(0px)',
+                }"
+              >
+                <div
+                  class="value"
+                  :key="index + 'ct'"
+                  v-for="(titem, index) in childItem.tempArr"
+                >
+                  {{ titem }}
+                </div>
+              </div>
+            </div>
             <van-icon
               name="arrow-down"
               :class="
@@ -214,9 +231,24 @@
               @click="changeChildItemAir('gear', childItem, 'up')"
               class="adjust-icon"
             />
-            <span class="adjust-text">{{
-              childItem.isAutoGear ? "AUTO" : childItem.gear
-            }}</span>
+            <div class="adjust-text">
+              <div
+                class="value-wrap"
+                :style="{
+                  transform: valueHeight
+                    ? 'translateY(' + -childItem.gIndex * valueHeight + 'px)'
+                    : 'translateY(0px)',
+                }"
+              >
+                <div
+                  class="value"
+                  v-for="(gItem, index) in childItem.gearArr"
+                  :key="index + 'g'"
+                >
+                  {{ gItem }}
+                </div>
+              </div>
+            </div>
             <van-icon
               name="arrow-down"
               :class="
@@ -236,15 +268,24 @@
               @click="changeChildItemAir('model', childItem, 'up')"
               class="adjust-icon"
             />
-            <span class="adjust-text">
-              {{
-                childItem.workMode == 1
-                  ? "制冷"
-                  : childItem.workMode == 2
-                  ? "制热"
-                  : "通风"
-              }}
-            </span>
+            <div class="adjust-text">
+              <div
+                class="value-wrap"
+                :style="{
+                  transform: valueHeight
+                    ? 'translateY(' + -childItem.mIndex * valueHeight + 'px)'
+                    : 'translateY(0px)',
+                }"
+              >
+                <div
+                  class="value"
+                  v-for="(mItem, index) in childItem.modelArr"
+                  :key="index + 'm'"
+                >
+                  {{ mItem }}
+                </div>
+              </div>
+            </div>
             <van-icon
               name="arrow-down"
               :class="childItem.workMode <= 1 ? 'disable-color' : ''"
@@ -343,7 +384,13 @@ export default defineComponent({
     let realTemp: any = 16;
     let windGearArr: any = [0, 1, 2, 3];
     let equipList: any = [];
+    let valueDom: any = null;
+    let valueHeight: any = null;
+    let spaceId: any = "";
     const proxyData = reactive({
+      valueDom: valueDom,
+      spaceId: spaceId,
+      valueHeight: valueHeight,
       equipList: equipList,
       cotrolLoading: false,
       loadingTimer: 0,
@@ -358,7 +405,6 @@ export default defineComponent({
       forceOverTimeFlag: props.forceOverTimeFlag,
       firstLoadingAir: true,
       domAirOpeen: domAirOpeen,
-      feedbackTimer: feedbackTimer,
       swiperIinit: false,
       parseImgUrl: parseImgUrl,
       part: 1,
@@ -376,19 +422,33 @@ export default defineComponent({
         designTemperature: 0,
       },
       // 点击展示所有的登录
-      showAll() {
+      async showAll() {
         proxyData.showChild = !proxyData.showChild;
         if (proxyData.lightIcon === "arrow-up") {
           proxyData.lightIcon = "arrow-down";
         } else {
           proxyData.lightIcon = "arrow-up";
         }
-        proxyData.barSwiperInit();
+
+        if (proxyData.showChild) {
+          await nextTick(() => {
+            proxyData.setChildSelectList();
+          });
+        } else {
+          await nextTick(() => {
+            proxyData.barSwiperInit();
+          });
+        }
+
+        // proxyData.getAirInfoToTimer(0);
       },
       // 设置温度条的位置
       setBarNowPerstion() {
-        // proxyData.airTemp=14
+        proxyData.realTemp = proxyData.airTemp;
         let barBox: any = document.querySelector("#barId");
+        if (!barBox) {
+          return;
+        }
         let sliderBox: any = document.querySelector("#sliderId");
         if (
           proxyData.airTemp >= proxyData.airData.minTempSet &&
@@ -399,20 +459,20 @@ export default defineComponent({
             ((proxyData.airTemp - proxyData.airData.minTempSet) / 0.5) *
             proxyData.part;
           left = Math.floor(left);
-
           if (barBox) {
             barBox.style.left = left + "px";
           }
         } else {
-          if (proxyData.airTemp < proxyData.airData.minTempSet) {
+          if (!proxyData.airTemp) {
             barBox.style.left = 0 + "px";
-          } else {
+          } else if (proxyData.airTemp < proxyData.airData.minTempSet) {
+            barBox.style.left = 0 + "px";
+          } else if (proxyData.airTemp > proxyData.airData.maxTempSet) {
             let sliderWidth: any = sliderBox.offsetWidth;
             let barWidth: any = barBox.offsetWidth;
-            barBox.style.left = (sliderWidth-barWidth) + "px";
+            barBox.style.left = sliderWidth - barWidth + "px";
           }
         }
-        proxyData.realTemp = proxyData.airTemp;
       },
       // 滑动
       endBoxSwiper() {
@@ -422,65 +482,58 @@ export default defineComponent({
         let sliderBox: any = document.querySelector("#sliderId");
         let isMove: any = false;
         let barLeft: any = 0;
-        let sliderWidth: any = sliderBox.offsetWidth;
-        let barWidth: any = barBox.offsetWidth;
+        let sliderWidth: any = sliderBox ? sliderBox.offsetWidth : 1;
+        let barWidth: any = barBox ? barBox.offsetWidth : 20;
         let tempPart =
           (proxyData.airData.maxTempSet - proxyData.airData.minTempSet) / 20;
         let part: any = 0.5 / (tempPart / (Math.floor(sliderWidth) / 22));
         proxyData.part = part;
+        if (!handBox) {
+          return;
+        }
         handBox.addEventListener("touchstart", function (e: any) {
           barLeft = isNaN(parseInt(barBox.style.left))
             ? 0
             : parseInt(barBox.style.left);
-          isMove = false;
+          isMove = true;
         });
         handBox.addEventListener("touchend", function (e: any) {
+          isMove = false;
           proxyData.changeZongAir("temp", proxyData.realTemp);
         });
         swiper(handBox, {
           swipeLeft: function (e: any) {
-            barLeft = Math.abs(barLeft);
-            let moveRealX: any = Math.abs(e.mation.moveX - e.mation.startX);
-            let left: any = barLeft - moveRealX;
-            left = left < 0 ? 0 : left;
-            barBox.style.left = left + "px";
-            proxyData.realTemp =
-              proxyData.airData.minTempSet + Math.ceil(left / part) * 0.5;
+            if (isMove) {
+              barLeft = Math.abs(barLeft);
+              let moveRealX: any = Math.abs(e.mation.moveX - e.mation.startX);
+              let left: any = barLeft - moveRealX;
+              left = left < 0 ? 0 : left;
+              barBox.style.left = left + "px";
+              proxyData.realTemp =
+                proxyData.airData.minTempSet + Math.ceil(left / part) * 0.5;
+            }
           },
           swipeRight: function (e: any) {
-            barLeft = Math.abs(barLeft);
-            let moveRealX: any = Math.abs(e.mation.moveX - e.mation.startX);
-            let left: any = barLeft + moveRealX;
-            left = left > sliderWidth ? sliderWidth - barWidth : left;
-            barBox.style.left = left + "px";
-            proxyData.realTemp =
-              proxyData.airData.minTempSet + Math.ceil(left / part) * 0.5;
-            if (proxyData.realTemp > proxyData.airData.maxTempSet) {
-              proxyData.realTemp = proxyData.airData.maxTempSet;
+            if (isMove) {
+              barLeft = Math.abs(barLeft);
+              let moveRealX: any = Math.abs(e.mation.moveX - e.mation.startX);
+              let left: any = barLeft + moveRealX;
+              left = left > sliderWidth ? sliderWidth - barWidth : left;
+              barBox.style.left = left + "px";
+              proxyData.realTemp =
+                proxyData.airData.minTempSet + Math.ceil(left / part) * 0.5;
+              if (proxyData.realTemp > proxyData.airData.maxTempSet) {
+                proxyData.realTemp = proxyData.airData.maxTempSet;
+              }
             }
           },
         });
       },
-      // 格式化模式
-      formateModel(childItem: any) {
-        if (childItem.workMode) {
-          if (childItem.workMode == 1) {
-            childItem.modeName = "制冷";
-          } else if (childItem.workMode == 2) {
-            childItem.modeName = "制热";
-          } else if (childItem.workMode == 3) {
-            childItem.modeName = "通风";
-          } else if (childItem.workMode == 4) {
-            childItem.modeName = "AUTO";
-          }
-        } else {
-          childItem.modeName = "";
-        }
-      },
       // 定时获取空调状态
-      getAirInfoToTimer(timerLong: any = 15000) {
+      getAirInfoToTimer(timerLong: any = 10000) {
         if (proxyData.airTimer) {
           clearTimeout(proxyData.airTimer);
+          proxyData.airTimer = null;
         }
         proxyData.airTimer = setTimeout(function () {
           proxyData.getAirInfo();
@@ -528,7 +581,7 @@ export default defineComponent({
           }
         }
         if (btnType == "gear" && text == "auto") {
-          proxyData.airData.isAutoGear = 1;
+          proxyData.airData.isAutoGear = proxyData.airData.isAutoGear ? 0 : 1;
           obj.value = proxyData.airData.isAutoGear ? 4 : proxyData.airData.gear;
           obj.codeKey = "gearCode";
         }
@@ -597,15 +650,15 @@ export default defineComponent({
           // loadig的状态
         } else if (btnType === "temp") {
           childItem.num = 2;
-          if (
-            childItem.tempSet <= proxyData.airData.minTempSet ||
-            childItem.tempSet >= proxyData.airData.maxTempSet
-          ) {
-            return;
-          }
           if (symbol === "up") {
+            if (childItem.tempSet >= proxyData.airData.maxTempSet) {
+              return;
+            }
             childItem.tempSet = childItem.tempSet + 0.5;
           } else if (symbol === "down") {
+            if (childItem.tempSet <= proxyData.airData.minTempSet) {
+              return;
+            }
             childItem.tempSet = childItem.tempSet - 0.5;
           }
           let obj: any = {
@@ -662,12 +715,11 @@ export default defineComponent({
           };
           arr.push(obj);
         }
-        console.log("====");
-        console.log(arr);
         // 修改单个设备的状态
         if (btnType !== "temp") {
           proxyData.setSpaceCondtioners(arr);
         }
+        proxyData.updateChildPerstion();
       },
       // 改变设备状态
       setSpaceCondtioners(data: any) {
@@ -685,23 +737,21 @@ export default defineComponent({
       changeZongAir(btnType: any, text: any) {
         if (!airData.runStatus) return;
         let equpObj: any = proxyData.formatAirData(btnType, text);
-        if (equpObj.value) {
-          let data: any = [];
-          proxyData.equipList.map((item: any) => {
-            let obj: any = {
-              id: item.id, //类型:String  必有字段  备注:设备id
-              code: item[equpObj.codeKey], //类型:String  必有字段  备注:编码 EquipSwtichSet
-              value: equpObj.value, //类型:String  必有字段  备注:值 0
-            };
-            data.push(obj);
-          });
-          console.log("设备数据处理---");
-          console.log(data);
-          if (!proxyData.cotrolLoading) {
-            proxyData.loadingStart();
-            // 调整设备状态
-            proxyData.setSpaceCondtioners(data);
-          }
+        let data: any = [];
+        proxyData.equipList.map((item: any) => {
+          let obj: any = {
+            id: item.id, //类型:String  必有字段  备注:设备id
+            code: item[equpObj.codeKey], //类型:String  必有字段  备注:编码 EquipSwtichSet
+            value: equpObj.value, //类型:String  必有字段  备注:值 0
+          };
+          data.push(obj);
+        });
+        console.log("设备数据处理---");
+        console.log(data);
+        if (!proxyData.cotrolLoading) {
+          proxyData.loadingStart();
+          // 调整设备状态
+          proxyData.setSpaceCondtioners(data);
         }
       },
       // 总控制改变空调状态
@@ -731,27 +781,94 @@ export default defineComponent({
         });
       },
       // 初始化滚动
-      barSwiperInit() {
+      async barSwiperInit() {
         if (proxyData.airData.isOpen && !proxyData.showChild) {
           if (!proxyData.swiperIinit) {
-            nextTick(() => {
+            await nextTick(() => {
               proxyData.endBoxSwiper();
               proxyData.setBarNowPerstion();
             });
           } else {
-            nextTick(() => {
+            await nextTick(() => {
               proxyData.setBarNowPerstion();
             });
           }
         }
       },
+      // 设置子设备的可调范围
+      setChildSelectList() {
+        proxyData.equipList.map((item: any) => {
+          let tempArr: any = [];
+          for (
+            let i = proxyData.airData.minTempSet;
+            i <= proxyData.airData.maxTempSet;
+            i = i + 0.5
+          ) {
+            tempArr.push(i);
+          }
+          item.tempArr = tempArr;
+          let index: any = item.tempArr.findIndex((ele: any) => {
+            return ele == item.tempSet;
+          });
+          item.sel = index == -1 ? 0 : index;
+
+          let modelArr: any = ["制冷", "制热", "通风"];
+          item.modelArr = modelArr;
+          let mIndex: any = item.workMode ? item.workMode - 1 : 2;
+          item.mIndex = mIndex;
+
+          let gearArr: any = [0, 1, 2, 3, "AUTO"];
+          item.gearArr = gearArr;
+          let gIndex: any = item.gearArr.findIndex((ele: any) => {
+            if (item.isAutoGear == 1) {
+              return ele == "AUTO";
+            } else {
+              return ele == item.gear;
+            }
+          });
+          item.gIndex = gIndex == -1 ? 0 : gIndex;
+        });
+        proxyData.setValueHeight();
+      },
+      setValueHeight() {
+        if (!proxyData.valueHeight) {
+          proxyData.valueDom = proxyData.valueDom
+            ? proxyData.valueDom
+            : document.querySelectorAll(".value")[0];
+          proxyData.valueHeight = proxyData.valueDom
+            ? proxyData.valueDom.offsetHeight
+            : 0;
+        }
+        console.log("proxyData.valueHeight==", proxyData.valueHeight);
+      },
+      // 改变子设备选中的位置
+      updateChildPerstion() {
+        proxyData.equipList.map((item: any) => {
+          let index: any = item.tempArr.findIndex((ele: any) => {
+            return ele == item.tempSet;
+          });
+          item.sel = index == -1 ? 0 : index;
+
+          let mIndex: any = item.workMode ? item.workMode - 1 : 2;
+          item.mIndex = mIndex;
+
+          let gIndex: any = item.gearArr.findIndex((ele: any) => {
+            if (item.isAutoGear == 1) {
+              return ele == "AUTO";
+            } else {
+              return ele == item.gear;
+            }
+          });
+          item.gIndex = gIndex == -1 ? 0 : gIndex;
+        });
+      },
       // 空调信息airTemp
       getAirInfo() {
         const paramObj = {
           // // projectId: props.projectId, //'Pj1101080255'
           // projectId: "Pj1101080255",
           // spaceId: "Sp110108025564f438d7fef64eea8202a6462f1bbcce",
-          spaceId: props.spaceId,
+          spaceId: proxyData.spaceId,
           // spaceId: props.spaceId,//'Sp110108025564f438d7fef64eea8202a6462f1bbcce' 空间id
         };
         //wx.showLoading();
@@ -771,7 +888,9 @@ export default defineComponent({
             proxyData.airData.workMode = data.workMode;
             proxyData.equipList = data.equipList;
             // 设置子设备的状态
+            proxyData.setChildSelectList();
             proxyData.formateSetChildStatus();
+
             // 设置当前温度的位置
             if (proxyData.airData.isOpen) {
               proxyData.airData.airImg = parseImgUrl(
@@ -784,6 +903,7 @@ export default defineComponent({
                 "air_close.png"
               );
             }
+
             proxyData.barSwiperInit();
             proxyData.getAirInfoToTimer();
           })
@@ -792,24 +912,24 @@ export default defineComponent({
     });
     watch(props, (newProps: any) => {
       if (newProps.spaceId) {
-        // proxyData.getAirInfo();
+        // proxyData.swiperIinit = false;
+        proxyData.spaceId = newProps.spaceId;
+        // proxyData.getAirInfoToTimer(0);
+        proxyData.temperature = props.temperature;
+        proxyData.userIsControl = newProps.userIsControl;
+        proxyData.forceOverTimeFlag = newProps.forceOverTimeFlag;
       }
-      proxyData.temperature = props.temperature;
-      proxyData.userIsControl = newProps.userIsControl;
-      proxyData.forceOverTimeFlag = newProps.forceOverTimeFlag;
     });
     onBeforeUnmount(() => {
       if (proxyData.airTimer) {
         clearTimeout(proxyData.airTimer);
         proxyData.airTimer = null;
       }
-      if (proxyData.feedbackTimer) {
-        clearTimeout(proxyData.feedbackTimer);
-        proxyData.feedbackTimer = null;
-      }
     });
     onMounted(() => {
-      proxyData.getAirInfo();
+      proxyData.spaceId = props.spaceId;
+      proxyData.getAirInfoToTimer(0);
+      console.log("切换空间===");
       // 获取空调信息
     });
     return {
@@ -909,8 +1029,24 @@ export default defineComponent({
           flex: 1;
         }
         .adjust-text {
-          flex: 1;
-          padding: 20px 0;
+          // flex: 1;
+          // padding: 20px 0;
+          height: 50px;
+          overflow: hidden;
+          color: #1f2429;
+          .value-wrap {
+            transition: transform 1s;
+            .value {
+              width: 100%;
+              height: 50px;
+              display: flex;
+              align-items: center;
+              //font-weight: 600;
+              justify-content: center;
+              text-align: center;
+              font-size: 14px;
+            }
+          }
         }
         .adjust-title {
           padding-top: 10px;

+ 4 - 1
src/views/envmonitor/index.vue

@@ -69,7 +69,7 @@
           </div> -->
         </div>
         <div class="space-info">
-          <div class="space-temp" >
+          <div class="space-temp">
             <img :src="parseImgUrl('ipdImages', 'template-icon.svg')" alt="" />
             <span class="temp-text">温度</span>
             <span class="temp-num" v-if="officeData.temperature"
@@ -1752,7 +1752,10 @@ export default defineComponent({
         proxyData.spaceData.map((item: any) => {
           item.active = false;
         });
+        proxyData.controlMode = 0; // 模式变成自动的
         proxyData.roomType = "";
+        proxyData.officeData.temperature = "";
+        proxyData.spaceExistenceDevice = spaceExistenceDevice;
         //  切换空间的时候把加班按钮平板
         proxyData.setForceOverTimeFlag(false);
         proxyData.isWork = false;