index.tsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. import React, { useState, useEffect, useRef, useCallback } from 'react';
  2. import { FormattedMessage, useModel } from 'umi';
  3. import SearchInput from '@/sagacare_components/SearchInput';
  4. import PageHeader from '@/sagacare_components/PageHeader';
  5. import Map from '@/sagacare_components/map';
  6. import TopNavigator from '@/sagacare_components/topNavigator';
  7. import TopNavRight from './components/topNavRight';
  8. import DeviceModal from './components/deviceModal';
  9. import styles from './index.less';
  10. import mapstyles from '@/sagacare_components/map/index.less';
  11. import cx from 'classnames';
  12. import { Spin, Modal, message } from 'antd';
  13. import moment from 'moment';
  14. import { getMaxScale } from '@/hooks/useMap';
  15. import { ExclamationCircleOutlined } from '@ant-design/icons';
  16. import { equipImageMap } from '@/config/sagacare/sagacare_image.js';
  17. import Icon from '@/tenants-ui/SgIcon';
  18. import type { navigatorItem } from '@/pages/Environment/index';
  19. import { projectObj } from '@/config/api.js';
  20. import {
  21. getMapList,
  22. queryEquipStatistics,
  23. queryDeviceTimeManage,
  24. queryProjectEquipType,
  25. } from '@/services/sagacare_service/environment';
  26. import {
  27. changeCurtain,
  28. changeAir,
  29. changeLight,
  30. getLamp,
  31. getAirInfo,
  32. } from '@/pages/Equipment/equipmentControl';
  33. //设备状态
  34. type equipStatus = {
  35. equipType: string;
  36. status: number;
  37. };
  38. //设备开启数量
  39. type statistics = {
  40. equipType: string;
  41. runCount: number;
  42. };
  43. const Environment: React.FC = () => {
  44. const { hasPersonList, querySpaceAdjustList } = useModel('sagacare_spaceFunc');
  45. const { changeLastFloorId } = useModel('sagacare_buildFloor');
  46. const { searchSpace } = useModel('sagacare_searchInfo');
  47. const { getSpaceFunc } = useModel('sagacare_spaceFunc');
  48. const { envir_all, equip_air, equip_lamp, envir_curtain } = equipImageMap;
  49. const [showModal, setShowModal] = useState<boolean>(false);
  50. const [showSpace, setShowSpace] = useState<API.MapInfo>({}); //当前弹框选中的空间
  51. const [navigatorList, setNavigatorList] = useState<navigatorItem[]>([
  52. {
  53. name: '全部设备',
  54. id: 'all',
  55. src: envir_all,
  56. //color: '#E5574F',
  57. color: '#E89E32',
  58. colorStr: '',
  59. },
  60. {
  61. name: '空调',
  62. id: 'airConditioner',
  63. src: equip_air,
  64. num: 0,
  65. color: '#5E8BCF',
  66. colorStr: '94,139,207,',
  67. },
  68. {
  69. name: '照明',
  70. id: 'light',
  71. src: equip_lamp,
  72. num: 0,
  73. color: '#FFE823',
  74. colorStr: '255,232,35,',
  75. },
  76. {
  77. name: '窗帘',
  78. id: 'curtain',
  79. src: envir_curtain,
  80. num: 0,
  81. color: '#E89E32',
  82. colorStr: '232, 158, 50,',
  83. },
  84. ]);
  85. const [scale, setScale] = useState<number>(0.8);
  86. const [maxScale, setMaxScale] = useState<number>(1);
  87. const [transXInit, setTransXInit] = useState<number>(0);
  88. const [mapList, setMapList] = useState<API.MapInfo[]>([]);
  89. const mapListCopy = useRef<any[]>([]);
  90. const [mapSize, setMapSize] = useState<any>({});
  91. const [equipMapList, setEquipMapList] = useState<any[]>([]);
  92. const [timeMapList, setTimeMapList] = useState<any[]>([]);
  93. const [selNav, setSelNav] = useState<navigatorItem>(navigatorList[0]);
  94. const [selFloorId, setSelFloorId] = useState<string>();
  95. const [mapCombineList, setMapCombineList] = useState<any[]>([]);
  96. const [loading, setLoading] = useState<boolean>(false);
  97. const changeFloorId = (data: string) => {
  98. //debugger;
  99. setSelFloorId(data);
  100. };
  101. //导航条切换
  102. const navigatorChange = (item: navigatorItem) => {
  103. setSelNav(item);
  104. };
  105. const showModalClick = (item) => {
  106. // console.log('showChart', item);
  107. setShowModal(true);
  108. setShowSpace(item);
  109. };
  110. //当前设备的状态 all全部开启 part部分开启 close全都关闭 还有类型type 包括airConditioner light curtain
  111. //根据设备状态返回不同的 颜色
  112. const getColorOpacity = (value: any, type?: string): string => {
  113. let colorStr = '';
  114. if (selNav.id == 'all') {
  115. //全部设备时 colorStr赋值
  116. var filterRes = navigatorList.filter(function (item) {
  117. return item.id == type;
  118. });
  119. colorStr = (filterRes[0] || {}).colorStr;
  120. } else {
  121. colorStr = selNav.colorStr;
  122. }
  123. if (selNav.id == 'curtain' || type == 'curtain') {
  124. if (value == 'noHave') {
  125. //没有
  126. return 'rgba(196, 196, 196, 0)';
  127. } else {
  128. return 'rgba(' + colorStr + '1)';
  129. }
  130. } else {
  131. if (value === 2) {
  132. //2 是部分开启
  133. return 'rgba(' + colorStr + '0.4)';
  134. } else if (value === 1) {
  135. //1 是开启
  136. return 'rgba(' + colorStr + '1)';
  137. } else if (value === 0 || value == 'nostatus') {
  138. //0是关闭
  139. return 'rgba(196, 196, 196, 0.6)';
  140. }
  141. }
  142. };
  143. const { confirm } = Modal;
  144. //单个空间的点击事情
  145. const spaceControl = (item, index: number) => {
  146. //全部设备 或者没有房间类型 则不可以点击
  147. if (selNav.id == 'all' || !item.canClick) return;
  148. //没有设备时
  149. if (item[selNav.id] == 'noHave') return;
  150. if (item[selNav.id] == 'nostatus') {
  151. message.success('该空间设备离线');
  152. return;
  153. }
  154. if (item[selNav.id] === 2) {
  155. //半开时
  156. confirm({
  157. title: '请确认',
  158. icon: <ExclamationCircleOutlined />,
  159. content: `是否进入单空间进行调节?`,
  160. okText: '确认',
  161. cancelText: '取消',
  162. onOk() {
  163. showModalClick(item);
  164. },
  165. onCancel() {
  166. //console.log('Cancel');
  167. },
  168. });
  169. return;
  170. }
  171. var status = item[selNav.id] === 1 ? '关闭' : '打开';
  172. confirm({
  173. title: '请确认',
  174. icon: <ExclamationCircleOutlined />,
  175. content: `确认${status}该${selNav.name}吗?`,
  176. okText: '确认',
  177. cancelText: '取消',
  178. onOk() {
  179. //现在加上循环调用 所以把手动去了
  180. function callback() {
  181. //这是在手动改变状态
  182. // var mapCopy = JSON.parse(JSON.stringify(mapCombineList));
  183. // mapCopy[index][selNav.id] = item[selNav.id] === 1 ? 0 : 1;
  184. // setMapCombineList(mapCopy);
  185. }
  186. //如果是空调
  187. if (selNav.id == 'airConditioner') {
  188. changeAir(item, index, callback);
  189. }
  190. if (selNav.id == 'light') {
  191. changeLight('one', [item], callback, status);
  192. }
  193. if (selNav.id == 'curtain') {
  194. changeCurtain('one', [item], callback, status);
  195. }
  196. },
  197. onCancel() {
  198. //console.log('Cancel');
  199. },
  200. });
  201. };
  202. //获取地图 mapList
  203. useEffect(() => {
  204. if (selFloorId) {
  205. getProjectEquipType();
  206. changeLastFloorId(selFloorId);
  207. setLoading(true);
  208. getMapList({
  209. //floorId: 'Fl11010802593241ec348ecb4148806b9034c8957454',
  210. floorId: selFloorId,
  211. })
  212. .then((res) => {
  213. setLoading(false);
  214. var data: API.MapInfo[] = (res.data || {}).spaceList || [];
  215. var bodyWidth = document.body.offsetWidth;
  216. var mapWidth = (res.data || {}).width || 800;
  217. if (mapWidth < bodyWidth) {
  218. var mscale = 1;
  219. setTransXInit((bodyWidth - mapWidth) / 2);
  220. } else {
  221. var mscale = Number((bodyWidth / mapWidth).toFixed(4));
  222. setTransXInit(0);
  223. }
  224. var mapSize: any = {
  225. width: mapWidth * mscale,
  226. height: (res.data || {}).height * mscale,
  227. };
  228. setMapSize(mapSize);
  229. //把地图变成 屏幕大小
  230. data.forEach((item, index) => {
  231. item.width = item.width * mscale;
  232. item.height = item.height * mscale;
  233. item.left = item.left * mscale;
  234. item.top = item.top * mscale;
  235. });
  236. var maxScaleTemp = getMaxScale(data);
  237. setMaxScale(maxScaleTemp);
  238. setMapList(data);
  239. mapListCopy.current = data;
  240. //setSelNav(navigatorList[0]); //每当重新请求地图时 让选中导航的默认是第一个
  241. })
  242. .catch(() => {
  243. setLoading(false);
  244. });
  245. } else {
  246. setMapList([]);
  247. }
  248. }, [selFloorId]);
  249. const changeMapList = useCallback(
  250. (mscale, moveWidth, moveHeight) => {
  251. setScale(mscale);
  252. console.log('mscale', mscale);
  253. var mapListTemp = JSON.parse(JSON.stringify(mapListCopy.current));
  254. var mapListTemp2 = mapListTemp.map((item, index) => {
  255. if (index == 0) {
  256. // console.log('mapListTemp', mscale, item.width, item.width * mscale);
  257. }
  258. item.width = item.width * mscale;
  259. item.height = item.height * mscale;
  260. item.left = item.left * mscale - moveWidth;
  261. item.top = item.top * mscale - moveHeight;
  262. return item;
  263. });
  264. setMapList(mapListTemp2);
  265. },
  266. [mapListCopy],
  267. );
  268. const queryDeviceManage = () => {
  269. //setLoading(true);
  270. return queryEquipStatistics({
  271. floorId: selFloorId,
  272. projectId: projectObj.projectId,
  273. })
  274. .then((res) => {
  275. // setLoading(false);
  276. //if (!setTimer.current) return;
  277. var statistics = res.data.statistics || [];
  278. //赋值 运行中的设备数量
  279. navigatorList.forEach(function (nItem) {
  280. var fres = statistics.filter((sItem: statistics) => {
  281. return sItem.equipType == nItem.id;
  282. });
  283. nItem.num = (fres[0] || {}).runCount;
  284. });
  285. setNavigatorList(navigatorList);
  286. //设备空间信息
  287. var spaceList = res.data.spaceList || [];
  288. spaceList.forEach((item: any) => {
  289. var allType = ['airConditioner', 'light', 'curtain'];
  290. allType.forEach((etype) => {
  291. var filterEquip = (item.equipList || []).filter((eItem: any) => {
  292. return eItem.equipType == etype;
  293. });
  294. //有当前设备
  295. if (filterEquip.length > 0) {
  296. item.equipStatusList = item.equipStatusList ? item.equipStatusList : [];
  297. var filterRes = (item.equipStatusList || []).filter((eItem: equipStatus) => {
  298. return eItem.equipType == etype;
  299. });
  300. //不存时 赋值not 如果没有设备状态 则说明没有设备 1 是开启 0是关闭
  301. if (filterRes.length > 0) {
  302. item[etype] = filterRes[0].status;
  303. } else {
  304. item[etype] = 'nostatus';
  305. item.equipStatusList.push({
  306. equipType: etype,
  307. status: 'nostatus',
  308. });
  309. }
  310. } else {
  311. item[etype] = 'noHave';
  312. }
  313. });
  314. });
  315. //console.log('spaceList', spaceList);
  316. //debugger;
  317. setEquipMapList(spaceList);
  318. return 'next';
  319. })
  320. .catch(() => {
  321. // setLoading(false);
  322. });
  323. };
  324. let setTimer1 = useRef();
  325. let setTimer2 = useRef();
  326. async function getDeviceStatus() {
  327. await queryDeviceManage().then((res) => {
  328. setTimer1.current = setTimeout(() => {
  329. getDeviceStatus();
  330. }, 8000);
  331. });
  332. }
  333. function getProjectEquipType() {
  334. // 项目拥有的设备
  335. return queryProjectEquipType().then((res) => {
  336. const resData = res.data || [];
  337. const copynNavigatorList = JSON.parse(JSON.stringify(navigatorList));
  338. copynNavigatorList.map((item: any, idx: any) => {
  339. if (idx === 0) return; // 第一个为全部设备,不参与对比
  340. let hasEquip = false; // 没有此设备
  341. resData.map((resItem: any) => {
  342. if (item.id === resItem) {
  343. hasEquip = true;
  344. }
  345. });
  346. if (!hasEquip) {
  347. navigatorList.splice(idx, 1);
  348. setNavigatorList(navigatorList);
  349. }
  350. });
  351. console.log(navigatorList, '-----navigatorList');
  352. });
  353. }
  354. function getSpaceHasPerson(sfId: any) {
  355. //获取有人无人
  356. querySpaceAdjustList(sfId).then((res) => {
  357. //debugger;
  358. setTimer2.current = setTimeout(() => {
  359. getSpaceHasPerson(sfId);
  360. }, 8000);
  361. });
  362. }
  363. //获取设备状态 设备种类
  364. useEffect(() => {
  365. if (selFloorId) {
  366. getDeviceStatus();
  367. getSpaceHasPerson(selFloorId);
  368. // queryDeviceManage(); //第一次执行
  369. // if (setTimer.current) {
  370. // clearInterval(setTimer.current);
  371. // setTimer.current = null;
  372. // }
  373. // //循环调接口
  374. // setTimer.current = setInterval(() => {
  375. // queryDeviceManage();
  376. // }, 3000);
  377. }
  378. return () => {
  379. //clearInterval(setTimer.current);
  380. clearTimeout(setTimer1.current);
  381. clearTimeout(setTimer2.current);
  382. };
  383. }, [selFloorId]);
  384. // useEffect(() => {
  385. // if (selFloorId) {
  386. // querySpaceAdjustList(selFloorId);
  387. // }
  388. // }, [selFloorId]);
  389. //获取时间列表 spaceTimeList
  390. useEffect(() => {
  391. if (selFloorId) {
  392. //setLoading(true);
  393. queryDeviceTimeManage({
  394. floorId: selFloorId,
  395. //floorId: 'Fl11010802593241ec348ecb4148806b9034c8957454',
  396. date: moment().format('YYYYMMDD'),
  397. })
  398. .then(function (res) {
  399. // setLoading(false);
  400. var resList = res.content || [];
  401. setTimeMapList(resList);
  402. })
  403. .catch(() => {
  404. // setLoading(false);
  405. });
  406. }
  407. }, [selFloorId]);
  408. //合并空间设备数据 和 空间数据
  409. useEffect(() => {
  410. var combineList: any = [];
  411. mapList.map(function (mitem) {
  412. var spaceId = mitem.spaceId;
  413. var filterSpace1 = equipMapList.filter((ele) => {
  414. return ele.id == spaceId;
  415. });
  416. var filterSpace2 = timeMapList.filter((ele) => {
  417. return ele.id == spaceId;
  418. });
  419. var filterSpace3 = hasPersonList.filter((ele) => {
  420. return ele.id == spaceId;
  421. });
  422. var combine = Object.assign({}, filterSpace3[0], filterSpace1[0], filterSpace2[0], mitem);
  423. combineList.push(combine);
  424. });
  425. setMapCombineList(combineList);
  426. console.log('combine');
  427. }, [equipMapList, mapList, timeMapList, hasPersonList]);
  428. let firtTime: number = 0;
  429. let lastTime: number = 0;
  430. return (
  431. <>
  432. <PageHeader title={<FormattedMessage id="menu.equipment" />} action={<SearchInput />} />
  433. <TopNavigator
  434. navigatorList={navigatorList}
  435. type={'equipment'}
  436. navigatorChange={navigatorChange}
  437. action={
  438. <TopNavRight
  439. selNavObj={selNav}
  440. navigatorList={navigatorList}
  441. mapList={mapCombineList}
  442. queryDeviceManage={queryDeviceManage}
  443. ></TopNavRight>
  444. }
  445. changeFloorId={changeFloorId}
  446. selParamObj={selNav}
  447. ></TopNavigator>
  448. <div className={styles.maptop}>
  449. {selNav.id !== 'all' && selNav.id !== 'curtain' && (
  450. <div className={styles.left}>
  451. <span>
  452. <Icon
  453. className=""
  454. type="youren"
  455. style={{ color: '#CE9F27', fontWeight: 'bold', fontSize: '9px' }}
  456. ></Icon>
  457. 有人
  458. </span>
  459. <span>
  460. <Icon
  461. className=""
  462. type="wuren"
  463. style={{ color: '#8B949E', fontWeight: 'bold', fontSize: '9px' }}
  464. ></Icon>
  465. 无人
  466. </span>
  467. </div>
  468. )}
  469. {selNav.id !== 'all' && selNav.id !== 'curtain' && (
  470. <div className={styles.right}>
  471. <div className={styles.rightOpen}>
  472. <div>
  473. <span
  474. className={styles.circle}
  475. style={{ backgroundColor: 'rgba(' + selNav.colorStr + '1)' }}
  476. ></span>
  477. <span>开启</span>
  478. </div>
  479. <div>
  480. <span
  481. className={styles.circle}
  482. style={{ backgroundColor: 'rgba(' + selNav.colorStr + '0.4)' }}
  483. ></span>
  484. <span>部分开启</span>
  485. </div>
  486. <div>
  487. <span
  488. className={styles.circle}
  489. style={{ backgroundColor: 'rgba(196, 196, 196, 0.6)' }}
  490. ></span>
  491. <span>关闭</span>
  492. </div>
  493. </div>
  494. </div>
  495. )}
  496. {selNav.id == 'curtain' && (
  497. <div className={styles.right}>
  498. <div>
  499. <span
  500. className={styles.circle}
  501. style={{ backgroundColor: 'rgba(' + selNav.colorStr + '1)' }}
  502. ></span>
  503. <span>有</span>
  504. </div>
  505. <div>
  506. <span className={cx(styles.circle, styles.noCurtain)}></span>
  507. <span>无</span>
  508. </div>
  509. </div>
  510. )}
  511. </div>
  512. <Spin spinning={loading} wrapperClassName={mapstyles.spinnclass}>
  513. {mapCombineList.length > 0 && (
  514. <Map
  515. changeMapList={changeMapList}
  516. mapList={mapCombineList}
  517. mapSize={mapSize}
  518. maxscale={maxScale}
  519. transXInit={transXInit}
  520. type={'equipment'}
  521. selFloorId={selFloorId}
  522. render={(item, index) => {
  523. return (
  524. <div
  525. className={mapstyles.houseWrap}
  526. key={index + item.id}
  527. style={{
  528. left: item.left,
  529. top: item.top,
  530. width: item.width,
  531. height: item.height,
  532. }}
  533. >
  534. <div
  535. style={{
  536. backgroundColor: item.canClick
  537. ? selNav.id == 'all'
  538. ? 'rgba(196, 196, 196, 0.4)'
  539. : getColorOpacity(item[selNav.id])
  540. : '',
  541. }}
  542. className={cx(mapstyles.house, {
  543. [mapstyles.notclick]: !item.canClick || item[selNav.id] == 'noHave',
  544. [mapstyles.searchSel]: item.spaceId && item.spaceId === searchSpace.spaceId,
  545. })}
  546. onClick={(event) => {
  547. event.stopPropagation();
  548. if (lastTime - firtTime < 200) {
  549. spaceControl(item, index);
  550. }
  551. }}
  552. onMouseDown={(event) => {
  553. //event.stopPropagation();
  554. firtTime = new Date().getTime();
  555. }}
  556. onMouseUp={(event) => {
  557. //event.stopPropagation();
  558. lastTime = new Date().getTime();
  559. }}
  560. >
  561. {/* {selNav.id !== 'all' && item[selNav.id] == 'noHave' && (
  562. <div className={mapstyles.noDevice}>
  563. <span className={mapstyles.noText}>无设备</span>
  564. </div>
  565. style={{ display: item.width > 80 && item.height > 50 ? 'flex' : 'none' }}
  566. )} */}
  567. {selNav.id == 'all' && (
  568. <div
  569. className={mapstyles.allDevice}
  570. style={{
  571. transform:
  572. scale == maxScale
  573. ? 'scale(1)'
  574. : item.width < 24 * (item.equipStatusList || []).length ||
  575. item.height < 24
  576. ? 'scale(0.3)'
  577. : 'scale(1)',
  578. }}
  579. >
  580. {/* 所有设备的图标列表 */}
  581. {(item.equipStatusList || []).map((ditem: equipStatus, dindex: number) => {
  582. return (
  583. <div
  584. key={dindex + 'device'}
  585. className={mapstyles.icon}
  586. style={{
  587. backgroundColor: getColorOpacity(ditem.status, ditem.equipType),
  588. }}
  589. >
  590. <Icon
  591. className=""
  592. type={ditem.equipType}
  593. style={{ color: '#fff', fontWeight: 'bold', fontSize: '8px' }}
  594. ></Icon>
  595. </div>
  596. );
  597. })}
  598. </div>
  599. )}
  600. {(selNav.id == 'airConditioner' || selNav.id == 'light') &&
  601. item.isPassengerPass &&
  602. item.canClick && (
  603. <div
  604. className={mapstyles.hasPerson}
  605. style={{
  606. transform:
  607. scale == maxScale
  608. ? 'scale(1)'
  609. : item.width < 46 || item.height < 25
  610. ? 'scale(0.4)'
  611. : 'scale(1)',
  612. }}
  613. >
  614. <Icon
  615. className=""
  616. type="youren"
  617. style={{ color: '#CE9F27', fontWeight: 'bold', fontSize: '9px' }}
  618. ></Icon>
  619. </div>
  620. )}
  621. {(selNav.id == 'airConditioner' || selNav.id == 'light') &&
  622. item.isPassengerPass == false &&
  623. item.canClick && (
  624. <div
  625. className={mapstyles.hasPerson}
  626. style={{
  627. transform:
  628. scale == maxScale
  629. ? 'scale(1)'
  630. : item.width < 46 || item.height < 25
  631. ? 'scale(0.4)'
  632. : 'scale(1)',
  633. }}
  634. >
  635. <Icon
  636. className=""
  637. type="wuren"
  638. style={{ color: '#8B949E', fontWeight: 'bold', fontSize: '9px' }}
  639. ></Icon>
  640. </div>
  641. )}
  642. {item.canClick && item[selNav.id] != 'noHave' && (
  643. <div
  644. className={mapstyles.showModal}
  645. onClick={(event) => {
  646. event.stopPropagation();
  647. if (lastTime - firtTime < 400) {
  648. showModalClick(item);
  649. }
  650. }}
  651. onMouseDown={(event) => {
  652. //event.stopPropagation();
  653. firtTime = new Date().getTime();
  654. }}
  655. onMouseUp={(event) => {
  656. //event.stopPropagation();
  657. lastTime = new Date().getTime();
  658. }}
  659. style={{
  660. transform: `scale(${scale - 0.1 < 1 ? scale - 0.1 : 1})`,
  661. }}
  662. >
  663. <Icon className="" type="hover" style={{ fontSize: '10px' }}></Icon>
  664. </div>
  665. )}
  666. <div className={mapstyles.content}>
  667. <Icon
  668. className=""
  669. type={getSpaceFunc(item.roomFuncType)}
  670. style={{
  671. fontSize: 18,
  672. display: item.width > 28 && item.height > 50 ? 'block' : 'none',
  673. }}
  674. ></Icon>
  675. <div
  676. className={mapstyles.name}
  677. style={{
  678. display:
  679. (item.width > 64 && item.height > 80) ||
  680. item.height > 140 ||
  681. item.width > 120 ||
  682. scale == maxScale
  683. ? 'block'
  684. : 'none',
  685. }}
  686. >
  687. {item.localName}
  688. </div>
  689. {(getSpaceFunc(item.roomFuncType) || item.localName) &&
  690. !(
  691. (getSpaceFunc(item.roomFuncType) &&
  692. item.width > 28 &&
  693. item.height > 50) ||
  694. (item.localName &&
  695. ((item.width > 64 && item.height > 80) ||
  696. item.height > 140 ||
  697. item.width > 120 ||
  698. scale == maxScale))
  699. ) && <div className={mapstyles.pointer}>.</div>}
  700. </div>
  701. </div>
  702. </div>
  703. );
  704. }}
  705. ></Map>
  706. )}
  707. </Spin>
  708. {showModal && (
  709. <DeviceModal
  710. showSpace={showSpace}
  711. onClose={() => {
  712. setShowModal(false);
  713. }}
  714. ></DeviceModal>
  715. )}
  716. </>
  717. );
  718. };
  719. export default Environment;