xieyonghong 3 лет назад
Родитель
Сommit
c10581cf8d

+ 2 - 2
config/proxy.ts

@@ -9,8 +9,8 @@
 export default {
   dev: {
     '/api': {
-      // target: 'http://192.168.32.28:8844/',
-      // ws: 'ws://192.168.32.28:8844/',
+      target: 'http://192.168.32.28:8844/',
+      ws: 'ws://192.168.32.28:8844/',
       // 开发环境
       target: 'http://120.79.18.123:8844/',
       ws: 'ws://120.79.18.123:8844/',

BIN
public/images/diagnose copy/back.png


BIN
public/images/diagnose copy/message-error.png


BIN
public/images/diagnose copy/status-error.png


BIN
public/images/diagnose copy/status-success-active.png


BIN
public/images/diagnose copy/status-success.png


BIN
public/images/diagnose copy/status/error.png


BIN
public/images/diagnose copy/status/loading.png


BIN
public/images/diagnose copy/status/success.png


BIN
public/images/diagnose copy/status/warning.png


BIN
public/images/diagnose copy/waiting.png


+ 4 - 1
src/components/FSelectDevices/index.tsx

@@ -10,6 +10,7 @@ import Service from '@/pages/device/Instance/service';
 import SearchComponent from '../SearchComponent';
 import { observer } from '@formily/react';
 import { model } from '@formily/reactive';
+import moment from 'moment';
 
 interface Props {
   value?: Partial<DeviceInstance>[];
@@ -59,9 +60,11 @@ const FSelectDevices = observer((props: Props) => {
         id: 'pages.device.instance.registrationTime',
         defaultMessage: '注册时间',
       }),
-      dataIndex: 'registerTime',
+      dataIndex: 'registryTime',
       width: '200px',
       valueType: 'dateTime',
+      render: (text: any, record: any) =>
+        record?.registerTime ? moment(record?.registerTime).format('YYYY-MM-DD HH:mm:ss') : '',
     },
     {
       title: '状态',

+ 2 - 2
src/components/FUpload/index.tsx

@@ -20,10 +20,10 @@ const FUpload = connect((props: Props) => {
   const handleChange = async (info: UploadChangeParam) => {
     if (info.file.status === 'done') {
       const result = info.file.response?.result;
-      const api = await service.querySystemApi();
+      const api = await service.querySystemApi(['basePath']);
       const f = {
         ...result,
-        url: `${api?.result?.basePath}file/${result?.id}?accessKey=${result?.others?.accessKey}`,
+        url: `${api?.result[0]?.properties?.basePath}file/${result?.id}?accessKey=${result?.others?.accessKey}`,
       };
       setUrl(f.url);
       props.onChange(f);

+ 31 - 20
src/pages/device/Firmware/Task/Detail/index.tsx

@@ -29,12 +29,14 @@ const state = model<{
   finish: number;
   error: number;
   canceled: number;
+  info: any;
 }>({
   waiting: 0,
   loading: 0,
   finish: 0,
   error: 0,
   canceled: 0,
+  info: {},
 });
 
 const Detail = observer(() => {
@@ -173,6 +175,11 @@ const Detail = observer(() => {
   };
 
   useEffect(() => {
+    service.taskById(params.id).then((resp) => {
+      if (resp.status === 200) {
+        state.info = resp.result;
+      }
+    });
     handleSearch();
   }, [params.id]);
 
@@ -248,7 +255,7 @@ const Detail = observer(() => {
           status: 'success',
         },
         canceled: {
-          text: '已取消',
+          text: '已停止',
           status: 'canceled',
         },
       },
@@ -281,24 +288,28 @@ const Detail = observer(() => {
                   <SearchOutlined />
                 </Tooltip>
               </a>,
-              <Popconfirm
-                key="refresh"
-                onConfirm={async () => {
-                  const resp = await service.startOneTask([record.id]);
-                  if (resp.status === 200) {
-                    message.success('操作成功!');
-                    handleSearch();
-                    actionRef.current?.reload?.();
-                  }
-                }}
-                title={'确认重试'}
-              >
-                <a>
-                  <Tooltip title={'重试'} key={'refresh'}>
-                    <RedoOutlined />
-                  </Tooltip>
-                </a>
-              </Popconfirm>,
+              <>
+                {state.info?.mode?.value === 'push' ? (
+                  <Popconfirm
+                    key="refresh"
+                    onConfirm={async () => {
+                      const resp = await service.startOneTask([record.id]);
+                      if (resp.status === 200) {
+                        message.success('操作成功!');
+                        handleSearch();
+                        actionRef.current?.reload?.();
+                      }
+                    }}
+                    title={'确认重试'}
+                  >
+                    <a>
+                      <Tooltip title={'重试'} key={'refresh'}>
+                        <RedoOutlined />
+                      </Tooltip>
+                    </a>
+                  </Popconfirm>
+                ) : null}
+              </>,
             ]
           : [],
     },
@@ -317,7 +328,7 @@ const Detail = observer(() => {
                     {item.name}
                   </div>
                   <div className={styles.firmwareDetailCardRight}>
-                    {item.key === 'error' && (
+                    {item.key === 'error' && state.info?.mode?.value === 'push' && (
                       <Popconfirm
                         title="确认批量重试"
                         onConfirm={async () => {

+ 16 - 12
src/pages/device/Firmware/Task/index.tsx

@@ -26,13 +26,10 @@ import { service } from '@/pages/device/Firmware';
 
 const UpgradeBtn = (props: { data: any; actions: any }) => {
   const { data, actions } = props;
-  if (data.progress === 100) {
-    return null;
-  }
-  return (
-    <a>
-      <Tooltip title={data.waiting ? '停止' : '继续升级'}>
-        {data.waiting ? (
+  if (data.waiting && data?.state?.value === 'processing') {
+    return (
+      <a>
+        <Tooltip title={'停止'}>
           <StopOutlined
             onClick={async () => {
               const resp = await service.stopTask(data.id);
@@ -42,7 +39,13 @@ const UpgradeBtn = (props: { data: any; actions: any }) => {
               }
             }}
           />
-        ) : (
+        </Tooltip>
+      </a>
+    );
+  } else if (data?.state?.value === 'canceled') {
+    return (
+      <a>
+        <Tooltip title={'继续升级'}>
           <ControlOutlined
             onClick={async () => {
               const resp = await service.startTask(data.id, ['canceled']);
@@ -52,10 +55,11 @@ const UpgradeBtn = (props: { data: any; actions: any }) => {
               }
             }}
           />
-        )}
-      </Tooltip>
-    </a>
-  );
+        </Tooltip>
+      </a>
+    );
+  }
+  return null;
 };
 
 export const state = model<{

+ 9 - 3
src/pages/device/Firmware/service.ts

@@ -4,9 +4,10 @@ import SystemConst from '@/utils/const';
 import type { FirmwareItem } from '@/pages/device/Firmware/typings';
 
 class Service extends BaseService<FirmwareItem> {
-  querySystemApi = () =>
-    request(`/${SystemConst.API_BASE}/system/apis`, {
-      method: 'GET',
+  querySystemApi = (data?: any) =>
+    request(`/${SystemConst.API_BASE}/system/config/scopes`, {
+      method: 'POST',
+      data,
     });
 
   task = (params: Record<string, unknown>) =>
@@ -15,6 +16,11 @@ class Service extends BaseService<FirmwareItem> {
       data: params,
     });
 
+  taskById = (id: string) =>
+    request(`/${SystemConst.API_BASE}/firmware/upgrade/task/${id}`, {
+      method: 'GET',
+    });
+
   saveTask = (data: Record<string, unknown>) =>
     request(`/${SystemConst.API_BASE}/firmware/upgrade/task`, {
       method: 'POST',

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

@@ -285,7 +285,7 @@ const Status = observer((props: Props) => {
                     key: 'gateway',
                     name: '设备接入网关',
                     desc: desc,
-                    status: 'error',
+                    status: 'warning',
                     text: '可能存在异常',
                     info: (
                       <div>
@@ -416,7 +416,7 @@ const Status = observer((props: Props) => {
                 key: 'gateway',
                 name: '设备接入网关',
                 desc: desc,
-                status: 'error',
+                status: 'warning',
                 text: '可能存在异常',
                 info: (
                   <div>
@@ -965,7 +965,7 @@ const Status = observer((props: Props) => {
                   key: `product-auth${i}`,
                   name: `产品-${item?.name}`,
                   desc: '诊断产品MQTT认证配置是否正确,错误的配置将导致连接失败',
-                  status: 'error',
+                  status: 'warning',
                   text: '可能存在异常',
                   info: (
                     <div>
@@ -1129,7 +1129,7 @@ const Status = observer((props: Props) => {
                   key: `device-auth${i}`,
                   name: `设备-${item?.name}`,
                   desc: '诊断设备MQTT认证配置是否正确,错误的配置将导致连接失败',
-                  status: 'error',
+                  status: 'warning',
                   text: '可能存在异常',
                   info: (
                     <div>
@@ -1409,7 +1409,7 @@ const Status = observer((props: Props) => {
             key: `onenet`,
             name: `设备-OneNet配置`,
             desc: '诊断设备OneNet是否已配置,未配置将导致连接失败',
-            status: 'error',
+            status: 'warning',
             text: '可能存在异常',
             info: (
               <div>
@@ -1524,7 +1524,7 @@ const Status = observer((props: Props) => {
             key: `ctwing`,
             name: `设备-CTWing配置`,
             desc: '诊断设备CTWing是否已配置,未配置将导致连接失败',
-            status: 'error',
+            status: 'warning',
             text: '可能存在异常',
             info: (
               <div>

+ 1 - 1
src/pages/device/Instance/Detail/Diagnose/Status/model.ts

@@ -13,7 +13,7 @@ export const TextColorMap = new Map();
 TextColorMap.set('loading', 'black');
 TextColorMap.set('error', 'red');
 TextColorMap.set('success', 'green');
-TextColorMap.set('warning', 'red');
+TextColorMap.set('warning', '#FAB247');
 
 export type ListProps = {
   key: string;

+ 1 - 1
src/pages/device/components/Metadata/metadata.ts

@@ -41,7 +41,7 @@ export const updateMetadata = (
     console.warn('未触发物模型修改');
   }
   // @ts-ignore
-  metadata[type] = config;
+  metadata[type] = config.sort((a, b) => b?.sortsIndex - a?.sortsIndex);
   data.metadata = JSON.stringify(metadata);
   return data;
 };

+ 1 - 1
src/pages/home/init/index.tsx

@@ -53,7 +53,7 @@ const Init = (props: Props) => {
           type="primary"
           onClick={() => {
             service
-              .setView({
+              .setViews({
                 name: 'view',
                 content: value,
               })

+ 14 - 0
src/pages/init-home/components/basis.tsx

@@ -32,6 +32,12 @@ const Basis = forwardRef((props: Props, ref) => {
               api: formData.apikey,
             },
           },
+          {
+            scope: 'basePath',
+            properties: {
+              basePath: formData.basePath,
+            },
+          },
         ];
         const res = await service.save(item);
         if (res.status === 200) {
@@ -100,6 +106,14 @@ const Basis = forwardRef((props: Props, ref) => {
           <Form.Item label="高德API Key" name="apikey" tooltip="配置后平台可调用高德地图GIS服务">
             <Input placeholder={'请输入高德API Key'} />
           </Form.Item>
+          <Form.Item
+            label="base-path"
+            name="basePath"
+            tooltip="界面访问后台服务器的URL(统一资源定位符)"
+            required
+          >
+            <Input />
+          </Form.Item>
           <Row gutter={[24, 24]}>
             <Col>
               <Form.Item

+ 13 - 11
src/pages/link/Channel/Modbus/index.tsx

@@ -338,17 +338,19 @@ const NewModbus = () => {
   }, []);
 
   useEffect(() => {
-    const id = `collector-data-modbus`;
-    const topic = `/collector/MODBUS_TCP/${activeKey}/data`;
-    wsRef.current = subscribeTopic?.(id, topic, {
-      pointId: pointList.map((item: any) => item.id),
-    })
-      ?.pipe(map((res: any) => res.payload))
-      .subscribe((payload: any) => {
-        const { pointId, hex } = payload;
-        current[pointId] = hex;
-        setCurrentData({ ...current });
-      });
+    if (pointList && activeKey) {
+      const id = `collector-data-modbus`;
+      const topic = `/collector/MODBUS_TCP/${activeKey}/data`;
+      wsRef.current = subscribeTopic?.(id, topic, {
+        pointId: pointList.map((item: any) => item.id),
+      })
+        ?.pipe(map((res: any) => res.payload))
+        .subscribe((payload: any) => {
+          const { pointId, hex } = payload;
+          current[pointId] = hex;
+          setCurrentData({ ...current });
+        });
+    }
     return () => wsRef.current && wsRef.current?.unsubscribe();
   }, [pointList]);
 

+ 26 - 52
src/pages/link/Type/Detail/index.tsx

@@ -14,8 +14,9 @@ import {
   Select,
 } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
-import { useEffect, useMemo, useRef } from 'react';
-import { Field, FieldDataSource, onFormInit } from '@formily/core';
+import { useMemo, useRef } from 'react';
+import type { Field, FieldDataSource } from '@formily/core';
+import { onFormInit } from '@formily/core';
 import { createForm, onFieldReact, onFieldValueChange } from '@formily/core';
 import { Card, Col, Row } from 'antd';
 import styles from './index.less';
@@ -58,16 +59,6 @@ const Save = observer(() => {
 
   const configRef = useRef([]);
 
-  useEffect(() => {
-    service.getResourcesCurrent().then((resp) => {
-      if (resp.status === 200) {
-        // setConfig(resp.result);
-        // console.log('test', resp);
-        configRef.current = resp.result;
-      }
-    });
-  }, []);
-
   const useAsyncData = (services: (arg0: Field) => Promise<FieldDataSource>) => (field: Field) => {
     field.loading = true;
     services(field).then(
@@ -122,6 +113,10 @@ const Save = observer(() => {
         // initialValues: {},
         effects() {
           onFormInit(async (form1) => {
+            const response = await service.getResourcesCurrent();
+            if (response.status === 200) {
+              configRef.current = response.result;
+            }
             if (param?.id && param.id !== ':id') {
               const resp = await service.detail(param.id);
               const data = resp?.result || {};
@@ -156,7 +151,7 @@ const Save = observer(() => {
             f.setFieldState('grid.configuration.panel1.layout2.host', (state) => {
               state.dataSource = _host.map((item) => ({ label: item.host, value: item.host }));
             });
-            f.setFieldState('cluster.config.*.host', (state) => {
+            f.setFieldState('grid.cluster.cluster.*.layout2.host', (state) => {
               state.dataSource = _host.map((item) => ({ label: item.host, value: item.host }));
             });
           });
@@ -173,26 +168,25 @@ const Save = observer(() => {
           });
           onFieldValueChange('shareCluster', (field, f5) => {
             const value = (field as Field).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 = [{}];
-                });
-                f5.setFieldState('grid.cluster.cluster.*.layout2.host', (state) => {
-                  state.value = undefined;
-                  state.disabled = false;
-                });
-              }
+            if (value) {
+              // 共享配置
+              f5.setFieldState('grid.configuration.panel1.layout2.host', (state) => {
+                state.value = '0.0.0.0';
+                state.disabled = true;
+              });
+            }
+            if (f5.modified && !value) {
+              // 独立配置
+              f5.setFieldState('grid.cluster.cluster', (state) => {
+                state.value = [{}];
+              });
+              f5.setFieldState('grid.cluster.cluster.*.layout2.host', (state) => {
+                state.value = undefined;
+                state.disabled = false;
+              });
             }
           });
-          onFieldValueChange('grid.cluster.cluster.*.layout2.serverId', async (field, f3) => {
+          onFieldReact('grid.cluster.cluster.*.layout2.serverId', async (field, f3) => {
             const value = (field as Field).value;
             const type = (field.query('type').take() as Field).value;
             const response = await getResourceById(value, type);
@@ -200,7 +194,7 @@ const Save = observer(() => {
               state.dataSource = response.map((item) => ({ label: item.host, value: item.host }));
             });
           });
-          onFieldValueChange('grid.cluster.cluster.*.layout2.host', async (field, f4) => {
+          onFieldReact('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;
@@ -215,24 +209,6 @@ const Save = observer(() => {
     [],
   );
 
-  // useEffect(() => {
-  //   console.log(Store.get('current-network-data'));
-  //   // const subscription = Store.subscribe('current-network-data', (data) => {
-  //   //   if (!data) return;
-  //   //   // form.readPretty = true;
-  //   //   const _data = _.cloneDeep(data);
-  //   //   // 处理一下集群模式数据
-  //   //   if (!_data.shareCluster) {
-  //   //     _data.cluster = _data.cluster?.map((item: any) => ({ ...item.configuration }));
-  //   //   }
-  //   //   form.setValues({ ..._data });
-  //   // });
-  //   // return () => {
-  //   //   subscription.unsubscribe();
-  //   //   // Store.set('current-network-data', undefined);
-  //   // };
-  // }, []);
-
   const SchemaField = createSchemaField({
     components: {
       FormItem,
@@ -299,8 +275,6 @@ const Save = observer(() => {
         'x-component-props': {
           placeholder: '请选择本地地址',
         },
-        default: '0.0.0.0',
-        'x-disabled': true,
         'x-decorator-props': {
           gridSpan: 1,
           labelAlign: 'left',

+ 2 - 2
src/pages/rule-engine/Alarm/Config/index.tsx

@@ -320,8 +320,8 @@ const Config = () => {
         <div style={{ marginLeft: 20 }} className={styles.doc}>
           <h1>功能说明</h1>
           <div>1、告警级别用于描述告警的严重程度,请根据业务管理方式进行自定义。</div>
-          <div>2、告警级别将会在告警配置中被引用</div>
-          <div>3、最多可配置5个级别</div>
+          <div>2、告警级别将会在告警配置中被引用</div>
+          <div>3、最多可配置5个级别</div>
         </div>
       </Col>
     </Row>

+ 19 - 2
src/pages/system/Basis/index.tsx

@@ -22,10 +22,12 @@ const Basis = () => {
     if (res.status === 200) {
       const basis = res.result?.filter((item: any) => item.scope === 'basis');
       const api = res?.result.filter((item: any) => item.scope === 'api');
+      const basePath = res?.result.filter((item: any) => item.scope === 'basePath');
       localStorage.setItem(SystemConst.AMAP_KEY, api[0].properties.api);
       form.setFieldsValue({
         ...basis[0].properties,
         apikey: api[0].properties.api,
+        basePath: basePath[0].properties.basePath,
       });
       setInitialState({
         ...initialState,
@@ -45,6 +47,7 @@ const Basis = () => {
           properties: {
             ...formData,
             apikey: '',
+            basePath: '',
           },
         },
         {
@@ -53,17 +56,23 @@ const Basis = () => {
             api: formData.apikey,
           },
         },
+        {
+          scope: 'basePath',
+          properties: {
+            basePath: formData.basePath,
+          },
+        },
       ];
       const res = await service.save(item);
       if (res.status === 200) {
         onlyMessage('保存成功');
-        detail(['basis', 'api']);
+        detail(['basis', 'api', 'basePath']);
       }
     }
   };
 
   useEffect(() => {
-    detail(['basis', 'api']);
+    detail(['basis', 'api', 'basePath']);
   }, []);
   return (
     <PageContainer>
@@ -99,6 +108,14 @@ const Basis = () => {
               >
                 <Input />
               </Form.Item>
+              <Form.Item
+                label="base-path"
+                name="basePath"
+                tooltip="界面访问后台服务器的URL(统一资源定位符)"
+                required
+              >
+                <Input />
+              </Form.Item>
               <Row gutter={[24, 24]}>
                 <Col>
                   <Form.Item

+ 8 - 0
src/pages/system/Relationship/index.tsx

@@ -35,6 +35,14 @@ const Relationship = () => {
       dataIndex: 'objectTypeName',
       title: '关联方',
       ellipsis: true,
+      valueType: 'select',
+      request: async () => {
+        const res = await service.getTypes();
+        if (res.status === 200) {
+          return res.result.map((item: any) => ({ label: item.name, value: item.name }));
+        }
+        return [];
+      },
     },
     {
       dataIndex: 'targetTypeName',