Преглед изворни кода

fix(bug): fix sc bug

fix: 3.28修改bug
Lind пре 3 година
родитељ
комит
44ac5a382f

+ 21 - 23
src/pages/device/Instance/Detail/Running/Event/index.tsx

@@ -1,16 +1,14 @@
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import ProTable from '@jetlinks/pro-table';
-import { InstanceModel, service } from '@/pages/device/Instance';
+import { service } from '@/pages/device/Instance';
 import { useParams } from 'umi';
 import type { EventMetadata } from '@/pages/device/Product/typings';
 import SearchComponent from '@/components/SearchComponent';
 import moment from 'moment';
 import { Form, Modal } from 'antd';
 import { SearchOutlined } from '@ant-design/icons';
-import { useEffect, useRef, useState } from 'react';
+import { useRef, useState } from 'react';
 import MonacoEditor from 'react-monaco-editor';
-import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
-import { map } from 'rxjs/operators';
 
 interface Props {
   data: Partial<EventMetadata>;
@@ -21,8 +19,8 @@ const EventLog = (props: Props) => {
   const { data } = props;
   const actionRef = useRef<ActionType>();
   const [searchParams, setSearchParams] = useState<any>({ pageSize: 10 });
-  const device = InstanceModel.detail;
-  const [subscribeTopic] = useSendWebsocketMessage();
+  // const device = InstanceModel.detail;
+  // const [subscribeTopic] = useSendWebsocketMessage();
 
   const columns: ProColumns<MetadataLogData>[] = [
     {
@@ -70,24 +68,24 @@ const EventLog = (props: Props) => {
   /**
    * 订阅事件数据
    */
-  const subscribeEvent = () => {
-    const id = `instance-info-event-${device.id}-${device.productId}`;
-    const topic = `/dashboard/device/${device.productId}/events/realTime`;
-    subscribeTopic!(id, topic, {
-      deviceId: device.id,
-    })
-      ?.pipe(map((res) => res.payload))
-      .subscribe((payload: any) => {
-        const { value } = payload;
-        if (value) {
-          actionRef.current?.reload?.();
-        }
-      });
-  };
+  // const subscribeEvent = () => {
+  //   const id = `instance-info-event-${device.id}-${device.productId}`;
+  //   const topic = `/dashboard/device/${device.productId}/events/realTime`;
+  //   subscribeTopic!(id, topic, {
+  //     deviceId: device.id,
+  //   })
+  //     ?.pipe(map((res) => res.payload))
+  //     .subscribe((payload: any) => {
+  //       const { value } = payload;
+  //       if (value) {
+  //         actionRef.current?.reload?.();
+  //       }
+  //     });
+  // };
 
-  useEffect(() => {
-    subscribeEvent();
-  }, []);
+  // useEffect(() => {
+  //   subscribeEvent();
+  // }, []);
 
   const createColumn = (): ProColumns[] =>
     data.valueType?.type === 'object'

+ 6 - 2
src/pages/device/Instance/Detail/Running/Property/PropertyCard.tsx

@@ -7,6 +7,7 @@ import { service } from '@/pages/device/Instance';
 import { useParams } from 'umi';
 import PropertyLog from '@/pages/device/Instance/Detail/MetadataLog/Property';
 import EditProperty from '@/pages/device/Instance/Detail/Running/Property/EditProperty';
+import moment from 'moment';
 
 interface Props {
   data: Partial<PropertyMetadata>;
@@ -67,8 +68,11 @@ const Property = (props: Props) => {
       colSpan={{ xs: 12, sm: 8, md: 6, lg: 6, xl: 6 }}
     >
       <Spin spinning={loading}>
-        <div style={{ height: 60, fontWeight: 600, fontSize: '30px' }}>
-          {value?.formatValue || ''}
+        <div>
+          <div style={{ fontWeight: 600, fontSize: '30px' }}>{value?.formatValue || '--'}</div>
+          <div style={{ marginTop: 10 }}>
+            {value?.timestamp ? moment(value?.timestamp).format('YYYY-MM-DD HH:mm:ss') : '--'}
+          </div>
         </div>
       </Spin>
       <EditProperty

+ 1 - 1
src/pages/device/Instance/Detail/index.tsx

@@ -140,7 +140,7 @@ const InstanceDetail = observer(() => {
       history.goBack();
     } else {
       setTab('detail');
-      getDetail(InstanceModel.current?.id || params.id);
+      getDetail(params?.id || InstanceModel.current?.id || '');
     }
     return () => {
       MetadataAction.clean();

+ 25 - 0
src/pages/device/Product/Detail/Access/index.tsx

@@ -60,6 +60,18 @@ const Access = () => {
           {text}
         </Tooltip>
       ),
+      onCell: (record: any, index: number) => {
+        const list = (config?.routes || []).sort((a: any, b: any) => a - b) || [];
+        const arr = list.filter((res: any) => {
+          // 这里gpsNumber是我需要判断的字段名(相同就合并)
+          return res?.group == record?.group;
+        });
+        if (index == 0 || list[index - 1]?.group != record?.group) {
+          return { rowSpan: arr.length };
+        } else {
+          return { rowSpan: 0 };
+        }
+      },
     },
     {
       title: 'topic',
@@ -111,6 +123,18 @@ const Access = () => {
           {text}
         </Tooltip>
       ),
+      onCell: (record: any, index: number) => {
+        const list = (config?.routes || []).sort((a: any, b: any) => a - b) || [];
+        const arr = list.filter((res: any) => {
+          // 这里gpsNumber是我需要判断的字段名(相同就合并)
+          return res?.group == record?.group;
+        });
+        if (index == 0 || list[index - 1]?.group != record?.group) {
+          return { rowSpan: arr.length };
+        } else {
+          return { rowSpan: 0 };
+        }
+      },
     },
     {
       title: '地址',
@@ -242,6 +266,7 @@ const Access = () => {
             <div>
               <Table
                 dataSource={config?.routes || []}
+                bordered
                 columns={config.id === 'MQTT' ? columnsMQTT : columnsHTTP}
                 pagination={false}
                 scroll={{ y: 240 }}

+ 25 - 0
src/pages/link/AccessConfig/Detail/Access/index.tsx

@@ -166,6 +166,18 @@ const Access = (props: Props) => {
           {text}
         </Tooltip>
       ),
+      onCell: (record: any, index: number) => {
+        const list = (config?.routes || []).sort((a: any, b: any) => a - b) || [];
+        const arr = list.filter((res: any) => {
+          // 这里gpsNumber是我需要判断的字段名(相同就合并)
+          return res?.group == record?.group;
+        });
+        if (index == 0 || list[index - 1]?.group != record?.group) {
+          return { rowSpan: arr.length };
+        } else {
+          return { rowSpan: 0 };
+        }
+      },
     },
     {
       title: 'topic',
@@ -217,6 +229,18 @@ const Access = (props: Props) => {
           {text}
         </Tooltip>
       ),
+      onCell: (record: any, index: number) => {
+        const list = (config?.routes || []).sort((a: any, b: any) => a - b) || [];
+        const arr = list.filter((res: any) => {
+          // 这里gpsNumber是我需要判断的字段名(相同就合并)
+          return res?.group == record?.group;
+        });
+        if (index == 0 || list[index - 1]?.group != record?.group) {
+          return { rowSpan: arr.length };
+        } else {
+          return { rowSpan: 0 };
+        }
+      },
     },
     {
       title: '分组',
@@ -556,6 +580,7 @@ const Access = (props: Props) => {
               {config?.routes && config?.routes?.length > 0 && (
                 <div>
                   <Table
+                    bordered
                     dataSource={config?.routes || []}
                     columns={config.id === 'MQTT' ? columnsMQTT : columnsHTTP}
                     pagination={false}

+ 4 - 20
src/pages/link/Protocol/index.tsx

@@ -267,6 +267,7 @@ const Protocol = () => {
                   dependencies: ['..type'],
                   fulfill: {
                     state: {
+                      value: '',
                       visible: '{{["jar","local"].includes($deps[0])}}',
                       componentType: '{{$deps[0]==="jar"?"FileUpload":"Input"}}',
                       componentProps: '{{$deps[0]==="jar"?{type:"file", accept: ".jar, .zip"}:{}}}',
@@ -274,26 +275,6 @@ const Protocol = () => {
                   },
                 },
               },
-              // provider: {
-              //   title: '类名',
-              //   'x-component': 'Input',
-              //   'x-decorator': 'FormItem',
-              //   'x-visible': false,
-              //   'x-validator': [
-              //     {
-              //       required: true,
-              //       message: '请选择类名',
-              //     },
-              //   ],
-              //   'x-reactions': {
-              //     dependencies: ['..type'],
-              //     fulfill: {
-              //       state: {
-              //         visible: '{{["jar","local"].includes($deps[0])}}',
-              //       },
-              //     },
-              //   },
-              // },
             },
           },
           description: {
@@ -341,6 +322,9 @@ const Protocol = () => {
             form.setFieldState('id', (state) => {
               state.disabled = CurdModel.model === 'edit';
             });
+            form.setFieldState('type', (state) => {
+              state.disabled = CurdModel.model === 'edit';
+            });
           });
         }}
         footer={

+ 7 - 4
src/pages/system/Permission/Save/index.tsx

@@ -225,8 +225,13 @@ const Save = (props: Props) => {
 
   const save = async () => {
     const value = await form.submit<UserItem>();
-    const response = await service.update(value);
-    if (response.status === 200) {
+    let response = undefined;
+    if (props.model === 'add') {
+      response = await service.save(value);
+    } else {
+      response = await service.update(value);
+    }
+    if (response && response.status === 200) {
       message.success(
         intl.formatMessage({
           id: 'pages.data.option.success',
@@ -234,8 +239,6 @@ const Save = (props: Props) => {
         }),
       );
       props.close();
-    } else {
-      message.error('操作失败!');
     }
   };