|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState, useEffect, useCallback } from 'react';
|
|
|
+import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
|
import { FormattedMessage, useModel } from 'umi';
|
|
|
|
|
|
import SearchInput from '@/components/SearchInput';
|
|
@@ -177,27 +177,28 @@ const Environment: React.FC = () => {
|
|
|
// clearInterval(interval);
|
|
|
// }, 60000);
|
|
|
// }
|
|
|
+ //现在加上循环调用 所以把手动关了
|
|
|
function callback() {
|
|
|
//这是在手动改变状态
|
|
|
- var mapCopy = JSON.parse(JSON.stringify(mapCombineList));
|
|
|
- mapCopy[index][selNav.id] = item[selNav.id] === 1 ? 0 : 1;
|
|
|
- setMapCombineList(mapCopy);
|
|
|
+ // var mapCopy = JSON.parse(JSON.stringify(mapCombineList));
|
|
|
+ // mapCopy[index][selNav.id] = item[selNav.id] === 1 ? 0 : 1;
|
|
|
+ // setMapCombineList(mapCopy);
|
|
|
}
|
|
|
|
|
|
//如果是空调
|
|
|
if (selNav.id == 'airConditioner') {
|
|
|
- function getDeviceStatus() {
|
|
|
- //执行查询函数
|
|
|
- getAirInfo(item, callback, 10, projectId);
|
|
|
- }
|
|
|
+ // function getDeviceStatus() {
|
|
|
+ // //执行查询函数
|
|
|
+ // getAirInfo(item, callback, 10, projectId);
|
|
|
+ // }
|
|
|
//changeAir(item, index, getDeviceStatus);
|
|
|
changeAir(item, index, callback);
|
|
|
}
|
|
|
if (selNav.id == 'light') {
|
|
|
- function getDeviceStatus() {
|
|
|
- //请求状态 10是指循环调10次
|
|
|
- getLamp(item, callback, 10);
|
|
|
- }
|
|
|
+ // function getDeviceStatus() {
|
|
|
+ // //请求状态 10是指循环调10次
|
|
|
+ // getLamp(item, callback, 10);
|
|
|
+ // }
|
|
|
//debugger;
|
|
|
// changeLight('one', [item], getDeviceStatus, status);
|
|
|
changeLight('one', [item], callback, status);
|
|
@@ -288,11 +289,27 @@ const Environment: React.FC = () => {
|
|
|
// setLoading(false);
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
+ let setTimer = useRef({});
|
|
|
//获取设备状态 设备种类
|
|
|
useEffect(() => {
|
|
|
+ // function getDeviceStatus() {
|
|
|
+ // queryDeviceManage().then((res) => {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // getDeviceStatus();
|
|
|
+ // }, 20000);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
if (selFloorId) {
|
|
|
queryDeviceManage();
|
|
|
+ if (setTimer.current) {
|
|
|
+ clearInterval(setTimer.current);
|
|
|
+ setTimer.current = null;
|
|
|
+ }
|
|
|
+ //加了循环调接口
|
|
|
+ setTimer.current = setInterval(() => {
|
|
|
+ queryDeviceManage();
|
|
|
+ }, 3000);
|
|
|
}
|
|
|
}, [selFloorId]);
|
|
|
|