Browse Source

fix: 环境控制页面的参数值修改

chenzhen2 2 years ago
parent
commit
49658d7ea8

File diff suppressed because it is too large
+ 3 - 0
public/images/ipdImages/humidity.svg


+ 8 - 1
src/apis/envmonitor.ts

@@ -203,7 +203,14 @@ export const queryCustomAndScence = (params: any) => {
  * 设置成办公空间
  */
  export const saveWorkSpace = (params: any) => {
-  return https().request<any>(`${objectService}padSpace/saveWorkSpace?${comParams}`, Method.POST, params, ContentType.json)
+  return https().request<any>(`${testApi}padSpace/saveWorkSpace?${comParams}`, Method.POST, params, ContentType.json)
+}
+
+/**
+ * 查询平板下面的办公空间
+ */
+ export const queryWorkSpace = (params: any) => {
+  return https().request<any>(`${testApi}padSpace/queryWorkSpace?${comParams}`, Method.POST, params, ContentType.json)
 }
 
 

+ 1 - 1
src/permission.ts

@@ -2,7 +2,7 @@ import router from '@/router'
 import { RouteLocationNormalized } from 'vue-router'
 import { useStore } from './store'
 import { UserActionTypes } from './store/modules/user/action-types'
-import { getUrlaccessToken } from '@/utils/https'
+// import { getUrlaccessToken } from '@/utils/https'
 import { getToken, setToken } from '@/utils/cookies'
 import { Toast } from 'vant'
 import Cookies from 'js-cookie'

+ 1 - 1
src/utils/https.ts

@@ -49,7 +49,7 @@ export const post = (url: any, data: any) => {
   })
 }
 
-export const getUrlaccessToken = () => {
+export const getUrlParams = () => {
   let url: any = location.search //获取url中"?"符后的字串
   let theRequest: any = new Object()
   if (url.indexOf('?') != -1) {

+ 4 - 19
src/utils/index.ts

@@ -499,25 +499,6 @@ export const getRelNowTime = function () {
 }
 
 /**
- * 
- * @returns js获取mac地址
- */
-export const getMacAddress = function () {
-  let obj: any = new ActiveXObject("WbemScripting.SWbemLocator");
-  let s: any = obj.ConnectServer(".");
-  let properties: any = s.ExecQuery("Select * from Win32_NetworkAdapterConfiguration");
-  let e: any = new Enumerator(properties);
-  let output: any = '';
-  while (!e.atEnd()) {
-    e.moveNext();
-    var p = e.item();
-    if (!p) continue;
-    if (p.IPEnabled) return p.MACAddress;
-  }
-  return "";
-}
-
-/**
  * 19000转成19:00
  */
 export const formatTimerStr = function (timer: any) {
@@ -526,4 +507,8 @@ export const formatTimerStr = function (timer: any) {
   } else {
     return ''
   }
+}
+
+export const newNumber = function (start: any, end: any, masAddess: any) {
+  return masAddess + "" + Math.round(Math.random() * (end - start) + start);//生成在[start,end]范围内的随机数值,只支持不小于0的合法范围
 }

+ 74 - 15
src/views/choiceSpace/choiceSpace.vue

@@ -15,7 +15,12 @@
             <van-icon class="arrow-down" name="arrow-down" />
           </div>
         </div>
-        <van-search class="search-box" placeholder="请输入搜索关键词" />
+        <van-search
+          class="search-box"
+          v-model="searchSpaceName"
+          @update:model-value="searchSpace"
+          placeholder="请输入搜索关键词"
+        />
         <div class="search-icon">
           <img :src="parseImgUrl('search-icon', 'search-icon.svg')" alt="" />
         </div>
@@ -69,7 +74,7 @@
 <script lang="ts">
 import { defineComponent, nextTick, onMounted, reactive, toRefs } from "vue";
 import { useRoute, useRouter, onBeforeRouteUpdate } from "vue-router";
-import { Search, TreeSelect, Popup, Checkbox } from "vant";
+import { Search, TreeSelect, Popup, Checkbox, Toast } from "vant";
 import { parseImgUrl, setQueryConfig } from "@/utils";
 import { store } from "@/store";
 import { UserMutationTypes } from "@/store/modules/user/mutation-types";
@@ -78,7 +83,9 @@ import {
   getDefaultLocation,
   getFloorList,
   getPadSpaceList,
+  saveWorkSpace,
 } from "@/apis/envmonitor";
+import { clear } from "console";
 
 export default defineComponent({
   components: {
@@ -136,6 +143,7 @@ export default defineComponent({
     const proxyData = reactive({
       parseImgUrl: parseImgUrl,
       spaceType: spaceType,
+      searchSpaceName: "",
       checked: false,
       positionArr: positionArr,
       checkPositon: checkPositon,
@@ -159,6 +167,8 @@ export default defineComponent({
       checkSpaceType(item: any) {
         proxyData.spaceType = item;
         proxyData.showSpaceType = false;
+        // 获取空间列表
+        proxyData.searchSpace();
       },
       // 设置建筑id
       setProjectId() {
@@ -266,10 +276,36 @@ export default defineComponent({
       },
       // 设置主空间
       goNext() {
-       let data:any= proxyData.spaceData.filter((item:any)=>{
-          return item.checked
-        })
-        router.push({ name: "setMainSpace" });
+        let data: any = proxyData.spaceData.filter((item: any) => {
+          return item.checked;
+        });
+        let idArr: any = [];
+        data.map((item: any) => {
+          idArr.push(item.spaceId);
+        });
+        if (idArr.length) {
+          let params: any = {
+            workSpaceList: idArr,
+            majorSpaceId: idArr[0], //类型:String  必有字段  备注:主空间
+            macAddress: "test", //类型:String  必有字段  备注:平板地址
+          };
+          proxyData.saveWorkSpace(params);
+        } else {
+          Toast("请选择办公空间!");
+        }
+      },
+      // 保存空间
+      saveWorkSpace(params: any) {
+        saveWorkSpace(params).then((res) => {
+          if (params.workSpaceList.length > 1) {
+            router.push({ name: "setMainSpace" });
+          } else {
+            router.push({
+              name: "envmonitor",
+              query: { spaceId: params.workSpaceList[0] },
+            });
+          }
+        });
       },
       // 选择建筑
       checkBuilding(index: any) {
@@ -285,30 +321,53 @@ export default defineComponent({
           proxyData.buildingItem.buildingName;
         proxyData.checkPositon.floorId = item.id;
         proxyData.checkPositon.floorName = item.localName;
+        proxyData.show = false;
+        proxyData.clearSearchName();
+        proxyData.getPadSpaceList();
+      },
+      // 清除搜索条件
+      clearSearchName() {
+        proxyData.searchSpaceName = "";
+        proxyData.spaceType = spaceType;
       },
       spaceData: spaceData,
       // 空间列表
-      getPadSpaceList() {
-        let params: any = {
-          floorId: proxyData.checkPositon.floorId,
-          buildingId: proxyData.checkPositon.buildingId,
-          funcType: "",
-          spaceName: "",
-          macAddress: "test",
-        };
+      getPadSpaceList(query: any = "") {
+        // debugger;
+        let params: any = query
+          ? query
+          : {
+              floorId: proxyData.checkPositon.floorId,
+              buildingId: proxyData.checkPositon.buildingId,
+              macAddress: "test",
+            };
         let str: any = setQueryConfig(params);
         getPadSpaceList(str).then((res) => {
           let resData: any = res;
           if (resData.result === "success") {
             proxyData.spaceData = resData?.data ?? [];
             proxyData.spaceData.map((item: any) => {
-              item.checked=false
+              if(item.isWorkSpace){
+                 item.checked = true;
+              }else{
+                item.checked = false;
+              }
             });
           } else {
             proxyData.spaceData = [];
           }
         });
       },
+      searchSpace() {
+        let query: any = {
+          floorId: proxyData.checkPositon.floorId,
+          buildingId: proxyData.checkPositon.buildingId,
+          funcType: proxyData.spaceType.type,
+          spaceName: proxyData.searchSpaceName,
+          macAddress: "test",
+        };
+        proxyData.getPadSpaceList(query);
+      },
       async init() {
         await proxyData.getDefaultLocation();
         await proxyData.getBuildingList();

+ 69 - 19
src/views/choiceSpace/setMainSpace.vue

@@ -2,15 +2,12 @@
   <div class="set-main-space content-box">
     <div
       class="space-item"
-      @click="checkMainSpace"
-      v-for="(item, index) in 5"
+      @click="checkMainSpace(item)"
+      v-for="(item, index) in spaceData"
       :key="'space' + index"
     >
       <van-swipe-cell>
-        <van-cell
-          :border="false"
-          title="单元格单元格单元格单元格单元格单元格单元格单元格"
-        />
+        <van-cell :border="false" :title="item.spaceName" />
         <template #right>
           <van-button square type="danger" text="删除" />
         </template>
@@ -37,6 +34,7 @@ import {
 import { useRoute, useRouter, onBeforeRouteUpdate } from "vue-router";
 import { SwipeCell, Cell, Popup, Button, Dialog, Loading } from "vant";
 import { parseImgUrl } from "@/utils";
+import { queryWorkSpace, saveWorkSpace } from "@/apis/envmonitor";
 
 export default defineComponent({
   components: {
@@ -48,30 +46,82 @@ export default defineComponent({
   },
   setup() {
     const proxyGlobal: any = getCurrentInstance();
+    const spaceData: any = [];
     const router: any = useRouter();
     const proxyData = reactive({
       show: false,
       loaging: false,
       parseImgUrl: parseImgUrl,
+      // 格式化提交的数据
+      formateData(item: any) {
+        let params: any = {
+          workSpaceList: [],
+          majorSpaceId: "", //类型:String  必有字段  备注:主空间
+          macAddress: "test", //类型:String  必有字段  备注:平板地址
+        };
+        proxyData.spaceData.map((space: any) => {
+          if (item.spaceId === space.spaceId) {
+            params.majorSpaceId = space.spaceId;
+          }
+          params.workSpaceList.push(space.spaceId);
+        });
+        return params;
+      },
       // 选择主空间
-      checkMainSpace() {
+      checkMainSpace(item: any) {
         if (!proxyData.loaging) {
-          proxyData.loaging = true;
-          proxyGlobal.proxy.$toast.loading({
-            forbidClick: true,
-            duration: 0, // 如果大于0则不必使用destory方法
-            message: "正在设置主空间...",
-          });
-          proxyData.closeLoading();
+          let params: any = proxyData.formateData(item);
+          proxyData.saveWorkSpace(params);
         }
       },
+      // 保存空间
+      saveWorkSpace(params: any) {
+        proxyData.loaging = true;
+        proxyGlobal.proxy.$toast.loading({
+          forbidClick: true,
+          duration: 0, // 如果大于0则不必使用destory方法
+          message: "正在设置主空间...",
+        });
+        saveWorkSpace(params)
+          .then((res) => {
+            proxyData.closeLoading();
+            router.push({
+              name: "envmonitor",
+              query: { spaceId: params.majorSpaceId },
+            });
+          })
+          .catch(() => {
+            proxyData.closeLoading();
+          });
+      },
       closeLoading() {
-        setTimeout(() => {
-          proxyGlobal.proxy.$toast.clear();
-          router.push({ name: "envmonitor" });
-          proxyData.loaging = false;
-        }, 2000);
+        proxyGlobal.proxy.$toast.clear();
+        proxyData.loaging = false;
       },
+      spaceData: spaceData,
+      queryWorkSpace() {
+        let params: any = {
+          criteria: {
+            //类型:Object  必有字段  备注:无
+            macAddress: "test", //类型:String  必有字段  备注:mac地址
+          },
+        };
+        queryWorkSpace(params).then((res) => {
+          let resData: any = res;
+          if (resData.result === "success") {
+            proxyData.spaceData = resData?.content ?? [];
+          } else {
+            proxyData.spaceData = [];
+          }
+          // 默认都不是主空间
+          proxyData.spaceData.map((item: any) => {
+            item.isMajorSpace = 0;
+          });
+        });
+      },
+    });
+    onMounted(() => {
+      proxyData.queryWorkSpace();
     });
     return {
       ...toRefs(proxyData),

+ 91 - 29
src/views/envmonitor/index.vue

@@ -26,17 +26,24 @@
         <div class="space-info">
           <div class="space-temp">
             <img :src="parseImgUrl('ipdImages', 'template-icon.svg')" alt="" />
-            <span class="temp-text">温度摄氏度</span>
+            <span class="temp-text">温度</span>
             <span class="temp-num">26<sup>℃</sup></span>
           </div>
         </div>
         <div class="space-env">
-          <div class="env-item" :key="'env' + index" v-for="(item, index) in 3">
+          <div
+            class="env-item"
+            :class="index==1?'env-color':''"
+            :key="'env' + index"
+            v-for="(item, index) in envlist"
+          >
             <div>
-              <img :src="parseImgUrl('ipdImages', 'jiaquan.svg')" alt="" />
-              <span>甲醛</span>
+              <img :src="parseImgUrl('ipdImages', item.img)" alt="" />
+              <span>{{ item.name }}</span>
+            </div>
+            <div class="env-text">
+              {{ item.num }} <sup>{{ item.unit }}</sup>
             </div>
-            <div>0.01 <sup> mg/㎡ </sup></div>
           </div>
         </div>
       </div>
@@ -50,7 +57,7 @@
           <span>博锐研发中心二区 </span>
         </div>
         <div class="fotter-item">
-          <img :src="parseImgUrl('ipdImages', 'rectangle3.svg')" />
+          <img :src="parseImgUrl('ipdImages', 'rectangle1.svg')" />
           <span>博锐研发中心二区 </span>
         </div>
       </div>
@@ -309,12 +316,24 @@ export default defineComponent({
     let spaceTempTimer: any = null;
     let envlist: any = [
       {
+        id: 2,
+        name: "甲醛",
+        num: "",
+        level: "",
+        img: "jiaquan.svg",
+        funcid: "HCHO",
+        code: "jiaquan",
+        unit: "mg/㎡",
+      },
+      {
         id: 0,
         name: "CO₂",
         num: "",
         level: "",
+        img: "co2.svg",
         funcid: "CO2",
         code: "co2",
+        unit: "ppm",
       },
       {
         id: 1,
@@ -322,23 +341,19 @@ export default defineComponent({
         num: "",
         level: "",
         funcid: "PM2d5",
+        img: "pm2.5.svg",
         code: "pm25",
-      },
-      {
-        id: 2,
-        name: "甲醛",
-        num: "",
-        level: "",
-        funcid: "HCHO",
-        code: "jiaquan",
+        unit: "ug/m³",
       },
       {
         id: 3,
         name: "湿度",
+        img: "humidity.svg",
         num: "",
         level: "",
         funcid: "Tdb,RH",
         code: "shidu",
+        unit: "%",
       },
     ];
     let scenarioArr: any = [];
@@ -821,34 +836,34 @@ export default defineComponent({
         for (let i = 0; i < content.length; i++) {
           let item = content[i];
           if (item.co2 || item.co2 == 0) {
-            proxyData.envlist[0].level = proxyData.checkLevel(
+            proxyData.envlist[1].level = proxyData.checkLevel(
               item.co2,
               "co2"
             ).levelTxt;
-            proxyData.envlist[0].num = item.co2;
+            proxyData.envlist[1].num = item.co2;
           } else {
-            proxyData.envlist[0].level = "";
-            proxyData.envlist[0].num = "";
+            proxyData.envlist[1].level = "";
+            proxyData.envlist[1].num = "";
           }
           if (item.pm25 || item.pm25 === 0) {
-            proxyData.envlist[1].level = proxyData.checkLevel(
+            proxyData.envlist[2].level = proxyData.checkLevel(
               item.pm25,
               "pm25"
             ).levelTxt;
-            proxyData.envlist[1].num = item.pm25;
+            proxyData.envlist[2].num = item.pm25;
           } else {
-            proxyData.envlist[1].level = "";
-            proxyData.envlist[1].num = "";
+            proxyData.envlist[2].level = "";
+            proxyData.envlist[2].num = "";
           }
           if (item.hcho || item.hcho == 0) {
-            proxyData.envlist[2].level = proxyData.checkLevel(
+            proxyData.envlist[0].level = proxyData.checkLevel(
               item.hcho,
               "hcho"
             ).levelTxt;
-            proxyData.envlist[2].num = item.hcho.toFixed(2);
+            proxyData.envlist[0].num = item.hcho.toFixed(2);
           } else {
-            proxyData.envlist[2].level = "";
-            proxyData.envlist[2].num = "";
+            proxyData.envlist[0].level = "";
+            proxyData.envlist[0].num = "";
           }
           if (item.humidity || item.humidity == 0) {
             proxyData.envlist[3].level = proxyData.checkLevel(
@@ -1733,6 +1748,7 @@ export default defineComponent({
           padding-left: 13px;
         }
         .temp-num {
+          position: relative;
           padding-left: 24px;
           font-family: "Montserrat";
           font-style: normal;
@@ -1741,6 +1757,8 @@ export default defineComponent({
           line-height: 73px;
           color: #ffffff;
           sup {
+            position: absolute;
+            top:-5px;
             font-family: "Noto Sans SC";
             font-style: normal;
             font-weight: 500;
@@ -1755,8 +1773,29 @@ export default defineComponent({
       display: flex;
       padding-top: 20px;
       justify-content: space-between;
+      text-align: left;
       .env-item {
-        flex: 1;
+        padding-top: 8px;
+        height: 88px;
+        &:nth-child(1) {
+          text-align: left;
+          width: 129px;
+        }
+        &:nth-child(2) {
+          // text-align: center;
+          padding-left: 20px;
+          width: 129px;
+        }
+        &:nth-child(3) {
+          // text-align: center;
+          padding-left: 20px;
+          width: 117px;
+        }
+        &:nth-child(4) {
+          // text-align: center;
+          padding-left: 20px;
+          width: 97px;
+        }
         div {
           img {
             display: inline-block;
@@ -1790,6 +1829,25 @@ export default defineComponent({
             }
           }
         }
+        .env-text {
+          position: relative;
+          width: 100%;
+          // text-align: left;
+          sup {
+            position: absolute;
+            // right: -5px;
+            top: 10px;
+          }
+        }
+      }
+      .env-color {
+        background: linear-gradient(
+          180deg,
+          rgba(205, 11, 0, 0) 0%,
+          #cd0b00 100%
+        );
+        opacity: 0.8;
+        border-radius: 25px;
       }
     }
   }
@@ -1835,7 +1893,7 @@ export default defineComponent({
         z-index: 222;
       }
       &:nth-child(3) {
-        margin-left: -18px;
+        margin-left: -25px;
       }
       span {
         position: absolute;
@@ -1852,12 +1910,16 @@ export default defineComponent({
         line-height: 18px;
         text-align: center;
         color: #c3c7cb;
+        word-wrap: break-word; /*强制换行*/
+        overflow: hidden; /*超出隐藏*/
+        text-overflow: ellipsis; /*隐藏后添加省略号*/
+        white-space: nowrap; /*强制不换行*/
       }
     }
     .fotter-item-active {
       margin-bottom: -2px;
       span {
-        color: #1F2429;
+        color: #1f2429;
       }
     }
   }

+ 4 - 4
src/views/home/index.vue

@@ -61,7 +61,7 @@ import {
 } from "vue";
 import QrcodeVue from "qrcode.vue";
 import { useRouter } from "vue-router";
-import { getMacAddress, parseImgUrl } from "@/utils";
+import { newNumber, parseImgUrl } from "@/utils";
 import { UserActionTypes } from "@/store/modules/user/action-types";
 import { useStore } from "@/store";
 import { login } from "@/apis/user";
@@ -109,12 +109,12 @@ export default defineComponent({
       /**
        * 获取mac地址
        */
-      getMacAddress() {
-        // let address: any = getMacAddress();
+      getQrcode() {
+        const id: any = newNumber(0, 100000, "test");
       },
     });
     onMounted(() => {
-      proxyData.getMacAddress();
+      
     });
     return {
       ...toRefs(proxyData),