chenzhen2 1 éve
szülő
commit
7192cdfcf3

+ 21 - 5
src/views/envmonitor/components/FloorHeating/ChildTempSet.vue

@@ -64,9 +64,26 @@ export default defineComponent({
       part: 0,
       floorData: props.floorData,
       swiperIinit: false,
-      // 状态控制调整
-      setSpaceContrl(data: any) {
-        setSpaceCondtioners(data).then((res: any) => {});
+      // 改变空调状态(child)
+      changeChildTemp() {
+        let data: any = [];
+        let obj: any = {
+          id: proxyData.floorData.id, //类型:String  必有字段  备注:设备id
+          code: proxyData.floorData.tempSetCode, //类型:String  必有字段  备注:编码 EquipSwtichSet
+          value: proxyData.realTemp, //类型:String  必有字段  备注:值 0
+        };
+        data.push(obj);
+        console.log(data);
+        proxyData.setSpaceCondtioners(data);
+      },
+      // 改变设备状态
+      setSpaceCondtioners(data: any) {
+        console.log("调节数据", data);
+        // setSpaceCondtioners(data)
+        //   .then((res) => {})
+        //   .catch(() => {
+        //     Toast("连接异常,请检查网络!");
+        //   });
       },
       getEleWidth(ele: any) {
         // debugger;
@@ -108,8 +125,7 @@ export default defineComponent({
         });
         handBox.addEventListener("touchend", function (e: any) {
           isMove = false;
-          // proxyData.changeZongAir("temp", proxyData.realTemp);
-          // proxyData.heatingTemp = proxyData.realTemp;
+          proxyData.changeChildTemp();
         });
         swiper(handBox, {
           swipeLeft: function (e: any) {

+ 99 - 266
src/views/envmonitor/components/FloorHeating/index.vue

@@ -40,6 +40,10 @@
         <Switch
           class="switch-btn"
           size="18px"
+          :loading="loadingFlag"
+          :disabled="loadingFlag"
+          :model-value="isOpen"
+          @click.stop="eqChangeSwitch('main', floorHeatingList[0])"
           inactive-color="rgba(196, 196, 196, 0.4)"
         />
       </div>
@@ -65,7 +69,7 @@
     <!--灯控制按钮-->
     <div class="line" v-if="navType == 'child'"></div>
     <div class="light-box" v-if="navType == 'child'">
-      <template v-for="(item, index) in floorHeatingList" :key="item.id">
+      <template v-for="item in floorHeatingList" :key="item.id">
         <div class="light-control">
           <div class="control-top">
             <div class="control-temp">
@@ -78,7 +82,7 @@
               v-model="item.switch"
               :loading="item.loading"
               size="14px"
-              @click.stop="eqChange('main', item, index)"
+              @click.stop="eqChangeSwitch('child', item)"
               inactive-color="rgba(196, 196, 196, 0.2)"
               class="child-switch"
             />
@@ -89,7 +93,7 @@
             </div>
             <img
               @click="showFloorHeating(item)"
-              :style="{ opacity: item.switch ? '1' : '1' }"
+              :style="{ opacity: item.switch ? '1' : '0.3' }"
               :src="lightColorImg"
               alt=""
             />
@@ -119,6 +123,7 @@ import {
   getStatusHttp,
   querySapceFloorHeating,
   setallLampHttp,
+  setSpaceCondtioners,
 } from "@/apis/envmonitor";
 import { parseImgUrl, setQueryConfig } from "@/utils";
 import { type } from "os";
@@ -182,13 +187,14 @@ export default defineComponent({
       lightParams: lightParams,
       heatingData: heatingData,
       heatingTemp: 35,
+      isOpen: false,
       parseImgUrl: parseImgUrl,
       allowSvg: "down_Arrow.svg",
       timeOut: timeOut,
       lightIcon: "arrow-down",
       loadMore: false,
       loadingLight: false,
-      loading: false,
+      loadingFlag: false,
       initData: initData,
       floorHeatingList: floorHeatingList,
       floorHeatingData: floorHeatingData,
@@ -201,20 +207,91 @@ export default defineComponent({
       part: 1,
       realTemp: 0,
       navType: "all",
+      runStatus: 0,
       showFloorHeating(floorHeatingItem: any) {
         let item: any = floorHeatingItem;
+        if (!item.switch) {
+          Toast("请先开启地暖,才可温度调节!");
+          return;
+        }
         item.minTempSet = proxyData.floorHeatingData.minTempSet;
         item.maxTempSet = proxyData.floorHeatingData.maxTempSet;
         contx.emit("showFloorHeating", item);
       },
-      getElePading(ele: any, elePadingKey: any) {
-        let style: any = getComputedStyle(ele, null);
-        if (style) {
-          return parseFloat(style.getPropertyValue(elePadingKey));
+      // 改变空调状态(main)
+      changeZongAir(text: any) {
+        if (text == "temp" && !proxyData.runStatus) {
+          return;
+        }
+        proxyData.runStatus = proxyData.isOpen ? 1 : 0;
+        let data: any = [];
+        proxyData.floorHeatingList.map((item: any) => {
+          let code: any = text == "temp" ? item.tempSetCode : item.switchCode;
+          let value: any =
+            text == "temp" ? proxyData.realTemp : proxyData.runStatus;
+          let obj: any = {
+            id: item.id, //类型:String  必有字段  备注:设备id
+            code: code, //类型:String  必有字段  备注:编码 EquipSwtichSet
+            value: value, //类型:String  必有字段  备注:值 0
+          };
+          data.push(obj);
+        });
+        if (!proxyData.loadingFlag) {
+          // 调整设备状态
+          proxyData.setSpaceCondtioners(data);
+        }
+      },
+      // 改变空调状态(child)
+      changeChildZongAir(text: any, item: any) {
+        let runStatus: any = item.switch ? 1 : 0;
+        let data: any = [];
+        proxyData.floorHeatingList.map((item: any) => {
+          let code: any = text == "temp" ? item.tempSetCode : item.switchCode;
+          let value: any = text == "temp" ? proxyData.realTemp : runStatus;
+          let obj: any = {
+            id: item.id, //类型:String  必有字段  备注:设备id
+            code: code, //类型:String  必有字段  备注:编码 EquipSwtichSet
+            value: value, //类型:String  必有字段  备注:值 0
+          };
+          data.push(obj);
+        });
+        console.log(data);
+        if (!item.loading) {
+          // 调整设备状态
+          proxyData.setSpaceCondtioners(data, item);
+        }
+      },
+      // 改变设备状态
+      setSpaceCondtioners(data: any, item: any = null) {
+        console.log("调节数据", data);
+        setSpaceCondtioners(data)
+          .then((res) => {
+            proxyData.loading = false;
+            if (item) {
+              item.loading = false;
+            }
+          })
+          .catch(() => {
+            proxyData.loading = false;
+            item.loading = false;
+            Toast("连接异常,请检查网络!");
+          });
+      },
+      // 地暖开关
+      eqChangeSwitch(type: any, item: any) {
+        if (type == "main") {
+          proxyData.isOpen = !proxyData.isOpen;
+          proxyData.loading = true;
+          proxyData.changeZongAir("switch");
         } else {
-          return 0;
+          item.loading = true;
+          proxyData.changeChildZongAir("switch", item);
         }
       },
+      // 设置地暖温度
+      eqChangeTemp() {
+        proxyData.changeZongAir("temp");
+      },
       // 子设备导航切换
       checkNav(type: any = "all") {
         proxyData.navType = type;
@@ -260,8 +337,7 @@ export default defineComponent({
         });
         handBox.addEventListener("touchend", function (e: any) {
           isMove = false;
-          // proxyData.changeZongAir("temp", proxyData.realTemp);
-          // proxyData.heatingTemp = proxyData.realTemp;
+          proxyData.eqChangeTemp();
         });
         swiper(handBox, {
           swipeLeft: function (e: any) {
@@ -396,262 +472,19 @@ export default defineComponent({
             proxyData.startLightsStatusTimer();
           });
       },
-      // 调整灯
-      eqChange(type: any, item: any, index: any) {
-        if (proxyData.userIsControl) {
-          // debugger
-          if (type === "allLamp") {
-            let isExeSpaceTime: Boolean = proxyData.checkDeviceIsExeSpaceTime(
-              proxyData.floorHeatingList
-            );
-            if (item !== "") {
-              proxyData.lampSw = item; // 点击全开和全关的时候item动态传值true或者false
-            }
-
-            if (
-              proxyData.forceOverTimeFlag &&
-              proxyData.lampSw &&
-              isExeSpaceTime
-            ) {
-              // 强制加班开灯
-              contx.emit("triggerWork", 3);
-              return;
-            }
-            //  总开关按钮所有灯
-            //  当前要执行的灯的操作
-            proxyData.loading = true;
-            proxyData.loadingLight = true;
-            proxyData.lightImg = proxyData.lampSw
-              ? parseImgUrl("page-officehome", "lamp_open.png")
-              : parseImgUrl("page-officehome", "lamp_close.png");
-            const statusFlag = proxyData.lampSw;
-            // 瞬间修改状态
-            proxyData.setStatus = true;
-            proxyData.updateAllLampStatus(statusFlag);
-            proxyData.setLamp(type, "", statusFlag, 0); // 调接口
-          } else {
-            let isExeSpaceTime: Boolean = proxyData.checkDeviceIsExeSpaceTime([
-              item,
-            ]);
-            if (proxyData.forceOverTimeFlag && item.switch && isExeSpaceTime) {
-              // 强制加班开灯
-              contx.emit("triggerWork", 3, item);
-              return;
-            }
-            //当前要执行的灯的操作
-            // 按钮loading
-            item.loading = true;
-            const statusFlag: any = item.switch;
-            let id = item.id;
-            proxyData.setStatus = true;
-            proxyData.updateLampStatus(item, statusFlag);
-            proxyData.setLamp(type, id, statusFlag, index, item); // 调接口
-          }
-        } else {
-          Toast("您没有当前空间的控制权限!");
-        }
-      },
-      //  控制灯的接口
-      setLamp(
-        type: string,
-        id: any,
-        statusFlag: any,
-        index: any,
-        item: any = null
-      ) {
-        let params: any = [];
-        if (type === "allLamp") {
-          for (let i = 0; i < proxyData.initData.length; i++) {
-            proxyData.initData[i].switch = statusFlag;
-          }
-          params = proxyData.initData;
-        } else {
-          params = [
-            {
-              id: id,
-              switch: statusFlag,
-            },
-          ];
-        }
-        proxyData.lightParams = params;
-        // 调服务端的接口像后台发送灯的操作的指令
-        setallLampHttp(params)
-          .then((res) => {
-            const resData: any = res;
-            // set成功后1s关闭定时器
-            setTimeout(() => {
-              proxyData.setStatus = false;
-            }, 1000);
-
-            if (item) {
-              item.loading = false;
-            }
-            if (resData.result === "success") {
-              // const checkData: any = proxyData.judgeChangeResponeseSuccess(resData)
-              // proxyData.getTimeLampStatus(checkData, type, id, statusFlag, index)
-            } else {
-              proxyData.initLampLoading();
-            }
-          })
-          .catch((error: any) => {
-            setTimeout(() => {
-              proxyData.setStatus = false;
-            }, 1000);
-            if (item) {
-              item.loading = false;
-            }
-            // console.log(error)
-            Toast("连接异常,请检查网络!");
-          });
-      },
-      // 报错后关闭灯的loading
-      initLampLoading() {
-        proxyData.loadingLight = false;
-        proxyData.floorHeatingList.map((item: any) => {
-          item.loading = false;
-        });
-      },
-      //手动修改灯的状态
-      updateAllLampStatus(statusFlag: any) {
-        proxyData.lampSw = statusFlag;
-        for (let i = 0; i < proxyData.floorHeatingList.length; i++) {
-          proxyData.floorHeatingList[i].switch = statusFlag;
-          // if (proxyData.floorHeatingList[i].type == 'lamp') {
-          // }
-        }
-      },
-      // 单个灯的状态修改
-      updateLampStatus(item: any, statusFlag: any) {
-        item.switch = statusFlag;
-        // let flag: any = true
-        // for (let i = 0; i < proxyData.floorHeatingList.length; i++) {
-        //   if (proxyData.floorHeatingList[i].type == 'lamp') {
-        //     if (proxyData.floorHeatingList[i].switch !== statusFlag) {
-        //       flag = false
-        //       break
-        //     }
-        //   }
-        // }
-      },
-      // 轮询查看状态
-      getTimeLampStatus(
-        checkData: any,
-        type: any,
-        id: any,
-        statusFlag: any,
-        index: any
-      ) {
-        if (checkData["success"] && checkData["success"].length) {
-          if (type === "allLamp") {
-            // 点击主灯按钮
-            proxyData.updateAllLampLoading(checkData["success"]); // 所有灯
-          } else {
-            // 当个的时候修改loading的状态
-            proxyData.updateLampLoading(index);
-          }
-          proxyData.getFloorHeatingList();
-        }
-        if (checkData["processing"] && checkData["processing"].length) {
-          let checkParams: any = proxyData.lightParams;
-          let processArr: any = checkData["processing"];
-          let params: any = [];
-          processArr.map((item: any) => {
-            let obj: any = {
-              id: item.id,
-              orderSeqNum: item.orderSeqNum,
-            };
-            for (let i = 0; i < checkParams.length; i++) {
-              if (item.id === checkParams[i].id) {
-                obj.switch = checkParams[i].switch;
-                break;
-              }
-            }
-            params.push(obj);
-          });
-          proxyData.checkChangeLightStatusSuccess(
-            params,
-            type,
-            id,
-            statusFlag,
-            index
-          );
-        }
-        if (checkData["error"] && checkData["error"].length) {
-          if (type === "allLamp") {
-            // 点击主灯按钮
-            proxyData.updateAllLampLoading(checkData["error"]); // 所有灯
-          } else {
-            // 当个的时候修改loading的状态
-            proxyData.updateLampLoading(index);
-          }
-        }
-      },
-      // 查看指令是否成功完成
-      judgeChangeResponeseSuccess(resData: any) {
-        let data: any = resData?.content ?? [];
-        let processingArr: any = [];
-        let successArr: any = [];
-        let errorArr: any = [];
-        for (let i = 0; i < data.length; i++) {
-          let item: any = data[i];
-          if ((item.result = "success")) {
-            if (item.state === 200 && item.exeResult === "success") {
-              successArr.push(item);
-            } else if (
-              (item.state === 200 && item.exeResult === "processing:rcvd") ||
-              (item.state === 202 && !item.exeResult)
-            ) {
-              processingArr.push(item);
-            } else {
-              errorArr.push(item);
-            }
-          } else {
-            errorArr.push(item);
-          }
-        }
-        let obj: any = {
-          success: successArr,
-          processing: processingArr,
-          error: errorArr,
-        };
-        return obj;
-      },
-      // 操作成功后更新所有灯的真实状态
-      updateAllLampLoading(arr: any) {
-        for (let i = 0; i < proxyData.floorHeatingList.length; i++) {
-          if (proxyData.floorHeatingList[i].type == "lamp") {
-            arr.map((item: any) => {
-              if (proxyData.floorHeatingList[i].id === item.id) {
-                proxyData.floorHeatingList[i].loading = false;
-              }
-            });
+      loadingTimer: 0,
+      loading: false,
+      // 计算loading时间
+      setLoadingNumber() {
+        let timer: any = setInterval(() => {
+          proxyData.loadingTimer++;
+          console.log(proxyData.loadingTimer);
+          if (proxyData.loadingTimer >= 15) {
+            clearInterval(timer);
+            proxyData.loading = false;
+            // proxyData.getAirInfoToTimer(0);
           }
-        }
-        let loadingLen = proxyData.floorHeatingList.filter((item: any) => {
-          return item.loading;
-        });
-        if (loadingLen.length === 0) {
-          proxyData.loadingLight = false;
-        }
-      },
-      // 动态切换主灯的状态
-      updateLampLoading(index: any) {
-        proxyData.floorHeatingList[index].loading = false;
-      },
-      // 灯的指令完成后更新状态
-      checkChangeLightStatusSuccess(
-        checkParams: any,
-        type: any,
-        id: any,
-        value: any,
-        index: any
-      ) {
-        // 轮询查询灯的状态
-        getStatusHttp(checkParams).then((res) => {
-          const resData: any = res;
-          const checkData: any = proxyData.judgeChangeResponeseSuccess(resData);
-          proxyData.getTimeLampStatus(checkData, type, id, value, index);
-        });
+        }, 1000);
       },
       // 灯灯接口清除定时器
       clearLightStatusTimer() {