Browse Source

环境信息

zhaojijng 3 years ago
parent
commit
69585c2c2e

+ 52 - 0
src/models/spaceFunc.ts

@@ -0,0 +1,52 @@
+import React, { useState, useCallback } from 'react';
+import { getMapList } from '@/services/ant-design-pro/environment';
+
+export default function () {
+  const allFunc = {
+    office: ['140'],
+    work: ['314', '313', '315', '921', '922', '923', '924', '925', '926'],
+    meeting: ['321', '322', '323'],
+    rest: ['170', '331', '931', '932', '933', '934', '935', '936', '937', '938'], //休闲
+    device: [
+      '211',
+      '212',
+      '221',
+      '222',
+      '223',
+      '231',
+      '232',
+      '233',
+      '234',
+      '235',
+      '236',
+      '237',
+      '241',
+      '242',
+      '243',
+      '244',
+      '245',
+      '251',
+      '252',
+      '253',
+      '254',
+    ], //设备
+    washroom: ['111', '112'], //卫生间
+    lift: ['130'], //电梯
+    stair: ['140'], //楼梯
+    dining: ['441', '442', '443', '451', '452', '453', '461', '462', '471', '472'], //用餐
+  };
+
+  const getSpaceFunc = useCallback((spaceCode: any) => {
+    for (var key in allFunc) {
+      var codeArr = allFunc[key];
+      if (codeArr.indexOf(spaceCode) > -1) {
+        //debugger;
+        return key;
+      }
+    }
+  }, []);
+
+  return {
+    getSpaceFunc,
+  };
+}

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

@@ -1,5 +1,5 @@
 import React, { useState, useEffect } from 'react';
-import { FormattedMessage } from 'umi';
+import { FormattedMessage, useModel } from 'umi';
 import PageHeader from '@/components/PageHeader';
 import Map from '@/components/map';
 import SearchInput from '@/components/SearchInput';
@@ -95,6 +95,7 @@ const Environment: React.FC = () => {
   const [mapList, setMapList] = useState<API.MapInfo[]>([]);
   const [envirMapList, setEnvirMapList] = useState<API.MapInfo[]>([]);
   const [mapCombineList, setMapCombineList] = useState<any[]>([]);
+  const { getSpaceFunc } = useModel('spaceFunc');
 
   const changeFloorId = (data: string) => {
     //debugger;
@@ -250,7 +251,11 @@ const Environment: React.FC = () => {
               }}
             >
               <div className={mapstyles.content}>
-                <Icon className="" type={item.roomFuncType} style={{ fontSize: 20 }}></Icon>
+                <Icon
+                  className=""
+                  type={getSpaceFunc(item.roomFuncType)}
+                  style={{ fontSize: 20 }}
+                ></Icon>
                 <div className={mapstyles.name}>{item.localName}</div>
               </div>
             </div>

+ 8 - 4
src/pages/Equipment/index.tsx

@@ -1,5 +1,5 @@
 import React, { useState, useEffect, useCallback } from 'react';
-import { FormattedMessage } from 'umi';
+import { FormattedMessage, useModel } from 'umi';
 
 import SearchInput from '@/components/SearchInput';
 import PageHeader from '@/components/PageHeader';
@@ -11,14 +11,13 @@ import DeviceModal from './components/deviceModal';
 import styles from './index.less';
 import mapstyles from '@/assets/css/map.less';
 
-// import './map.less';
 import { equipImageMap } from '@/config/image.js';
-import { Input } from 'antd';
 import Icon from '@/tenants-ui/Icon';
 import type { navigatorItem } from '@/pages/Environment/index';
 import { getMapList, queryDeviceTimeManage } from '@/services/ant-design-pro/environment';
 
 const Environment: React.FC = () => {
+  const { getSpaceFunc } = useModel('spaceFunc');
   const { envir_all, equip_air, equip_lamp, envir_curtain } = equipImageMap;
 
   const [searchText, setSearchText] = useState<{ text: any }>();
@@ -134,6 +133,7 @@ const Environment: React.FC = () => {
         navigatorChange={navigatorChange}
         action={<TopNavRight selNavObj={selNav} navigatorList={navigatorList}></TopNavRight>}
         changeFloorId={changeFloorId}
+        selParamObj={selNav}
       ></TopNavigator>
       <div className={styles.maptop}>
         {selNav.id !== 'all' && (
@@ -205,7 +205,11 @@ const Environment: React.FC = () => {
                 <Icon className="" type="hover"></Icon>
               </div>
               <div className={mapstyles.content}>
-                <Icon className="" type={item.roomFuncType} style={{ fontSize: 20 }}></Icon>
+                <Icon
+                  className=""
+                  type={getSpaceFunc(item.roomFuncType)}
+                  style={{ fontSize: 20 }}
+                ></Icon>
                 <div className={mapstyles.name}>{item.localName}</div>
               </div>
             </div>

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

@@ -3,7 +3,7 @@ import PageHeader from '@/components/PageHeader';
 import Map from '@/components/map';
 import TopNavigator from '@/components/topNavigator';
 import RunNavRight from './components/topNavRight';
-import { FormattedMessage, history } from 'umi';
+import { FormattedMessage, history, useModel } from 'umi';
 import { Popover } from 'antd';
 import styles from './index.less';
 import mapstyles from '@/assets/css/map.less';
@@ -22,6 +22,7 @@ type runtimeNavType = {
 
 const Runtime: React.FC = () => {
   // const { maptemp6 } = equipImageMap;
+  const { getSpaceFunc } = useModel('spaceFunc');
 
   const [searchText, setSearchText] = useState<{ text: any }>();
   const [runtimeNav, setRuntimeNav] = useState<runtimeNavType>({});
@@ -222,7 +223,11 @@ const Runtime: React.FC = () => {
                 )}
               </div>
               <div className={mapstyles.content}>
-                <Icon className="" type={item.roomFuncType} style={{ fontSize: 20 }}></Icon>
+                <Icon
+                  className=""
+                  type={getSpaceFunc(item.roomFuncType)}
+                  style={{ fontSize: 20 }}
+                ></Icon>
                 <div className={mapstyles.name}>{item.localName}</div>
               </div>
             </div>

+ 1 - 1
src/tenants-ui/Icon/index.jsx

@@ -1,7 +1,7 @@
 import { createFromIconfontCN } from '@ant-design/icons';
 
 const Icon = createFromIconfontCN({
-  scriptUrl: '//at.alicdn.com/t/font_3184967_nhdn0ferz2.js',
+  scriptUrl: '//at.alicdn.com/t/font_3184967_ll9zpyz6dxk.js',
 });
 
 export default ({ type, className, style = {} }) => {