Parcourir la source

fix: bug

feat: 物模型映射
hear il y a 3 ans
Parent
commit
5bb3a2ebba

+ 4 - 4
config/proxy.ts

@@ -9,14 +9,14 @@
 export default {
 export default {
   dev: {
   dev: {
     '/api': {
     '/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/',
       // target: 'http://120.79.18.123:8844/',
       // ws: 'ws://120.79.18.123:8844/',
       // ws: 'ws://120.79.18.123:8844/',
       // 测试环境
       // 测试环境
-      // target: 'http://120.77.179.54:8844/',
-      // ws: 'ws://120.77.179.54:8844/',
+      target: 'http://120.77.179.54:8844/',
+      ws: 'ws://120.77.179.54:8844/',
       // target: 'http://192.168.32.65:8850/',
       // target: 'http://192.168.32.65:8850/',
       // ws: 'ws://192.168.32.65:8850/',
       // ws: 'ws://192.168.32.65:8850/',
       //v2环境
       //v2环境

+ 1 - 1
src/pages/account/NotificationRecord/detail/index.tsx

@@ -55,7 +55,7 @@ const Detail = (props: Props) => {
           {data?.description || ''}
           {data?.description || ''}
         </Descriptions.Item>
         </Descriptions.Item>
         <Descriptions.Item label="告警流水" span={2}>
         <Descriptions.Item label="告警流水" span={2}>
-          {data?.alarmInfo || ''}
+          {JSON.stringify(props.data?.detailJson || '') || ''}
         </Descriptions.Item>
         </Descriptions.Item>
       </Descriptions>
       </Descriptions>
     </Modal>
     </Modal>

+ 1 - 0
src/pages/account/NotificationRecord/typings.d.ts

@@ -9,4 +9,5 @@ type NotifitionRecord = {
   subscriberType: string;
   subscriberType: string;
   topicName: string;
   topicName: string;
   dataId: string;
   dataId: string;
+  detailJson: string;
 };
 };

+ 14 - 0
src/pages/device/Instance/Detail/EdgeMap/index.tsx

@@ -0,0 +1,14 @@
+import useDomFullHeight from '@/hooks/document/useDomFullHeight';
+import { Card } from 'antd';
+import MapTable from './mapTable';
+
+const EdgeMap = () => {
+  const { minHeight } = useDomFullHeight('.metadataMap');
+  return (
+    <Card className="metadataMap" style={{ minHeight }}>
+      <MapTable metaData={[]} />
+    </Card>
+  );
+};
+
+export default EdgeMap;

+ 6 - 0
src/pages/device/Instance/Detail/EdgeMap/mapTable/index.less

@@ -0,0 +1,6 @@
+.top-button {
+  display: flex;
+  flex-direction: row;
+  justify-content: flex-end;
+  margin-bottom: 10px;
+}

+ 229 - 0
src/pages/device/Instance/Detail/EdgeMap/mapTable/index.tsx

@@ -0,0 +1,229 @@
+import PermissionButton from '@/components/PermissionButton';
+import { DisconnectOutlined, QuestionCircleOutlined } from '@ant-design/icons';
+import { FormItem, ArrayTable, Editable, Select, NumberPicker } from '@formily/antd';
+import { createForm } from '@formily/core';
+import { FormProvider, createSchemaField } from '@formily/react';
+import { Badge, Button, Tooltip } from 'antd';
+import './index.less';
+
+interface Props {
+  metaData: Record<string, string>[];
+}
+
+const MapTable = (props: Props) => {
+  const { metaData } = props;
+
+  const Render = (propsName: any) => {
+    const text = metaData.find((item: any) => item.metadataId === propsName.value);
+    return (
+      <>
+        {text?.metadataName}({text?.metadataId})
+      </>
+    );
+  };
+  const StatusRender = (propsRender: any) => {
+    if (propsRender.value) {
+      return <Badge status="success" text={'已绑定'} />;
+    } else {
+      return <Badge status="error" text={'未绑定'} />;
+    }
+  };
+  const ActionButton = () => {
+    const record = ArrayTable.useRecord?.();
+    const index = ArrayTable.useIndex?.();
+    return (
+      <PermissionButton
+        isPermission={true}
+        style={{ padding: 0 }}
+        disabled={!record(index)?.id}
+        tooltip={{
+          title: '解绑',
+        }}
+        popConfirm={{
+          title: '确认解绑',
+          disabled: !record(index)?.id,
+          onConfirm: async () => {
+            // deteleMaster(item.id)
+            // remove([record(index)?.id]);
+          },
+        }}
+        key="unbind"
+        type="link"
+      >
+        <DisconnectOutlined />
+      </PermissionButton>
+    );
+  };
+  const SchemaField = createSchemaField({
+    components: {
+      FormItem,
+      Editable,
+      ArrayTable,
+      Select,
+      NumberPicker,
+      Render,
+      ActionButton,
+      StatusRender,
+    },
+  });
+  const form = createForm({});
+
+  const schema = {
+    type: 'object',
+    properties: {
+      requestList: {
+        type: 'array',
+        'x-decorator': 'FormItem',
+        'x-component': 'ArrayTable',
+        'x-component-props': {
+          pagination: {
+            pageSize: 10,
+          },
+          scroll: { x: '100%' },
+        },
+        items: {
+          type: 'object',
+          properties: {
+            column1: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': { width: 120, title: '名称' },
+              properties: {
+                metadataId: {
+                  type: 'string',
+                  'x-component': 'Render',
+                },
+              },
+            },
+            column2: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': { width: 200, title: '通道' },
+              properties: {
+                collectorId: {
+                  type: 'string',
+                  'x-decorator': 'FormItem',
+                  'x-component': 'Select',
+                  'x-component-props': {
+                    placeholder: '请选择',
+                    showSearch: true,
+                    allowClear: true,
+                    showArrow: true,
+                    filterOption: (input: string, option: any) =>
+                      option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
+                  },
+                  // enum: masterList,
+                },
+              },
+            },
+            column3: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': {
+                width: 200,
+                title: (
+                  <>
+                    采集器
+                    <Tooltip title="边缘网关代理的真实物理设备">
+                      <QuestionCircleOutlined />
+                    </Tooltip>
+                  </>
+                ),
+              },
+              properties: {
+                collectors: {
+                  type: 'string',
+                  'x-decorator': 'FormItem',
+                  'x-component': 'Select',
+                  'x-component-props': {
+                    placeholder: '请选择',
+                    showSearch: true,
+                    allowClear: true,
+                    showArrow: true,
+                    filterOption: (input: string, option: any) =>
+                      option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
+                  },
+                  'x-reactions': ['{{useAsyncDataSource(getName)}}'],
+                },
+              },
+            },
+            column4: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': { width: 200, title: '点位' },
+              properties: {
+                pointId: {
+                  type: 'string',
+                  'x-decorator': 'FormItem',
+                  'x-component': 'Select',
+                  'x-component-props': {
+                    placeholder: '请选择',
+                    showSearch: true,
+                    allowClear: true,
+                    showArrow: true,
+                    filterOption: (input: string, option: any) =>
+                      option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
+                  },
+                  'x-reactions': ['{{useAsyncDataSource(getName)}}'],
+                },
+              },
+            },
+            column6: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': {
+                width: 100,
+                title: '状态',
+                // sorter: (a: any, b: any) => a.state.value.length - b.state.value.length,
+              },
+              properties: {
+                id: {
+                  type: 'string',
+                  'x-decorator': 'FormItem',
+                  'x-component': 'StatusRender',
+                },
+              },
+            },
+            column7: {
+              type: 'void',
+              'x-component': 'ArrayTable.Column',
+              'x-component-props': {
+                title: '操作',
+                dataIndex: 'operations',
+                width: 50,
+                fixed: 'right',
+              },
+              properties: {
+                item: {
+                  type: 'void',
+                  'x-component': 'FormItem',
+                  properties: {
+                    remove: {
+                      type: 'void',
+                      'x-component': 'ActionButton',
+                    },
+                  },
+                },
+              },
+            },
+          },
+        },
+      },
+    },
+  };
+
+  return (
+    <div>
+      <div className="top-button">
+        <Button style={{ marginRight: 10 }}>批量映射</Button>
+        <Button type="primary">保存</Button>
+      </div>
+      <div>
+        <FormProvider form={form}>
+          <SchemaField schema={schema} scope={{}} />
+        </FormProvider>
+      </div>
+    </div>
+  );
+};
+export default MapTable;

+ 37 - 0
src/pages/device/Instance/Detail/EdgeMap/service.ts

@@ -0,0 +1,37 @@
+import BaseService from '@/utils/BaseService';
+import { request } from 'umi';
+import SystemConst from '@/utils/const';
+
+class Service extends BaseService<any> {
+  restPassword = (deviceId: string, data?: any) =>
+    request(
+      `/${SystemConst.API_BASE}/edge/operations/${deviceId}/auth-user-password-reset/invoke`,
+      {
+        method: 'POST',
+        data,
+      },
+    );
+  edgeChannel = (deviceId: string, data?: any) =>
+    request(
+      `/${SystemConst.API_BASE}/edge/operations/${deviceId}/data-collector-channel-list/invoke`,
+      {
+        method: 'POST',
+        data,
+      },
+    );
+  edgeCollector = (deviceId: string, data?: any) =>
+    request(`/${SystemConst.API_BASE}/edge/operations/${deviceId}/data-collector-list/invoke`, {
+      method: 'POST',
+      data,
+    });
+  edgePoint = (deviceId: string, data?: any) =>
+    request(
+      `/${SystemConst.API_BASE}/edge/operations/${deviceId}/data-collector-point-list/invoke`,
+      {
+        method: 'POST',
+        data,
+      },
+    );
+}
+
+export default Service;

+ 8 - 0
src/pages/device/Instance/Detail/index.tsx

@@ -29,6 +29,7 @@ import Service from '@/pages/device/Instance/service';
 import useLocation from '@/hooks/route/useLocation';
 import useLocation from '@/hooks/route/useLocation';
 import { onlyMessage, isNoCommunity } from '@/utils/util';
 import { onlyMessage, isNoCommunity } from '@/utils/util';
 import Parsing from './Parsing';
 import Parsing from './Parsing';
+// import EdgeMap from './EdgeMap';
 
 
 export const deviceStatus = new Map();
 export const deviceStatus = new Map();
 deviceStatus.set('online', <Badge status="success" text={'在线'} />);
 deviceStatus.set('online', <Badge status="success" text={'在线'} />);
@@ -212,6 +213,13 @@ const InstanceDetail = observer(() => {
           component: <ChildDevice />,
           component: <ChildDevice />,
         });
         });
       }
       }
+      // if(response.result){
+      //   datalist.push({
+      //     key: 'edge-map',
+      //     tab: '边缘端映射',
+      //     component: <EdgeMap />,
+      //   })
+      // }
       setList(datalist);
       setList(datalist);
       // 写入物模型数据
       // 写入物模型数据
       const metadata: DeviceMetadata = JSON.parse(response.result?.metadata || '{}');
       const metadata: DeviceMetadata = JSON.parse(response.result?.metadata || '{}');

+ 2 - 1
src/pages/init-home/service.ts

@@ -51,7 +51,8 @@ class Service extends BaseService<any> {
   // 更新全部菜单
   // 更新全部菜单
   // updateMenus = (data: any) =>
   // updateMenus = (data: any) =>
   //   request(`${SystemConst.API_BASE}/menu/_all`, { method: 'PATCH', data });
   //   request(`${SystemConst.API_BASE}/menu/_all`, { method: 'PATCH', data });
-  updateMenus = (data: any) => request(`${this.uri}/iot/_all`, { method: 'PATCH', data });
+  updateMenus = (data: any) =>
+    request(`${SystemConst.API_BASE}/menu/iot/_all`, { method: 'PATCH', data });
 
 
   // 添加角色
   // 添加角色
   addRole = (data: any) => request(`/${SystemConst.API_BASE}/role`, { method: 'POST', data });
   addRole = (data: any) => request(`/${SystemConst.API_BASE}/role`, { method: 'POST', data });