Browse Source

Merge branch 'master' of http://39.106.8.246:3003/sagacloud/sagacloud-manager-control

zhaojijng 2 năm trước cách đây
mục cha
commit
b29b5ddaab

+ 4 - 3
config/proxy.ts

@@ -26,11 +26,12 @@ export default {
     //   },
     // },
     '/sgadmin': {
-      target: 'https://duoduoenv.sagacloud.cn/',
-      //target: 'http://10.100.28.79',
+      //   target: 'https://duoduoenv.sagacloud.cn/',
+      target: 'http://10.100.28.79',
       changeOrigin: true,
       pathRewrite: {
-        '^/sgadmin': '',
+        '^/sgadmin': '/sgadmin',
+        // '^/sgadmin': '/',
       },
     },
   },

+ 3 - 4
src/models/sagacare_spaceFunc.ts

@@ -47,17 +47,16 @@ export default function () {
   //获取房间类型 来显示相应的图片
   const getSpaceFunc = useCallback((spaceCode: any) => {
     //var nowkey = 'device';
-    var nowkey = '';
     var flag = false;
     for (var key in allFunc) {
       var codeArr = allFunc[key];
       if (codeArr.indexOf(spaceCode) > -1) {
         flag = true;
-        nowkey = key;
-        return;
+        return key;
       }
     }
-    return nowkey;
+
+    return '';
   }, []);
 
   return {

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

@@ -333,7 +333,10 @@ const Environment: React.FC = () => {
                       <Icon
                         className=""
                         type={getSpaceFunc(item.roomFuncType)}
-                        style={{ fontSize: 20 }}
+                        style={{
+                          fontSize: 20,
+                          display: item.width > 40 && item.height > 40 ? 'block' : 'none',
+                        }}
                       ></Icon>
                       <div
                         className={mapstyles.name}

+ 58 - 22
src/pages/Equipment/components/deviceModal/airEq/index.jsx

@@ -1,4 +1,4 @@
-import React, { useState, useEffect, useRef } from 'react';
+import React, { useState, useEffect, useRef, useCallback } from 'react';
 import { message } from 'antd';
 import styles from './index.less';
 import commonStyles from '../common.less';
@@ -19,9 +19,13 @@ export default ({ spaceId, projectId }) => {
     wind_down,
   } = equipImageMap;
   const hasAir = true;
-  const [isOpen, setIsOpen] = useState(true);
+  let isNowAirStatus = useRef('');
+  let firstLoading = useRef(true);
+  let [isOpen, setIsOpen] = useState(false);
+  let [isLoading, setIsLoading] = useState(false);
   const [imgSrc, setImgSrc] = useState(null);
   let timer = useRef(null);
+  let airLoadingTimer = useRef(null);
   const [spaceStatus, setStatusText] = useState('null');
   const airExpend = [
     {
@@ -59,30 +63,61 @@ export default ({ spaceId, projectId }) => {
   };
 
   function timerGetAirInfo(timeLong) {
-    clearInterval(timer.current);
-    timer.current = setInterval(() => {
+    clearTimeout(timer.current);
+    timer.current = setTimeout(() => {
       getAirInfo(); // 获取空调状态
     }, timeLong);
   }
 
   function changeSwitch(val) {
-    const itemIdSum = val ? 12 : 10; // 10关闭 12开启
-    clearInterval(timer.current);
-    changeAir(itemIdSum);
+    if (!isLoading) {
+      setIsLoading(true);
+      changeIsLoading(val);
+      const itemIdSum = val ? 12 : 10; // 10关闭 12开启¬
+      changeAir(itemIdSum);
+    }
   }
 
-  const getAirInfo = () => {
+  const changeIsLoading = (val) => {
+    let countTimer = 0;
+    airLoadingTimer.current = setInterval(() => {
+      if (countTimer >= 30 || isNowAirStatus.current === val) {
+        setIsOpen(val); // 开关
+        setIsLoading(false);
+        clearInterval(airLoadingTimer.current);
+      } else {
+        countTimer++;
+      }
+    }, 1000);
+  };
+
+  const getAirInfo = useCallback(() => {
     const paramsObj = {
       objectId: spaceId,
       projectId: projectId,
     };
-    getFeedbackDocumentsHttp(paramsObj).then((res) => {
-      const val = res.icon == 7 ? false : true;
-      setIsOpen(val); // 开关
-      setStatusText(res.spaceStatus); // 状态文案
-      statusImg(res.icon); // icon
-    });
-  };
+    getFeedbackDocumentsHttp(paramsObj)
+      .then((res) => {
+        const val = res.icon == 7 ? false : true;
+        if (firstLoading.current) {
+          isNowAirStatus.current = val;
+          setIsOpen(val); // 开关
+          setIsLoading(false);
+        } else {
+          isNowAirStatus.current = val;
+        }
+        firstLoading.current = false;
+        // setFirstLoading(false)
+        timerGetAirInfo(1000);
+        setStatusText(res.spaceStatus); // 状态文案
+        statusImg(res.icon); // icon
+      })
+      .catch(() => {
+        timerGetAirInfo(1000);
+        firstLoading.current = false;
+        // setIsLoading(false);
+      });
+  }, []);
 
   const changeAir = (itemId) => {
     const paramsObj = {
@@ -92,20 +127,20 @@ export default ({ spaceId, projectId }) => {
     };
     changeAirHttp(paramsObj).then((res) => {
       if (res.result == 'success') {
-        message.success('指令下发成功');
-        getAirInfo();
-        timerGetAirInfo(3000);
+        // message.success('指令下发成功');
+        // getAirInfo();
+        // timerGetAirInfo(2000);
       } else {
-        message.error('操作失败,请重试');
+        // message.error('操作失败,请重试');
       }
     });
   };
 
   useEffect(() => {
     getAirInfo(); // 获取空调状态
-    timerGetAirInfo(3000);
+    timerGetAirInfo(2000);
     return () => {
-      clearInterval(timer.current);
+      clearTimeout(timer.current);
     };
   }, []);
 
@@ -162,7 +197,8 @@ export default ({ spaceId, projectId }) => {
             }}
             className={commonStyles.eqBtn}
           >
-            <AnSwitch isOpen={isOpen} />
+            <AnSwitch isOpen={isOpen} isAir={true} isLoading={isLoading} />
+            {/*<Switch loading isOpen />*/}
           </div>
         </div>
       </div>

+ 17 - 3
src/pages/Equipment/components/deviceModal/anSwitch/index.jsx

@@ -1,11 +1,25 @@
 import React, { useState, useEffect } from 'react';
+import { Spin } from 'antd';
+import { LoadingOutlined } from '@ant-design/icons';
+
+const antIcon = (
+  <LoadingOutlined
+    style={{
+      fontSize: 14,
+    }}
+    spin
+  />
+);
 import './index.less';
 
-export default ({ isOpen }) => {
+export default ({ isOpen, isAir, isLoading }) => {
   return (
     <div className="box">
-      <div className={`content ${isOpen ? null : 'closeBg'}`}>
-        <div className={`point  ${isOpen ? null : 'closePt'}`}></div>
+      {isAir && isLoading ? (
+        <Spin indicator={antIcon} className={`box-loading ${isOpen ? '' : 'box-close-loading'}`} />
+      ) : null}
+      <div className={`content ${isOpen ? '' : 'closeBg'}`}>
+        <div className={`point  ${isOpen ? '' : 'closePt'}`}></div>
       </div>
     </div>
   );

+ 14 - 0
src/pages/Equipment/components/deviceModal/anSwitch/index.less

@@ -1,9 +1,22 @@
 .box {
+  position: relative;
   display: flex;
   align-items: center;
   justify-content: center;
   width: 54px;
   height: 30px;
+
+  .box-loading {
+    position: absolute;
+    top: 50%;
+    left: 60%;
+    z-index: 333;
+    transform: translateY(-50%);
+  }
+  .box-close-loading {
+    left: 14%;
+  }
+
   .content {
     position: relative;
     width: 48px;
@@ -34,6 +47,7 @@
       box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.03);
       transform: translate(90%, 0%);
       transition: transform 0.3s cubic-bezier(0.3, 1.05, 0.4, 1.05);
+
       &.closePt {
         transform: translate(-10%, 0%);
       }

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

@@ -549,7 +549,10 @@ const Environment: React.FC = () => {
                         <Icon
                           className=""
                           type={getSpaceFunc(item.roomFuncType)}
-                          style={{ fontSize: 20 }}
+                          style={{
+                            fontSize: 20,
+                            display: item.width > 40 && item.height > 40 ? 'block' : 'none',
+                          }}
                         ></Icon>
                         <div
                           className={mapstyles.name}

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

@@ -269,7 +269,12 @@ const Runtime: React.FC = () => {
                       : '',
                   }}
                 >
-                  <div className={mapstyles.allTime}>
+                  <div
+                    className={mapstyles.allTime}
+                    style={{
+                      display: item.width > 86 && item.height > 40 ? 'block' : 'none',
+                    }}
+                  >
                     {/* {(item.timeList || []).map(function (titem: string, tindex: number) {
                   return <span key={tindex + 'time'}>{titem},</span>;
                 })} */}
@@ -316,7 +321,10 @@ const Runtime: React.FC = () => {
                     <Icon
                       className=""
                       type={getSpaceFunc(item.roomFuncType)}
-                      style={{ fontSize: 20 }}
+                      style={{
+                        fontSize: 20,
+                        display: item.width > 40 && item.height > 40 ? 'block' : 'none',
+                      }}
                     ></Icon>
                     <div
                       className={mapstyles.name}