Browse Source

fix:手动控制加班

chenzhen2 2 years ago
parent
commit
6117957c30

+ 2 - 2
src/apis/envmonitor.ts

@@ -172,7 +172,7 @@ export const querySpaceSceneConfig = (params: any) => {
 export const queryCustomAndScence = (params: any) => {
   //return https().request<any>(`${duoduoenvService}customScene/queryCustomAndScence?${params}`, Method.GET, undefined, ContentType.json)
 
-  return https().request<any>(`${testApi}customScene/queryCustomAndScence?${params}`, Method.GET, undefined, ContentType.json)
+  return https().request<any>(`${duoduoenvService}customScene/queryCustomAndScence?${params}`, Method.GET, undefined, ContentType.json)
 }
 
 /**
@@ -181,7 +181,7 @@ export const queryCustomAndScence = (params: any) => {
  */
 export const saveBatchCustomScene = (data: any) => {
   // return post(`${duoduoenvService}customScene/saveBatchCustomScene`, data)
-  return post(`${testApi}customScene/saveBatchCustomScene`, data)
+  return post(`${duoduoenvService}customScene/saveBatchCustomScene`, data)
 }
 
 

+ 2 - 2
src/views/envmonitor/components/ManualWork/WorkConfig.vue

@@ -473,7 +473,7 @@ export default defineComponent({
           customSceneList.map((item: any) => {
             let oldTimeEnd: any = endTime;
             if (startTime === item.startTime && endTime === item.endTime) {
-              item.type = 3;
+              item.type = 3;  // 3=我要离开
               proxyData.delTimeArr.push(item);
             } // 点击我要离开的时候需要删除的数据
             if (oldTimeEnd === item.startTime) {
@@ -489,7 +489,7 @@ export default defineComponent({
         // 格式化当前时间
         proxyData.formatDataDel();
         // 设置真实的离开时间
-        proxyData.setLeavingTime();
+        proxyData.setLeavingTime();  // // 3=我要离开
         console.log("离开了=====");
         console.log(proxyData.delTimeArr);
         proxyData.leaveBtnFlag = true;

+ 70 - 6
src/views/envmonitor/components/ManualWork/index.vue

@@ -146,7 +146,11 @@ import {
 import { myTime } from "@/model/workTimeData";
 import { propsToAttrMap } from "@vue/shared";
 import { isTemplateElement } from "@babel/types";
-import { saveBatchCustomScene } from "@/apis/envmonitor";
+import {
+  saveBatchCustomScene,
+  setallLampHttp,
+  setSpaceCondtioners,
+} from "@/apis/envmonitor";
 import { number } from "echarts";
 
 export default defineComponent({
@@ -269,6 +273,7 @@ export default defineComponent({
             }
           });
         } else if (formatTimer < cusStartTime) {
+          console.log("在当前的服务定制之前---4");
           timerArr.map((item: any, index: any) => {
             if (item.formatTimer === cusStartTime) {
               obj.len = index - nowIndex;
@@ -277,6 +282,18 @@ export default defineComponent({
               }
             }
           });
+        } else if (formatTimer >= cusEndTime) {  // 在服务定制之后
+          // 在服务定制之后
+          console.log("在当前的服务定制之后---4");
+          let endFormatTimer: any = timerArr[nowIndex + obj.len].formatTimer;
+          spaceCustomContentList.map((item: any) => {
+            let startTime: any = proxyData.parseCusStartTime(item.startTime);
+            if (startTime > cusEndTime && endFormatTimer > startTime) {
+              let cusIndex: any = proxyData.getTimerIndex(timerArr, startTime);
+              obj.len =
+                cusIndex - obj.nowIndex > 0 ? cusIndex - obj.nowIndex : 0;
+            }
+          });
         }
         return obj;
       },
@@ -703,6 +720,7 @@ export default defineComponent({
       myTimeArr: myTimeArr,
       // 格式化设备
       formateEquipment() {
+        console.log(proxyData.enterType);
         if (proxyData.enterType === 1) {
           proxyData.nowData.equipmentList.map((item: any) => {
             item.isCheck = true;
@@ -1202,9 +1220,53 @@ export default defineComponent({
             item.sceneEquipList = sceneEquipList;
           }
         });
-        console.log("提交申请-----");
-        console.log(formTimerArr);
+        // 保存加班记录
         proxyData.saveBatchCustomScene(formTimerArr);
+        //  如果在当前时间,需要手动开启设备
+        proxyData.openDeviceAll(formTimerArr);
+      },
+      // 手动控制开启设备
+      openDeviceAll(formTimerArr: any) {
+        let sceneEquipList: any = [];
+        formTimerArr.map((item: any) => {
+          if (item.type == "2") {
+            sceneEquipList = sceneEquipList.concat(item.sceneEquipList);
+          }
+        });
+        sceneEquipList = proxyData.removeDuplicateObj(sceneEquipList);
+        // 改变设备状态
+        let airDevice: any = [];
+        let lightDevice: any = [];
+        sceneEquipList.map((item: any) => {
+          if (item.type == "SELTLT") {
+            let obj: any = {
+              id: item.objectId,
+              switch: true,
+            };
+            lightDevice.push(obj);
+          } else {
+            let obj: any = {
+              id: item.objectId, //类型:String  必有字段  备注:设备id
+              code: "EquipSwitchSet", //类型:String  必有字段  备注:编码 EquipSwtichSet
+              value: "1", //类型:String  必有字段  备注:值 0
+            };
+            airDevice.push(obj);
+          }
+        });
+        proxyData.setSpaceCondtioners(airDevice);
+        proxyData.setallLampHttp(lightDevice);
+      },
+      // 手动开空调
+      setSpaceCondtioners(data: any) {
+        setSpaceCondtioners(data)
+          .then((res) => {})
+          .catch(() => {});
+      },
+      // 手动开灯
+      setallLampHttp(data: any) {
+        setallLampHttp(data)
+          .then((res) => {})
+          .catch(() => {});
       },
       // 提交加班记录
       saveBatchCustomScene(formTimerArr: any, type: any = 1) {
@@ -1274,10 +1336,12 @@ export default defineComponent({
     watch(props, (newProps: any) => {
       proxyData.workkArr = newProps.workkArr;
       proxyData.projectId = newProps.projectId;
+      proxyData.enterType = newProps.enterType;
+      console.log("newProps.enterType==", newProps.enterType);
+      console.log(newProps.enterType);
       if (proxyData.isUpdate) {
         proxyData.setWorkTimeList();
       }
-      proxyData.enterType = newProps.enterType;
     });
     onMounted(() => {
       // 设置dom最外层的宽
@@ -1562,8 +1626,8 @@ export default defineComponent({
       display: inline-block;
     }
     img {
-      width: 30px;
-      height: 30px;
+      width: 25px;
+      height: 25px;
     }
   }
 }

+ 24 - 18
src/views/envmonitor/index.vue

@@ -173,7 +173,6 @@
       <manual-index
         v-if="controlMode === 1"
         @triggerWork="triggerWork"
-        :enterType="1"
         :forceOverTimeFlag="forceOverTimeFlag"
         @updateAirTemp="updateAirTemp"
         :hasAir="spaceExistenceDevice.airConditioner"
@@ -242,6 +241,7 @@
       <!--加班手动控制 start-->
       <manual-overtime
         v-if="isShowWork && controlMode === 1"
+        :enterType="enterType"
         :spaceInfo="spaceInfo"
         @closeWork="closeWork"
         :projectId="projectId"
@@ -831,8 +831,11 @@ export default defineComponent({
        * 加班
        */
       triggerWork(type: any = 1) {
-        proxyData.isShowWork = true;
+        // console.log(type);
         proxyData.enterType = type;
+        console.log("proxyData.enterType===");
+        console.log(proxyData.enterType);
+        proxyData.isShowWork = true;
       },
       /**
        * 关闭加班
@@ -1664,21 +1667,24 @@ export default defineComponent({
           spaceId: proxyData.spaceInfo.spaceId,
         };
         let str: any = setQueryConfig(params);
-        queryCustomAndScence(str).then((res) => {
-          let resData: any = res?.data ?? [];
-          proxyData.workkArr = resData;
-          for (let i = 0; i < proxyData.workkArr.length; i++) {
-            let customSceneList: any =
-              proxyData.workkArr[i]?.customSceneList ?? [];
-            customSceneList = customSceneList.sort(proxyData.compare);
-          }
-          // 手动控制的情况下走新的服务定制
-          if (proxyData.controlMode === 1) {
-            proxyData.formateManualWorkTime();
-          }
-
-          proxyData.queryCustomAndScenceTimer(5000);
-        });
+        queryCustomAndScence(str)
+          .then((res) => {
+            let resData: any = res?.data ?? [];
+            proxyData.workkArr = resData;
+            for (let i = 0; i < proxyData.workkArr.length; i++) {
+              let customSceneList: any =
+                proxyData.workkArr[i]?.customSceneList ?? [];
+              customSceneList = customSceneList.sort(proxyData.compare);
+            }
+            // 手动控制的情况下走新的服务定制
+            if (proxyData.controlMode === 1) {
+              proxyData.formateManualWorkTime();
+            }
+            proxyData.queryCustomAndScenceTimer(5000);
+          })
+          .catch(() => {
+            proxyData.queryCustomAndScenceTimer(5000);
+          });
       },
 
       // 手动控制加班处理时间段拼接的逻辑
@@ -1722,7 +1728,7 @@ export default defineComponent({
               }
             }
           }
-          if (item.cusStartTime) {
+          if (!item.cusStartTime) {
             item.cusStartTime = spaceCustomContentList[0]
               ? spaceCustomContentList[0].startTime
               : "";

+ 83 - 71
src/views/mapData/indexOld.vue

@@ -78,89 +78,101 @@ export default defineComponent({
       },
       getFile(e: any) {
         console.log(e.target.files);
-        let files:any=e.target.files
-        for(let i=0;i<files.length;i++){
-        let fileSelect: any = files[i]
-        let name: any = fileSelect.name;
-        name = name.split(".")[0];
-        // this.fileName = fileSelect.name;
-        let reader: any = new FileReader();
-        if (typeof FileReader === "undefined") {
-          console.log("您的浏览器不支持FileReader接口");
-          return;
-        }
-        reader.readAsText(fileSelect, "gb2312"); //注意读取中文的是用这个编码,不是utf-8
-        // const _this = this;
-        reader.onload = function () {
-          // console.log(reader.result);
-          let result: any = reader.result;
-          // _this.$nextTick(() => {
-          //     _this.voiceContent = reader.result;
-          // });
-          // proxyData.handleStr(result);
-          proxyData.handPoint(result, name);
-        };
+        let files: any = e.target.files;
+        for (let i = 0; i < files.length; i++) {
+          let fileSelect: any = files[i];
+          let name: any = fileSelect.name;
+          name = name.split(".")[0];
+          // this.fileName = fileSelect.name;
+          let reader: any = new FileReader();
+          if (typeof FileReader === "undefined") {
+            console.log("您的浏览器不支持FileReader接口");
+            return;
+          }
+          reader.readAsText(fileSelect, "gb2312"); //注意读取中文的是用这个编码,不是utf-8
+          // const _this = this;
+          reader.onload = function () {
+            // console.log(reader.result);
+            let result: any = reader.result;
+            // _this.$nextTick(() => {
+            //     _this.voiceContent = reader.result;
+            // });
+            // proxyData.handleStr(result);
+            proxyData.handPoint(result, name);
+          };
         }
-        
       },
       handPoint(result: any, name: any) {
         result = result.replace(/\"/g, "");
         let nameArr: any = name.split("-");
         let arr: any = result.split(/[(\r\n)\r\n]+/);
-        let pointObj: any = {
-          spaceId: nameArr[0].toString(),
-          localName:nameArr[0].toString(),
-          canClick:true,
-          pointArr: [],
-          devicePoint: [],
-          circlePoint: [],
-          logPointArr: [],
-        };
+        if (nameArr && nameArr[0] == "B3") {
+          arr.map((item: any) => {
+            if (item) {
+              let itemArr: any = item.split(",");
+              let obj: any = {
+                width: itemArr[0],
+                height: itemArr[1],
+              };
+              console.log(obj)
+            }
+          });
+        } else {
+          let pointObj: any = {
+            spaceId: nameArr[0].toString(),
+            localName: nameArr[0].toString(),
+            canClick: true,
+            pointArr: [],
+            devicePoint: [],
+            circlePoint: [],
+            logPointArr: [],
+          };
 
-        // debugger
-        arr.map((item: any, index: any) => {
-          if (item) {
-            let itemArr: any = item.split(",");
-            let obj: any = {
-              left: itemArr[0],
-              top: itemArr[1],
-            };
-            if (nameArr[1]) {
-              pointObj.circlePoint.push(obj);
-            } else {
-              if (index <= 1) {
-                pointObj.logPointArr.push(obj);
-              } else if (index <= 4) {
-                pointObj.devicePoint.push(obj);
+          // debugger
+          arr.map((item: any, index: any) => {
+            if (item) {
+              let itemArr: any = item.split(",");
+              let obj: any = {
+                left: itemArr[0],
+                top: itemArr[1],
+              };
+              if (nameArr[1]) {
+                pointObj.circlePoint.push(obj);
               } else {
-                pointObj.pointArr.push(obj);
+                if (index <= 1) {
+                  pointObj.logPointArr.push(obj);
+                } else if (index <= 4) {
+                  pointObj.devicePoint.push(obj);
+                } else {
+                  pointObj.pointArr.push(obj);
+                }
               }
             }
+          });
+          let str: any = localStorage.getItem("spaceList");
+          let spaceList: any = str ? JSON.parse(str) : [];
+          let flag: any = false;
+          spaceList.map((item: any) => {
+            if (nameArr[1] && item.spaceId === nameArr[1]) {
+              item.circlePoint = pointObj.circlePoint;
+              flag = true;
+            } else {
+              if (item.spaceId === nameArr[0]) {
+                // debugger
+                // pointObj.circlePoint = item.circlePoint;
+                item.logPointArr = pointObj.logPointArr;
+                item.devicePoint = pointObj.devicePoint;
+                item.pointArr = pointObj.pointArr;
+                flag = true;
+              }
+            }
+          });
+          if (!flag) {
+            spaceList.push(pointObj);
           }
-        });
-        let str: any = localStorage.getItem("spaceList");
-        let spaceList: any = str ? JSON.parse(str) : [];
-        let flag: any = false;
-        spaceList.map((item: any) => {
-          if (nameArr[1] && item.spaceId === nameArr[1]) {
-            item.circlePoint = pointObj.circlePoint;
-            flag = true;
-          } else {
-           if( item.spaceId === nameArr[0]){
-            // debugger
-            // pointObj.circlePoint = item.circlePoint;
-            item.logPointArr = pointObj.logPointArr;
-            item.devicePoint = pointObj.devicePoint;
-            item.pointArr = pointObj.pointArr;
-            flag = true;
-           }
-          }
-        });
-        if (!flag) {
-          spaceList.push(pointObj);
+          localStorage.setItem("spaceList", JSON.stringify(spaceList));
+          console.log(spaceList);
         }
-        localStorage.setItem("spaceList", JSON.stringify(spaceList));
-        console.log(spaceList);
       },
       // 处理坐标
       handleStr(mapstr: any) {

File diff suppressed because it is too large
+ 758 - 399
src/views/mapDataNew/sichuan.vue