Kaynağa Gözat

修改 运行时间字符串显示不对的问题 co2 pm2.5 没有值的时候的样式问题

zhaojijng 2 yıl önce
ebeveyn
işleme
ffd1197c62

+ 16 - 11
src/pages/Environment/index.tsx

@@ -274,15 +274,18 @@ const Environment: React.FC = () => {
               >
                 <div
                   className={cx(mapstyles.house, {
-                    [mapstyles.notclick]: !item.roomFuncType,
+                    [mapstyles.notclick]:
+                      !item.roomFuncType || (!item.avgValues && item.avgValues != 0),
                     [mapstyles.searchSel]: item.spaceId && item.spaceId === searchSpace.spaceId,
                   })}
                   style={{
                     background: item.roomFuncType
-                      ? 'rgba(' +
-                        selNav.colorStr +
-                        (selNav.opacity as number) * getColorOpacity(item.avgValues) +
-                        ')'
+                      ? item.avgValues || item.avgValues == 0
+                        ? 'rgba(' +
+                          selNav.colorStr +
+                          (selNav.opacity as number) * getColorOpacity(item.avgValues) +
+                          ')'
+                        : ''
                       : '',
                   }}
                   onClick={(event) => {
@@ -301,12 +304,14 @@ const Environment: React.FC = () => {
                   }}
                 >
                   <div className={mapstyles.content}>
-                    <Icon
-                      className=""
-                      type={getSpaceFunc(item.roomFuncType)}
-                      style={{ fontSize: 20 }}
-                    ></Icon>
-                    <div className={mapstyles.name}>{item.localName}</div>
+                    <div className={mapstyles.contentDiv}>
+                      <Icon
+                        className=""
+                        type={getSpaceFunc(item.roomFuncType)}
+                        style={{ fontSize: 20 }}
+                      ></Icon>
+                      <div className={mapstyles.name}>{item.localName}</div>
+                    </div>
                   </div>
                 </div>
               </div>

+ 3 - 1
src/pages/Equipment/index.tsx

@@ -302,7 +302,6 @@ const Environment: React.FC = () => {
 
     if (selFloorId) {
       queryDeviceManage(); //第一次执行
-
       if (setTimer.current) {
         clearInterval(setTimer.current);
         setTimer.current = null;
@@ -311,6 +310,9 @@ const Environment: React.FC = () => {
       setTimer.current = setInterval(() => {
         queryDeviceManage();
       }, 3000);
+      return () => {
+        clearInterval(setTimer.current);
+      };
     }
   }, [selFloorId]);
 

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

@@ -93,6 +93,7 @@ const Runtime: React.FC = () => {
         resList.forEach((ritem) => {
           ritem.runTimeStatus = 'normalRun'; //正常工作
           var timeList = [];
+
           if (ritem.hasOwnProperty('workTimeStartTime')) {
             var timeStrArr = [ritem.workTimeStartTime, ritem.workTimeEndTime];
             timeList.push(timeStrArr);
@@ -110,9 +111,17 @@ const Runtime: React.FC = () => {
             ritem.runTimeStatus = 'overtimeWork'; //加班
           }
           ritem.showTimeList = timeList;
+          console.log('timeList', timeList);
           ritem.showTimeStr =
-            timeList.length > 0 ? timeList[0][0] + '-' + timeList[timeList.length - 1][1] : '';
+            timeList.length > 0
+              ? timeList[0][0] +
+                '-' +
+                (timeList[timeList.length - 1][1] > timeList[0][1]
+                  ? timeList[timeList.length - 1][1]
+                  : timeList[0][1])
+              : '';
         });
+
         setSpaceTimeList(resList);
       })
       .catch(() => {
@@ -135,6 +144,10 @@ const Runtime: React.FC = () => {
       setTimer.current = setInterval(() => {
         getDeviceTime();
       }, 10000);
+
+      return () => {
+        clearInterval(setTimer.current);
+      };
     }
   }, [selFloorId, selTime]);