wh 2 роки тому
батько
коміт
a8b94aa2a8

+ 4 - 0
src/utils/api.js

@@ -30,4 +30,8 @@ export default {
 
     //工单维修--分页查询
     repairInfoQuery: (params) => service.get("/app/repairorder/page", { params: params }),
+    //空调下发指令
+    setControl:(params) => service.post("/app/airconditioner/command", params),
+    //继电器下发指令
+    setControlElec:(params) => service.post("/app/relay/control/command", params),
 }

+ 4 - 2
src/views/home.vue

@@ -356,7 +356,9 @@ export default {
     };
   },
   created() {
-    this.getHomeData();
+    if(localStorage.getItem('token')){
+      this.getHomeData();
+    }
     // this.role = localStorage.getItem("role");
   },
   methods: {
@@ -423,7 +425,7 @@ export default {
 <style lang="scss" scoped>
 .page_info {
   position: relative;
-  height: calc( 100vh - 40px);
+  height: calc( 100vh - 85px);
      overflow: auto;
     // height:100% - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 50px -46px
   .info_bg {

+ 363 - 41
src/views/remoteControl.vue

@@ -7,7 +7,7 @@
   />
   <div class="page_check">
     <div class="search_pannel">
-      <div class="pannel_left">
+      <div class="pannel_left" @click="showRepairPositionPicker = true">
         <van-image
           :src="require('@/assets/position.svg')"
           width="16"
@@ -81,39 +81,101 @@
             finished-text="没有更多了"
             @load="onLoad"
           >
-            <div v-for="item in list" :key="item.id" class="list_item">
+            <div v-for="(item, index) in list" :key="item.id" class="list_item">
               <template v-if="deviceType == 'AirConditioner'">
-                <div
+                <!-- <div
+                v-if="item.attributeList[2]"
                   class="reduce_type"
                   :style="{
                     'background-color': `${
-                      deviceStatus_filter(item.attributeList[2].value)['color']
+                      deviceStatus_filter(item.attributeList[3].value)['color']
                     }`,
                   }"
                 >
                   <span>{{
                     `${
-                      deviceStatus_filter(item.attributeList[2].value)["label"]
+                      deviceStatus_filter(item.attributeList[3].value)["label"]
                     }`
                   }}</span>
-                </div>
+                </div> -->
+                <template v-if="item.attributeList">
+                  <van-switch
+                    v-model="item.attributeList[3].value"
+                    :active-value="1"
+                    :inactive-value="0"
+                    class="isSwitch"
+                    inactive-color="#dddddd"
+                    @change="
+                      changeSwitch(
+                        item.attributeList[3].value,
+                        index,
+                        item.deviceId
+                      )
+                    "
+                  />
+                </template>
                 <span class="header">{{ item.airConditionerName }}</span>
                 <span
                   >空间信息:{{ item.installSite }}{{ item.roomNumbers }}</span
                 >
-                <span>设备编号:{{ item.airConditionerNo }}</span>
+                <!-- <span>设备编号:{{ item.airConditionerNo }}</span> -->
                 <span v-if="item.attributeList"
-                  >实时读数:{{ item.attributeList[5].value }}</span
+                  >室温:{{ item.attributeList[4].value }}</span
                 >
                 <!-- <span>所属租户:{{ item.rentNum }}</span> -->
-                <div class="list_btn" v-if="item.attributeList">
+                <!-- <div class="list_btn" v-if="item.attributeList">
                   <van-button plain type="primary" size="small">{{
                     item.attributeList[3].value == 1 ? "开启" : "关闭"
                   }}</van-button>
-                </div>
+                </div> -->
+                <van-row class="operation" v-if="item.attributeList">
+                  <van-col
+                    span="8"
+                    @click="
+                      chooseMs(
+                        'moshitxt',
+                        item.attributeList[2].value,
+                        index,
+                        item.deviceId
+                      )
+                    "
+                    >{{ ms(item.attributeList[2].value)
+                    }}<van-icon name="arrow-down" class="xl"
+                  /></van-col>
+                  <div class="line" style="left: 32%"></div>
+                  <van-col
+                    span="8"
+                    @click="
+                      chooseMs(
+                        'wendu',
+                        item.attributeList[5].value,
+                        index,
+                        item.deviceId
+                      )
+                    "
+                    >{{ item.attributeList[5].value }}℃<van-icon
+                      name="arrow-down"
+                      class="xl"
+                  /></van-col>
+                  <div class="line" style="left: 65%"></div>
+                  <van-col
+                    span="8"
+                    @click="
+                      chooseMs(
+                        'fengs',
+                        item.attributeList[0].value,
+                        index,
+                        item.deviceId
+                      )
+                    "
+                    >{{ fs(item.attributeList[0].value)
+                    }}<van-icon name="arrow-down" class="xl"
+                  /></van-col>
+                </van-row>
               </template>
               <template v-if="deviceType == 'Ammeter'">
                 <div
+                  v-if="item.attributeList"
                   class="reduce_type"
                   :style="{
                     'background-color': `${
@@ -130,25 +192,43 @@
                 <!-- <span>设备编号:{{ item.deviceId }}</span>
                 <span>实时读数:{{ item.status }}</span> -->
                 <!-- <span>所属租户:{{ item.rentNum }}</span> -->
-                <div class="list_btn">
-                  <van-button
-                    plain
-                    type="primary"
-                    size="small"
-                    @click="elecControl(item.id,item.status)"
-                    >{{ item.status == 1 ? "关闭" : "开启" }}</van-button
-                  >
-                </div>
+                <van-switch
+                  v-model="item.status"
+                  active-value="1"
+                  inactive-value="0"
+                  class="isSwitch"
+                  inactive-color="#dddddd"
+                  @change="changeElecSwitch(item.status, item.deviceId)"
+                />
               </template>
             </div>
           </van-list>
         </van-pull-refresh>
       </div>
     </div>
+    <van-popup v-model:show="showRepairPositionPicker" round position="bottom">
+      <van-picker
+        title="标题"
+        :columns="positionList"
+        :columns-field-names="fieldNames"
+        @cancel="showRepairPositionPicker = false"
+        @confirm="confirmPosition"
+      />
+    </van-popup>
+    <van-popup v-model:show="showControl" round position="bottom">
+      <van-picker
+        v-model="checkedMs"
+        title="请选择"
+        :columns="controlList"
+        @confirm="onConfirmMs"
+        @cancel="showControl = false"
+      />
+    </van-popup>
   </div>
 </template>
 <script>
 import api from "../utils/api";
+import { ref } from "vue";
 import { isEmpty } from "@/utils/index.js";
 import VCountUp from "./CountUp";
 import { Notify, Dialog, showConfirmDialog } from "vant";
@@ -156,10 +236,91 @@ export default {
   components: {
     "v-count-up": VCountUp,
   },
+  setup() {
+    //指令下发
+    const controlList = ref([]);
+    const showControl = ref(false);
+    const deviceId = ref("");
+    const module = ref("");
+    //切换模式start
+    const checkedMs = ref([]);
+    const msCurrentIndex = ref(0);
+    const moshitxt = ref([
+      { text: "制热", value: 1 },
+      { text: "制冷", value: 2 },
+      { text: "送风", value: 4 },
+      { text: "除湿", value: 8 },
+    ]);
+    //切换模式end
+    //切换温度start
+    const checkedWd = ref("");
+    const wdCurrentIndex = ref(0);
+    const wendu = ref([]);
+    //切换温度end
+    const checkedFs = ref("");
+    const fsCurrentIndex = ref(0);
+    const fengs = ref([
+      { text: "自动", value: 0 },
+      { text: "低速", value: 1 },
+      { text: "中速", value: 2 },
+      { text: "高速", value: 3 },
+    ]);
+    const fieldNames = ref({
+      text: "orgName",
+      value: "orgId",
+      children: "childrenList",
+    });
+    const storeyId=ref('');
+    const buildingId=ref('');
+    const positionList = ref([]); //定位
+
+    function ms(data) {
+      let text = "";
+      let node = this.moshitxt.filter((item) => {
+        return item.value == data;
+      });
+      if (node[0]) {
+        text = node[0].text;
+      }
+      return text;
+    }
+    function fs(data) {
+      let text = "";
+      let node = this.fengs.filter((item) => {
+        return item.value == data;
+      });
+      if (node[0]) {
+        text = node[0].text;
+      }
+      return text;
+    }
+    return {
+      module,
+      deviceId,
+      controlList,
+      showControl,
+      ms,
+      moshitxt,
+      checkedMs,
+      msCurrentIndex,
+      wendu,
+      checkedWd,
+      wdCurrentIndex,
+      fs,
+      fengs,
+      checkedFs,
+      fsCurrentIndex,
+      fieldNames,
+      positionList,
+      buildingId,
+      storeyId,
+    };
+  },
   data() {
     return {
+      showRepairPositionPicker: false,
       loading: false,
-      name: "电商园四期-B座",
+      name: "电商园四期",
       deviceType: "AirConditioner",
       deviceStatus: "",
       deviceTypeTitle: "空调",
@@ -180,24 +341,139 @@ export default {
       finished: false,
     };
   },
+  watch: {
+    positionList(newval, oldval) {
+      if (newval) {
+        let json = {
+          category: "s",
+          childrenList: null,
+          orgId: "",
+          orgName: "全部",
+        };
+        for (let i = 0; i < newval.length; i++) {
+          newval[i].childrenList.push(json);
+        }
+      }
+    },
+  },
   created() {
+    this.getBuildList();
+    this.setwendu();
     this.getAircond();
   },
   methods: {
-    elecControl(id,state) {
-      console.log(id,state)
+    //定位完成
+    confirmPosition(val) {
+      console.log(val);
+      this.buildingId=val[0].orgId;
+      this.storeyId=val[1].orgId;
+      let storeyName=val[1].orgName=='全部'?'':val[1].orgName+'-';
+      this.name="电商园四期-"+val[0].orgName+storeyName;
+      this.showRepairPositionPicker=false;
+      console.log(this.buildingId);
+      console.log(this.storeyId);
+    },
+    //继电器下发指令开关
+    changeElecSwitch(val, deviceId) {
+      api
+        .setControlElec({
+          keyword: "setRelay",
+          param: val ? 0 : 1,
+          deviceId: deviceId,
+        })
+        .then((res) => {
+          if (res.code == 0) {
+            Notify({ type: "success", message: "操作成功" });
+          }
+        });
+    },
+    //空调下发指令开关
+    changeSwitch(val, index, deviceId) {
+      api
+        .setControl({
+          keyword: "setPower",
+          param: val ? 0 : 1,
+          deviceId: deviceId,
+        })
+        .then((res) => {
+          if (res.code == 0) {
+            Notify({ type: "success", message: "操作成功" });
+          }
+        });
+    },
+    onConfirmMs(data) {
+      let deviceCommandDTO = {};
+      switch (this.module) {
+        case "moshitxt":
+          this.checkedMs[0] = data.value;
+          this.list[this.msCurrentIndex].attributeList[2].value = data.value;
+          this.showControl = false;
+          deviceCommandDTO = {
+            keyword: "setMode",
+            param: data.value,
+            deviceId: this.deviceId,
+          };
+          break;
+        case "wendu":
+          console.log(data);
+          this.checkedMs[0] = data;
+          this.list[this.msCurrentIndex].attributeList[5].value = data;
+          this.showControl = false;
+          deviceCommandDTO = {
+            keyword: "setTemp",
+            param: data,
+            deviceId: this.deviceId,
+          };
+          break;
+        case "fengs":
+          this.checkedMs[0] = data.value;
+          this.list[this.msCurrentIndex].attributeList[0].value = data.value;
+          this.showControl = false;
+          deviceCommandDTO = {
+            keyword: "setFan",
+            param: data.value,
+            deviceId: this.deviceId,
+          };
+          break;
+      }
+      api.setControl(deviceCommandDTO).then((res) => {
+        if (res.code == 0) {
+          Notify({ type: "success", message: "操作成功" });
+        }
+      });
+    },
+    chooseMs(name, val, index, deviceId) {
+      this.deviceId = deviceId;
+      this.msCurrentIndex = index;
+      this.showControl = true;
+      this.controlList = this[name];
+      this.module = name;
+    },
+    setwendu() {
+      this.wendu = [];
+      for (let i = 16; i < 33; i++) {
+        this.wendu.push(i);
+      }
+    },
+    elecControl(id, state) {
+      console.log(id, state);
       Dialog.confirm({
         title: "标题",
-        message:
-          "确定执行该操作?",
+        message: "确定执行该操作?",
       })
         .then(() => {
-          api.elecControl({keyword:'setRelay',deviceId:id,param:state?'1':'0'}).then(res=>{
-            console.log(res)
-            if(res.code==0){
-              this.getElec();
-            }
-          })
+          api
+            .elecControl({
+              keyword: "setRelay",
+              deviceId: id,
+              param: state ? "1" : "0",
+            })
+            .then((res) => {
+              console.log(res);
+              if (res.code == 0) {
+                this.getElec();
+              }
+            });
         })
         .catch(() => {
           // on cancel
@@ -206,9 +482,11 @@ export default {
     getElec() {
       api
         .getElec({
+          buildingId:this.buildingId,
+          storeyId:this.storeyId,
           page: 1,
           limit: 10,
-          status:this.deviceStatus,
+          status: this.deviceStatus,
           controlCategory: "CommonLighting",
         })
         .then((res) => {
@@ -228,6 +506,8 @@ export default {
         .airconditioner({
           page: 1,
           limit: 10,
+          buildingId:this.buildingId,
+          storeyId:this.storeyId,
         })
         .then((res) => {
           if (res.code == 0) {
@@ -264,13 +544,31 @@ export default {
         };
       }
     },
+    //获取楼栋
+    getBuildList() {
+      api.getBuildInfo().then((res) => {
+        if (res.code == 0) {
+          this.positionList = res.data[0].childrenList;
+          if (this.positionList) {
+            let json = {
+              category: "s",
+              childrenList: null,
+              orgId: "",
+              orgName: "全部",
+            };
+            for (let i = 0; i < this.positionList.length; i++) {
+              this.positionList[i].childrenList.unshift(json);
+            }
+          }
+        }
+      });
+    },
     onLoad() {
       setTimeout(() => {
         if (this.refreshing) {
           this.list = [];
           this.refreshing = false;
         }
-
         for (let i = 0; i < 10; i++) {
           this.list.push(this.list.length + 1);
         }
@@ -281,7 +579,6 @@ export default {
         }
       }, 1000);
     },
-
     onRefresh() {
       // 清空列表数据
       this.finished = false;
@@ -301,7 +598,9 @@ export default {
         (item) => item.value === val
       )[0].text;
     },
-    onClickLeft() {},
+    onClickLeft() {
+      this.$router.back();
+    },
   },
 };
 </script>
@@ -415,14 +714,37 @@ export default {
             line-height: 16px;
           }
         }
-        .list_btn {
+        // .list_btn {
+        //   position: absolute;
+        //   bottom: 15px;
+        //   right: 12px;
+        //   .van-button {
+        //     &:nth-child(2) {
+        //       margin: 0 12px;
+        //     }
+        //   }
+        // }
+        .isSwitch {
           position: absolute;
-          bottom: 15px;
-          right: 12px;
-          .van-button {
-            &:nth-child(2) {
-              margin: 0 12px;
-            }
+          right: 10px;
+          font-size: 18px;
+          top: auto;
+          z-index: 1;
+        }
+        .operation {
+          width: 100%;
+          position: relative;
+          font-size: 13px;
+          margin-top: 10px;
+          .xl {
+            margin-left: 4px;
+          }
+          .line {
+            position: absolute;
+            top: 15%;
+            width: 2px;
+            height: 16px;
+            background: #d6d6d6;
           }
         }
       }

+ 2 - 0
src/views/repairList.vue

@@ -227,6 +227,8 @@ export default {
   }
   .info_list {
     padding: 0 16px;
+    height: calc(100vh - 125px);
+    overflow: auto;
     .list_item {
       background: #ffffff;
       box-shadow: 0px 0px 10px 0px rgba(153, 153, 153, 0.15);

+ 1 - 0
src/views/repairOnline.vue

@@ -155,6 +155,7 @@ import Api from "../utils/api";
 export default {
   data() {
     return {
+      
       loading: false,
       fileList: [],
       tempFileList: [],