Forráskód Böngészése

fix: 修改网络组件

sun-chaochao 3 éve
szülő
commit
89ea081568

+ 11 - 5
src/components/BindParentDevice/index.tsx

@@ -4,7 +4,7 @@ import SearchComponent from '@/components/SearchComponent';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import ProTable from '@jetlinks/pro-table';
 import { useRef, useState } from 'react';
-import { service, statusMap } from '@/pages/device/Instance';
+import { service } from '@/pages/device/Instance';
 import { useIntl } from 'umi';
 import moment from 'moment';
 
@@ -14,6 +14,11 @@ interface Props {
   onOk: (parentId: string) => void;
 }
 
+const statusMap = new Map();
+statusMap.set('online', 'success');
+statusMap.set('offline', 'error');
+statusMap.set('notActive', 'warning');
+
 const BindParentDevice = (props: Props) => {
   const intl = useIntl();
 
@@ -42,6 +47,7 @@ const BindParentDevice = (props: Props) => {
       dataIndex: 'registryTime',
       ellipsis: true,
       width: '200px',
+      valueType: 'dateTime',
       render: (text: any) => (!!text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '/'),
       sorter: true,
     },
@@ -59,21 +65,21 @@ const BindParentDevice = (props: Props) => {
             id: 'pages.device.instance.status.notActive',
             defaultMessage: '未启用',
           }),
-          value: 'notActive',
+          status: 'notActive',
         },
         offline: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.offLine',
             defaultMessage: '离线',
           }),
-          value: 'offline',
+          status: 'offline',
         },
         online: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.onLine',
             defaultMessage: '在线',
           }),
-          value: 'online',
+          status: 'online',
         },
       },
     },
@@ -122,7 +128,7 @@ const BindParentDevice = (props: Props) => {
             submitBtn();
           }}
         >
-          确
+          确
         </Button>,
       ]}
     >

+ 17 - 8
src/pages/device/Instance/Detail/ChildDevice/BindChildDevice/index.tsx

@@ -4,18 +4,21 @@ import SearchComponent from '@/components/SearchComponent';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import ProTable from '@jetlinks/pro-table';
 import { useRef, useState } from 'react';
-import { InstanceModel, service, statusMap } from '@/pages/device/Instance';
+import { InstanceModel, service } from '@/pages/device/Instance';
 import { useIntl } from 'umi';
 import moment from 'moment';
 
 interface Props {
-  visible: boolean;
   data: Partial<DeviceInstance>;
   onCancel: () => void;
 }
 
+const statusMap = new Map();
+statusMap.set('online', 'success');
+statusMap.set('offline', 'error');
+statusMap.set('notActive', 'warning');
+
 const BindChildDevice = (props: Props) => {
-  const { visible } = props;
   const intl = useIntl();
 
   const actionRef = useRef<ActionType>();
@@ -42,8 +45,13 @@ const BindChildDevice = (props: Props) => {
       title: '注册时间',
       dataIndex: 'registryTime',
       ellipsis: true,
+      valueType: 'dateTime',
       width: '200px',
-      render: (text: any) => (!!text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '/'),
+      render: (text: any, record: any) => {
+        return !record?.registryTime
+          ? ''
+          : moment(record?.registryTime).format('YYYY-MM-DD HH:mm:ss');
+      },
       sorter: true,
     },
     {
@@ -60,21 +68,21 @@ const BindChildDevice = (props: Props) => {
             id: 'pages.device.instance.status.notActive',
             defaultMessage: '未启用',
           }),
-          value: 'notActive',
+          status: 'notActive',
         },
         offline: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.offLine',
             defaultMessage: '离线',
           }),
-          value: 'offline',
+          status: 'offline',
         },
         online: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.onLine',
             defaultMessage: '在线',
           }),
-          value: 'online',
+          status: 'online',
         },
       },
     },
@@ -93,7 +101,7 @@ const BindChildDevice = (props: Props) => {
     <Modal
       maskClosable={false}
       title="绑定子设备"
-      visible={visible}
+      visible
       width={1000}
       onOk={() => {
         submitBtn();
@@ -129,6 +137,7 @@ const BindChildDevice = (props: Props) => {
         field={[...columns]}
         target="child-device-bind"
         enableSave={false}
+        model="simple"
         // pattern={'simple'}
         defaultParam={[
           {

+ 24 - 13
src/pages/device/Instance/Detail/ChildDevice/index.tsx

@@ -4,7 +4,7 @@ import type { LogItem } from '@/pages/device/Instance/Detail/Log/typings';
 import { Badge, Button, Card, Popconfirm, Tooltip } from 'antd';
 import { DisconnectOutlined, SearchOutlined } from '@ant-design/icons';
 import { useIntl } from '@@/plugin-locale/localeExports';
-import { InstanceModel, service, statusMap } from '@/pages/device/Instance';
+import { InstanceModel, service } from '@/pages/device/Instance';
 import { useRef, useState } from 'react';
 import SearchComponent from '@/components/SearchComponent';
 import BindChildDevice from './BindChildDevice';
@@ -14,6 +14,11 @@ import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 import { useDomFullHeight } from '@/hooks';
 import { onlyMessage } from '@/utils/util';
 
+const statusMap = new Map();
+statusMap.set('online', 'success');
+statusMap.set('offline', 'error');
+statusMap.set('notActive', 'warning');
+
 const ChildDevice = () => {
   const intl = useIntl();
   const [visible, setVisible] = useState<boolean>(false);
@@ -53,7 +58,12 @@ const ChildDevice = () => {
       title: '注册时间',
       dataIndex: 'registryTime',
       width: '200px',
-      render: (text: any) => (!!text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '/'),
+      valueType: 'dateTime',
+      render: (text: any, record: any) => {
+        return !record?.registryTime
+          ? ''
+          : moment(record?.registryTime).format('YYYY-MM-DD HH:mm:ss');
+      },
       sorter: true,
     },
     {
@@ -68,21 +78,21 @@ const ChildDevice = () => {
             id: 'pages.device.instance.status.notActive',
             defaultMessage: '未启用',
           }),
-          value: 'notActive',
+          status: 'notActive',
         },
         offline: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.offLine',
             defaultMessage: '离线',
           }),
-          value: 'offline',
+          status: 'offline',
         },
         online: {
           text: intl.formatMessage({
             id: 'pages.device.instance.status.onLine',
             defaultMessage: '在线',
           }),
-          value: 'online',
+          status: 'online',
         },
       },
     },
@@ -189,14 +199,15 @@ const ChildDevice = () => {
         }}
         request={(params) => service.query(params)}
       />
-      <BindChildDevice
-        visible={visible}
-        data={{}}
-        onCancel={() => {
-          setVisible(false);
-          actionRef.current?.reload?.();
-        }}
-      />
+      {visible && (
+        <BindChildDevice
+          data={{}}
+          onCancel={() => {
+            setVisible(false);
+            actionRef.current?.reload?.();
+          }}
+        />
+      )}
     </Card>
   );
 };

+ 2 - 0
src/pages/device/Instance/Detail/Diagnose/Status/ManualInspection.tsx

@@ -198,6 +198,8 @@ const ManualInspection = (props: Props) => {
           )}
         </>
       );
+    } else {
+      return null;
     }
   };
 

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

@@ -2102,6 +2102,7 @@ const Status = observer((props: Props) => {
               info: null,
             });
             InstanceModel.detail.parentId = parentId;
+            setBindParentVisible(false);
           }}
         />
       )}

+ 1 - 1
src/pages/device/components/Metadata/Import/index.tsx

@@ -192,7 +192,7 @@ const Import = (props: Props) => {
       obj.events = old?.event || [];
     }
     if (fid.includes('propertyNotModifiable')) {
-      obj.properties = old?.properties || {};
+      obj.properties = old?.properties || [];
     }
     return obj;
   };

+ 19 - 14
src/pages/link/Type/Detail/index.tsx

@@ -135,6 +135,9 @@ const Save = observer(() => {
               f.setFieldState('grid.configuration.panel1.layout2.secure', (state) => {
                 state.value = false;
               });
+              f.setFieldState('shareCluster', (state) => {
+                state.value = true;
+              });
             }
             const _host = filterConfigByType(_.cloneDeep(configRef.current), value);
             f.setFieldState('grid.configuration.panel1.layout2.host', (state) => {
@@ -157,17 +160,19 @@ const Save = observer(() => {
           });
           onFieldValueChange('shareCluster', (field, f5) => {
             const value = (field as Field).value;
-            if (value) {
-              // 共享配置
-              f5.setFieldState('grid.configuration.panel1.layout2.host', (state) => {
-                state.value = '0.0.0.0';
-                state.disabled = true;
-              });
-            } else {
-              // 独立配置
-              f5.setFieldState('grid.cluster.cluster', (state) => {
-                state.value = [{}];
-              });
+            if (f5.modified) {
+              if (value) {
+                // 共享配置
+                f5.setFieldState('grid.configuration.panel1.layout2.host', (state) => {
+                  state.value = '0.0.0.0';
+                  state.disabled = true;
+                });
+              } else {
+                // 独立配置
+                f5.setFieldState('grid.cluster.cluster', (state) => {
+                  state.value = [{}];
+                });
+              }
             }
           });
           onFieldValueChange('grid.cluster.cluster.*.layout2.serverId', async (field, f3) => {
@@ -180,8 +185,8 @@ const Save = observer(() => {
           });
           onFieldValueChange('grid.cluster.cluster.*.layout2.host', async (field, f4) => {
             const host = (field as Field).value;
-            const value = (field.query('.serverId').take() as Field).value;
-            const type = (field.query('type').take() as Field).value;
+            const value = (field.query('.serverId').take() as Field)?.value;
+            const type = (field.query('type').take() as Field)?.value;
             const response = await getResourceById(value, type);
             const _ports = response.find((item) => item.host === host);
             f4.setFieldState(field.query('.port').take(), async (state) => {
@@ -212,7 +217,7 @@ const Save = observer(() => {
       if (!_data.shareCluster) {
         _data.cluster = _data.cluster?.map((item: any) => ({ ...item.configuration }));
       }
-      form.setValues(_data);
+      form.setValues({ ..._data });
     });
     return () => {
       subscription.unsubscribe();

+ 2 - 2
src/pages/notice/Config/BindUser/index.tsx

@@ -22,10 +22,10 @@ const BindUser = (props: Props) => {
 
   const getUsers = async (id: string) => {
     const resp = await service.syncUser.noBindUser({
-      pagign: false,
+      paging: false,
       terms: [
         {
-          column: `id$user-third${state.current?.type}_${state.current?.provider}$not`,
+          column: `id$user-third$${state.current?.type}_${state.current?.provider}$not`,
           value: id,
         },
       ],