Lind 4 лет назад
Родитель
Сommit
291fb953de

+ 5 - 5
src/pages/Analysis/MessageChart/index.tsx

@@ -1,7 +1,7 @@
-import { Column } from '@ant-design/charts';
+import {Column, ColumnConfig} from '@ant-design/charts';
 import moment from 'moment';
-import { useEffect } from 'react';
-import { service } from '@/pages/Analysis';
+import {useEffect} from 'react';
+import {service} from '@/pages/Analysis';
 
 const calculationDate = () => {
   const dd = new Date();
@@ -97,13 +97,13 @@ const MessageChart = () => {
 
   const paletteSemanticRed = '#F4664A';
   const brandColor = '#5B8FF9';
-  const config = {
+  const config: ColumnConfig = {
     data,
     xField: 'type',
     yField: 'value',
     seriesField: '',
     color: function color(_ref: any) {
-      const { type } = _ref;
+      const {type} = _ref;
       if (type === '10-30分' || type === '30+分') {
         return paletteSemanticRed;
       }

+ 40 - 14
src/pages/link/Gateway/index.tsx

@@ -1,9 +1,8 @@
-import { PageContainer } from '@ant-design/pro-layout';
-import BaseService from '@/utils/BaseService';
-import type { GatewayItem } from '@/pages/link/Gateway/typings';
-import { useRef } from 'react';
-import type { ActionType, ProColumns } from '@jetlinks/pro-table';
-import { Tooltip } from 'antd';
+import {PageContainer} from '@ant-design/pro-layout';
+import type {GatewayItem} from '@/pages/link/Gateway/typings';
+import {useEffect, useRef} from 'react';
+import type {ActionType, ProColumns} from '@jetlinks/pro-table';
+import {Tooltip} from 'antd';
 import {
   ArrowDownOutlined,
   BarsOutlined,
@@ -12,9 +11,14 @@ import {
   MinusOutlined,
 } from '@ant-design/icons';
 import BaseCrud from '@/components/BaseCrud';
-import { useIntl } from '@@/plugin-locale/localeExports';
+import {useIntl} from '@@/plugin-locale/localeExports';
+import {ISchema} from "@formily/json-schema";
+import Service from "@/pages/link/Gateway/service";
+import linkService from "@/pages/link/service";
+import GatewayModel from "@/pages/link/Gateway/model";
+
+export const service = new Service('network/config');
 
-export const service = new BaseService<GatewayItem>('network/config');
 const Gateway = () => {
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
@@ -63,7 +67,7 @@ const Gateway = () => {
               defaultMessage: '编辑',
             })}
           >
-            <EditOutlined />
+            <EditOutlined/>
           </Tooltip>
         </a>,
         <a>
@@ -73,7 +77,7 @@ const Gateway = () => {
               defaultMessage: '删除',
             })}
           >
-            <MinusOutlined />
+            <MinusOutlined/>
           </Tooltip>
         </a>,
         <a>
@@ -83,7 +87,7 @@ const Gateway = () => {
               defaultMessage: '下载配置',
             })}
           >
-            <ArrowDownOutlined />
+            <ArrowDownOutlined/>
           </Tooltip>
         </a>,
         <a>
@@ -93,7 +97,7 @@ const Gateway = () => {
               defaultMessage: '调试',
             })}
           >
-            <BugOutlined />
+            <BugOutlined/>
           </Tooltip>
         </a>,
         <a>
@@ -103,14 +107,36 @@ const Gateway = () => {
               defaultMessage: '通知记录',
             })}
           >
-            <BarsOutlined />
+            <BarsOutlined/>
           </Tooltip>
         </a>,
       ],
     },
   ];
 
-  const schema = {};
+  const getProviders = () => {
+    linkService.getProviders().subscribe(data => {
+      GatewayModel.provider = data;
+    });
+  }
+
+  useEffect(() => {
+    getProviders();
+  }, []);
+
+  const schema: ISchema = {
+    type: 'object',
+    properties: {
+      name: {},
+      type: {
+        title: '类型',
+        'x-component': 'Select',
+        enum: GatewayModel.provider
+      },
+      network: {},
+      description: {}
+    }
+  };
 
   return (
     <PageContainer>

+ 10 - 0
src/pages/link/Gateway/model.ts

@@ -0,0 +1,10 @@
+import {model} from "@formily/reactive";
+
+type GatewayModelType = {
+  provider: { label: string, value: string }[]
+}
+const GatewayModel = model<GatewayModelType>({
+  provider: []
+})
+
+export default GatewayModel;

+ 8 - 0
src/pages/link/Gateway/service.ts

@@ -0,0 +1,8 @@
+import BaseService from '@/utils/BaseService';
+import {GatewayItem} from "@/pages/link/Gateway/typings";
+
+class Service extends BaseService<GatewayItem> {
+
+}
+
+export default Service;

+ 1 - 1
src/pages/link/Gateway/typings.d.ts

@@ -1,4 +1,4 @@
-import type { BaseItem, State } from '@/utils/typings';
+import type {BaseItem, State} from '@/utils/typings';
 
 type GatewayItem = {
   networkId: string;

+ 31 - 0
src/pages/link/service.ts

@@ -0,0 +1,31 @@
+import {request} from 'umi';
+import {defer, from} from 'rxjs';
+import SystemConst from "@/utils/const";
+import {filter, map} from "rxjs/operators";
+
+class LinkService {
+
+  public getProviders = () =>
+    defer(() =>
+      from(
+        request(`${SystemConst.API_BASE}/gateway/device/providers`, {
+          method: 'GET'
+        }),
+      ),
+    ).pipe(
+      filter((item) => item.status === 200),
+      map((item) => item.result),
+    );
+
+  public getSupports = () => {
+    defer(() =>
+      from(
+        request(`${SystemConst.API_BASE}/protocol/supports`, {
+          method: 'GET'
+        })
+      ))
+  }
+}
+
+const linkService = new LinkService();
+export default linkService;