sun-chaochao 3 лет назад
Родитель
Сommit
2abe7c568f

+ 10 - 1
src/pages/device/Instance/Detail/MetadataLog/Property/Charts.tsx

@@ -1,3 +1,4 @@
+import { Empty } from 'antd';
 import * as echarts from 'echarts';
 import _ from 'lodash';
 import { useEffect, useRef } from 'react';
@@ -58,7 +59,15 @@ const Charts = (props: Props) => {
     }
   }, [props.data]);
 
-  return <div id="charts" style={{ width: '100%', height: 500 }}></div>;
+  return (
+    <div>
+      {Array.isArray(props?.data) && props?.data.length > 2 ? (
+        <div id="charts" style={{ width: '100%', height: 500 }}></div>
+      ) : (
+        <Empty />
+      )}
+    </div>
+  );
 };
 
 export default Charts;

+ 2 - 3
src/pages/device/Instance/Detail/MetadataLog/Property/index.tsx

@@ -187,7 +187,6 @@ const PropertyLog = (props: Props) => {
         value: undefined,
         type: data?.name || '',
       });
-      console.log(dataList.length);
       setChartsList(dataList || []);
     }
   };
@@ -199,7 +198,7 @@ const PropertyLog = (props: Props) => {
     if (resp.status === 200) {
       const dataList: any[] = [
         {
-          year: start,
+          year: end,
           value: undefined,
           type: data?.name || '',
         },
@@ -213,7 +212,7 @@ const PropertyLog = (props: Props) => {
         });
       });
       dataList.push({
-        year: end,
+        year: start,
         value: undefined,
         type: data?.name || '',
       });

+ 10 - 10
src/pages/device/Instance/Detail/Running/Property/FileComponent/index.less

@@ -2,27 +2,27 @@
   display: flex;
   align-items: center;
   width: 100%;
-  max-height: 60px;
 
-  .other {
+  .cardValue {
+    display: flex;
+    align-items: center;
     width: 100%;
+    height: 60px;
     overflow: hidden;
     color: #323130;
     font-weight: 700;
     font-size: 24px;
     white-space: nowrap;
     text-overflow: ellipsis;
-  }
 
-  .img {
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    width: 60px;
-    height: 100%;
+    img {
+      width: 60px;
+    }
+  }
 
+  .otherValue {
     img {
-      width: 100%;
+      width: 40px;
     }
   }
 }

+ 8 - 8
src/pages/device/Instance/Detail/Running/Property/FileComponent/index.tsx

@@ -33,14 +33,14 @@ const FileComponent = (props: Props) => {
 
   const renderValue = () => {
     if (value?.formatValue !== 0 && !value?.formatValue) {
-      return <div className={props.type === 'card' ? styles.other : {}}>--</div>;
+      return <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>--</div>;
     } else if (data?.valueType?.type === 'file') {
       if (
         data?.valueType?.fileType === 'base64' ||
         data?.valueType?.fileType === 'Binary(二进制)'
       ) {
         return (
-          <div className={props.type === 'card' ? styles.other : {}}>
+          <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
             <Tooltip placement="topLeft" title={String(value?.formatValue)}>
               {String(value?.formatValue)}
             </Tooltip>
@@ -51,7 +51,7 @@ const FileComponent = (props: Props) => {
         // 图片
         return (
           <div
-            className={styles.img}
+            className={props.type === 'card' ? styles.cardValue : styles.otherValue}
             onClick={() => {
               if (isHttps && value?.formatValue.indexOf('http:') !== -1) {
                 message.error('域名为https时,不支持访问http地址');
@@ -80,7 +80,7 @@ const FileComponent = (props: Props) => {
       ) {
         return (
           <div
-            className={styles.img}
+            className={props.type === 'card' ? styles.cardValue : styles.otherValue}
             onClick={() => {
               if (isHttps && value?.formatValue.indexOf('http:') !== -1) {
                 message.error('域名为https时,不支持访问http地址');
@@ -107,20 +107,20 @@ const FileComponent = (props: Props) => {
             value?.formatValue.includes(item),
           ) || '';
         return (
-          <div className={styles.img}>
+          <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
             <img src={imgMap.get(flag.slice(1))} />
           </div>
         );
       } else {
         return (
-          <div className={styles.img}>
+          <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
             <img src={imgMap.get('other')} />
           </div>
         );
       }
     } else if (data?.valueType?.type === 'object' || data?.valueType?.type === 'geoPoint') {
       return (
-        <div className={props.type === 'card' ? styles.other : {}}>
+        <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
           <Tooltip placement="topLeft" title={JSON.stringify(value?.formatValue)}>
             {JSON.stringify(value?.formatValue)}
           </Tooltip>
@@ -128,7 +128,7 @@ const FileComponent = (props: Props) => {
       );
     } else {
       return (
-        <div className={props.type === 'card' ? styles.other : {}}>
+        <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
           <Tooltip placement="topLeft" title={String(value?.formatValue)}>
             {String(value?.formatValue)}
           </Tooltip>