Sfoglia il codice sorgente

针对地图的修改

zhaojijng 2 anni fa
parent
commit
5a9dc5d8e6

+ 1 - 1
config/proxy.ts

@@ -11,7 +11,7 @@ export default {
     // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
     '/sgadmin/duoduo-service': {
       target: 'https://duoduoenv.sagacloud.cn/',
-      // target: 'http://192.168.12.13:52011/',
+      //target: 'http://10.100.28.79',
       changeOrigin: true,
       pathRewrite: {
         '^/sgadmin/duoduo-service': '/duoduo-service',

+ 3 - 2
src/components/SearchInput/index.tsx

@@ -15,9 +15,9 @@ const { Option } = Select;
 
 type SearchInputProps = {
   // callbackSearch: (s: any) => void;
-  mapList: API.MapInfo[];
+  //mapList: API.MapInfo[];
 };
-const SearchInput: React.FC<SearchInputProps> = ({ mapList }) => {
+const SearchInput: React.FC<SearchInputProps> = () => {
   const [matchData, setMatchData] = useState<mapResType[]>([]);
   const [value, setValue] = useState<any>();
   const { changeSearchBuildId, changeSearchFloorId, changeSearchText } = useModel('searchInfo');
@@ -72,6 +72,7 @@ const SearchInput: React.FC<SearchInputProps> = ({ mapList }) => {
     });
     var resItem = filterItem[0] || {};
     //callbackSearch(resItem);
+    //搜索内容改变
     changeSearchText({ text: resItem.localName });
     //改变存储的搜索得到的buildingId floorId
     changeSearchBuildId(resItem.buildingId);

+ 9 - 7
src/components/map/index.tsx

@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useRef } from 'react';
 import mapstyles from '@/assets/css/map.less';
 import { useModel } from 'umi';
 
@@ -16,7 +16,7 @@ type MapProps = {
 
 const Map: React.FC<MapProps> = ({ type, selFloorId, render, mapList, mapSize }) => {
   //useModel 注释掉 不用啦 晚会删
-  // const { mapList, getMapListData } = useModel('map');
+
   //   useEffect(() => {
   //     getMapListData(selFloorId);
   //   }, [selFloorId]);
@@ -33,8 +33,8 @@ const Map: React.FC<MapProps> = ({ type, selFloorId, render, mapList, mapSize })
   const [maxscale, setMaxscale] = useState<number>(1.6);
   const [minscale, setMinscale] = useState<number>(0.3);
   const [canMove, setCanMove] = useState<boolean>(false);
+  const currentFloorId = useRef<any>(null);
 
-  const [mapKey, setMapKey] = useState<number>(0);
   //   let mapWidth: number = 3000,
   //     mapHeight: number = 1200;
 
@@ -88,7 +88,7 @@ const Map: React.FC<MapProps> = ({ type, selFloorId, render, mapList, mapSize })
   useEffect(() => {
     //searchText使用对象 防止修改了 不再重新定位
     //根据searchText进行搜索 如果mapList 更改了
-    debugger;
+
     if (searchText && searchText.text && mapList.length > 0) {
       let left: any = 0,
         top: any = 0;
@@ -104,16 +104,18 @@ const Map: React.FC<MapProps> = ({ type, selFloorId, render, mapList, mapSize })
       //搜索完成
       changeSearchBuildId(''); //清空搜索记录  以防两次搜索一样的建筑的 没反应
       changeSearchFloorId(''); //清空搜索记录 以防两次搜索一样的楼层时 没反应 要不要换位置
-      changeSearchText({});
-    } else {
+      changeSearchText({}); //清空搜索记录 好进行一些操作
+    } else if (currentFloorId.current != selFloorId) {
+      //如果两次的selFloorId 不一样 才会更改地图的位置为0 0
       setTranslateX(0);
       setTranslateY(0);
     }
+
+    currentFloorId.current = selFloorId;
   }, [mapList]);
 
   //搜索信息改变时的搜索
   useEffect(() => {
-    debugger;
     if (searchText && searchText.text && mapList.length > 0) {
       let left: any = 0,
         top: any = 0;

+ 2 - 1
src/pages/Environment/index.tsx

@@ -223,7 +223,7 @@ const Environment: React.FC = () => {
       <PageHeader
         title={<FormattedMessage id="menu.environment" />}
         action={
-          <SearchInput mapList={mapList} />
+          <SearchInput />
 
           //   <Input.Search
           //     size="large"
@@ -268,6 +268,7 @@ const Environment: React.FC = () => {
           type={'enviroment'}
           mapList={mapCombineList}
           mapSize={mapSize}
+          selFloorId={selFloorId}
           render={(item: API.MapInfo, index: number) => {
             return (
               <div

+ 2 - 1
src/pages/Equipment/components/topNavRight/index.tsx

@@ -57,9 +57,10 @@ const TopNavRight: React.FC<topNavRightProps> = ({
           setTimeout(() => {
             console.log('setTimeout');
             clearInterval(interval);
-          }, 30000);
+          }, 10000);
         }
         //如果是空调
+        if (filterSpaceArr.length == 0) return;
         if (selNavObj.id == 'airConditioner') {
           changeAllAir(filterSpaceArr2, getDeviceStatus, '打开', projectId);
         }

+ 2 - 2
src/pages/Equipment/equipmentControl.js

@@ -118,12 +118,12 @@ export const getLamp = (sitem, callback, num) => {
         //说明状态改变
         if (sitem.light !== totalIsOpen) {
             callback(totalIsOpen);
-            debugger;
+          
             return;
         } else if (num == 0) {
             return;
         }
-        debugger;
+      
         getLamp(sitem, callback, num);
 
 

+ 18 - 7
src/pages/Equipment/index.tsx

@@ -88,10 +88,14 @@ const Environment: React.FC = () => {
     },
   ]);
   const [mapList, setMapList] = useState<API.MapInfo[]>([]);
+  const [mapListFloorId, setMapListFloorId] = useState<string>();
   const [mapSize, setMapSize] = useState<any>({});
 
   const [equipMapList, setEquipMapList] = useState<any[]>([]);
+  const [equipMapListFloorId, setEquipMapListFloorId] = useState<string>();
   const [timeMapList, setTimeMapList] = useState<any[]>([]);
+  const [timeMapListFloorId, setTimeMapListFloorId] = useState<string>();
+
   const [selNav, setSelNav] = useState<navigatorItem>(navigatorList[0]);
   const [selFloorId, setSelFloorId] = useState<string>();
   const [mapCombineList, setMapCombineList] = useState<any[]>([]);
@@ -227,6 +231,7 @@ const Environment: React.FC = () => {
           };
           setMapSize(mapSize);
           setMapList(data);
+
           //setSelNav(navigatorList[0]); //每当重新请求地图时 让选中导航的默认是第一个
         })
         .catch(() => {
@@ -261,11 +266,19 @@ const Environment: React.FC = () => {
         spaceList.forEach((item: any) => {
           var allType = ['airConditioner', 'light', 'curtain'];
           allType.forEach((etype) => {
-            var filterRes = (item.equipStatusList || []).filter((eItem: equipStatus) => {
+            var filterEquip = (item.equipList || []).filter((eItem: any) => {
               return eItem.equipType == etype;
             });
-            //不存时 赋值not  如果没有设备状态 则说明没有设备
-            filterRes.length > 0 ? (item[etype] = filterRes[0].status) : (item[etype] = 'not');
+            //有当前设备
+            if (filterEquip.length > 0) {
+              var filterRes = (item.equipStatusList || []).filter((eItem: equipStatus) => {
+                return eItem.equipType == etype;
+              });
+              //不存时 赋值not  如果没有设备状态 则说明没有设备  1 是开启   0是关闭
+              filterRes.length > 0 ? (item[etype] = filterRes[0].status) : (item[etype] = 0);
+            } else {
+              item[etype] = 'not';
+            }
           });
         });
         //console.log('spaceList', spaceList);
@@ -326,10 +339,7 @@ const Environment: React.FC = () => {
   let lastTime: number = 0;
   return (
     <>
-      <PageHeader
-        title={<FormattedMessage id="menu.equipment" />}
-        action={<SearchInput mapList={mapList} />}
-      />
+      <PageHeader title={<FormattedMessage id="menu.equipment" />} action={<SearchInput />} />
       <TopNavigator
         navigatorList={navigatorList}
         type={'equipment'}
@@ -378,6 +388,7 @@ const Environment: React.FC = () => {
             mapList={mapCombineList}
             mapSize={mapSize}
             type={'equipment'}
+            selFloorId={selFloorId}
             render={(item, index) => {
               return (
                 <div

+ 2 - 1
src/pages/Runtime/index.tsx

@@ -154,7 +154,7 @@ const Runtime: React.FC = () => {
           //       <span>查看加班记录</span>
           //     </div>
           //   </div>
-          <SearchInput mapList={mapList} />
+          <SearchInput />
         }
       />
       <TopNavigator
@@ -186,6 +186,7 @@ const Runtime: React.FC = () => {
         <Map
           mapList={mapCombineList}
           mapSize={mapSize}
+          selFloorId={selFloorId}
           type={'runtime'}
           render={(item, index) => {
             return (