Просмотр исходного кода

feat(merge): merge sc

fix: 修改运行状态样式
Lind 3 лет назад
Родитель
Сommit
4f49cc9f3d

+ 7 - 4
src/components/ProTableCard/CardItems/AlarmConfig.tsx

@@ -41,19 +41,22 @@ export default (props: AlarmConfigProps) => {
           <div className={'card-item-content'}>
             <div>
               <label>关联场景联动</label>
-              <div>
+              <div className={'ellipsis'}>
                 <PermissionButton
                   type={'link'}
                   isPermission={!!getMenuPathByCode(MENUS_CODE['rule-engine/Scene'])}
                   style={{ padding: 0, height: 'auto' }}
+                  tooltip={{
+                    title: !!getMenuPathByCode(MENUS_CODE['rule-engine/Scene'])
+                      ? props?.sceneName
+                      : '没有权限,请联系管理员',
+                  }}
                   onClick={() => {
                     const url = getMenuPathByCode('rule-engine/Scene/Save');
                     history.push(`${url}?id=${props.sceneId}`);
                   }}
                 >
-                  <div className={'ellipsis'}>
-                    <Tooltip title={props?.sceneName || ''}>{props?.sceneName || ''}</Tooltip>
-                  </div>
+                  {props?.sceneName || ''}
                 </PermissionButton>
               </div>
             </div>

+ 1 - 0
src/pages/device/Instance/Detail/MetadataLog/Property/AMap.tsx

@@ -49,6 +49,7 @@ export default (props: Props) => {
             type="primary"
             onClick={() => {
               if (PathNavigatorRef.current) {
+                PathNavigatorRef.current.moveToPoint(0, 0);
                 PathNavigatorRef.current.stop();
               }
             }}

+ 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>

+ 22 - 3
src/pages/device/Instance/Detail/Running/Property/index.tsx

@@ -11,7 +11,7 @@ import EditProperty from './EditProperty';
 import { useParams } from 'umi';
 import PropertyLog from '../../MetadataLog/Property';
 import styles from './index.less';
-import { throttle } from 'lodash';
+import { groupBy, throttle, toArray } from 'lodash';
 import PropertyTable from './PropertyTable';
 
 interface Props {
@@ -166,9 +166,28 @@ const Property = (props: Props) => {
     setLoading(true);
     service.propertyRealTime(param).subscribe({
       next: (resp) => {
+        if (resp.status === 200) {
+          const t1 = (resp?.result || []).map((item: any) => {
+            return {
+              timeString: item.data?.timeString,
+              timestamp: item.data?.timestamp,
+              ...item?.data?.value,
+            };
+          });
+          const obj: any = {};
+          toArray(groupBy(t1, 'property'))
+            .map((item) => {
+              return {
+                list: item.sort((a, b) => b.timestamp - a.timestamp),
+                property: item[0].property,
+              };
+            })
+            .forEach((i) => {
+              obj[i.property] = i.list[0];
+            });
+          setPropertyValue({ ...propertyValue, ...obj });
+        }
         setLoading(false);
-        propertyValue[resp.property] = resp.list[0];
-        setPropertyValue({ ...propertyValue });
       },
     });
   };

+ 17 - 18
src/pages/device/Instance/service.ts

@@ -1,9 +1,9 @@
 import BaseService from '@/utils/BaseService';
 import { request } from 'umi';
-import type { DeviceInstance, PropertyData } from '@/pages/device/Instance/typings';
+import type { DeviceInstance } from '@/pages/device/Instance/typings';
 import SystemConst from '@/utils/const';
-import { defer, from, mergeMap, toArray } from 'rxjs';
-import { filter, groupBy, map } from 'rxjs/operators';
+import { defer, from } from 'rxjs';
+import { map } from 'rxjs/operators';
 
 class Service extends BaseService<DeviceInstance> {
   public detail = (id: string) => request(`${this.uri}/${id}/detail`, { method: 'GET' });
@@ -82,21 +82,20 @@ class Service extends BaseService<DeviceInstance> {
           data,
         }),
       ).pipe(
-        filter((resp) => resp.status === 200),
-        map((resp) => resp.result),
-        mergeMap((temp: PropertyData[]) => from(temp)),
-        map((item) => ({
-          timeString: item.data.timeString,
-          timestamp: item.data.timestamp,
-          ...item.data.value,
-        })),
-        groupBy((group$) => group$.property),
-        mergeMap((group) => group.pipe(toArray())),
-        map((arr) => ({
-          list: arr.sort((a, b) => a.timestamp - b.timestamp),
-          property: arr[0].property,
-        })),
-        // toArray()
+        // filter((resp) => resp.status === 200),
+        map((resp) => resp),
+        // mergeMap((temp: PropertyData[]) => from(temp)),
+        // map((item) => ({
+        //   timeString: item.data.timeString,
+        //   timestamp: item.data.timestamp,
+        //   ...item.data.value,
+        // })),
+        // groupBy((group$) => group$.property),
+        // mergeMap((group) => group.pipe(toArray())),
+        // map((arr) => ({
+        //   list: arr.sort((a, b) => a.timestamp - b.timestamp),
+        //   property: arr[0].property,
+        // }))
       ),
     );
 

+ 11 - 5
src/pages/device/Product/Detail/Access/AccessConfig/index.tsx

@@ -1,5 +1,5 @@
 import { useEffect, useState } from 'react';
-import { Button, Col, message, Modal, Pagination, Row } from 'antd';
+import { Col, message, Modal, Pagination, Row } from 'antd';
 import { service } from '@/pages/link/AccessConfig';
 import { productModel } from '@/pages/device/Product';
 import SearchComponent from '@/components/SearchComponent';
@@ -8,6 +8,8 @@ import styles from './index.less';
 import Service from '@/pages/device/Product/service';
 
 import AccessConfigCard from '@/components/ProTableCard/CardItems/AccessConfig';
+import { getMenuPathByCode } from '@/utils/menu';
+import PermissionButton from '@/components/PermissionButton';
 
 interface Props {
   close: () => void;
@@ -17,6 +19,7 @@ interface Props {
 const AccessConfig = (props: Props) => {
   const { close } = props;
   const service1 = new Service('device-product');
+  const { permission } = PermissionButton.usePermission('link/AccessConfig');
 
   const [dataSource, setDataSource] = useState<any>({
     data: [],
@@ -127,19 +130,22 @@ const AccessConfig = (props: Props) => {
           }}
         />
         <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
-          <Button
-            type="primary"
+          <PermissionButton
+            isPermission={permission.add}
             onClick={() => {
-              const tab: any = window.open(`${origin}/#/link/AccessConfig/Detail`);
+              const url = getMenuPathByCode('link/AccessConfig/Detail');
+              const tab: any = window.open(`${origin}/#${url}`);
               tab!.onTabSaveSuccess = (value: any) => {
                 if (value.status === 200) {
                   handleSearch(param);
                 }
               };
             }}
+            key="button"
+            type="primary"
           >
             新增
-          </Button>
+          </PermissionButton>
         </div>
       </div>
       <Row gutter={[16, 16]}>

+ 11 - 1
src/pages/link/Certificate/index.tsx

@@ -2,7 +2,7 @@ import { PageContainer } from '@ant-design/pro-layout';
 import { useRef, useState } from 'react';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import ProTable from '@jetlinks/pro-table';
-import { message } from 'antd';
+import { message, Tooltip } from 'antd';
 import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import SearchComponent from '@/components/SearchComponent';
@@ -29,10 +29,20 @@ const Certificate = () => {
     {
       dataIndex: 'name',
       title: '证书名称',
+      width: '30%',
+      ellipsis: true,
     },
     {
       dataIndex: 'description',
       title: '说明',
+      width: '30%',
+      render: (text: any) => (
+        <div style={{ width: '100%' }} className="ellipsis">
+          <Tooltip placement="topLeft" title={text}>
+            {text}
+          </Tooltip>
+        </div>
+      ),
     },
     {
       title: intl.formatMessage({

+ 20 - 15
src/pages/rule-engine/Alarm/Configuration/index.tsx

@@ -62,17 +62,23 @@ const Configuration = () => {
     {
       title: '关联场景联动',
       dataIndex: 'sceneName',
+      width: 160,
       render: (text: any, record: any) => (
         <PermissionButton
           type={'link'}
           isPermission={!!getMenuPathByCode(MENUS_CODE['rule-engine/Scene'])}
-          style={{ padding: 0, height: 'auto' }}
+          style={{ padding: 0, height: 'auto', width: '100%' }}
+          tooltip={{
+            title: !!getMenuPathByCode(MENUS_CODE['rule-engine/Scene'])
+              ? text
+              : '没有权限,请联系管理员',
+          }}
           onClick={() => {
             const url = getMenuPathByCode('rule-engine/Scene/Save');
             history.push(`${url}?id=${record.sceneId}`);
           }}
         >
-          {text}
+          <span className="ellipsis">{text}</span>
         </PermissionButton>
       ),
     },
@@ -86,6 +92,7 @@ const Configuration = () => {
     {
       title: '说明',
       dataIndex: 'description',
+      ellipsis: true,
     },
     {
       title: '操作',
@@ -143,12 +150,11 @@ const Configuration = () => {
           key="action"
           style={{ padding: 0 }}
           popConfirm={{
-            title: intl.formatMessage({
-              id: `pages.data.option.${
-                record.state?.value !== 'disabled' ? 'disabled' : 'disabled'
-              }.tips`,
-              defaultMessage: `确认${record.state?.value !== 'disabled' ? '禁用' : '启用'}?`,
-            }),
+            title: `${
+              record.state?.value !== 'disabled'
+                ? '禁用告警不会影响关联的场景状态,确定要禁用吗'
+                : '确认启用'
+            }?`,
             onConfirm: async () => {
               if (record.state?.value === 'disabled') {
                 await service._enable(record.id);
@@ -174,7 +180,7 @@ const Configuration = () => {
           }}
           type="link"
         >
-          {record.state?.value === 'disabled' ? <CloseCircleOutlined /> : <PlayCircleOutlined />}
+          {record.state?.value === 'disabled' ? <PlayCircleOutlined /> : <CloseCircleOutlined />}
         </PermissionButton>,
         <PermissionButton
           type="link"
@@ -274,12 +280,11 @@ const Configuration = () => {
                 isPermission={permission.action}
                 style={{ padding: 0 }}
                 popConfirm={{
-                  title: intl.formatMessage({
-                    id: `pages.data.option.${
-                      record.state?.value !== 'disabled' ? 'disabled' : 'enabled'
-                    }.tips`,
-                    defaultMessage: `确认${record.state?.value !== 'disabled' ? '禁用' : '启用'}?`,
-                  }),
+                  title: `${
+                    record.state?.value !== 'disabled'
+                      ? '禁用告警不会影响关联的场景状态,确定要禁用吗'
+                      : '确认启用'
+                  }?`,
                   onConfirm: async () => {
                     if (record.state?.value === 'disabled') {
                       await service._enable(record.id);