lind 3 лет назад
Родитель
Сommit
1e87616ef8

+ 1 - 1
src/components/SearchComponent/index.tsx

@@ -307,7 +307,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
           'x-decorator': 'FormItem',
           'x-component': 'GroupNameControl',
           'x-decorator-props': {
-            gridSpan: 2,
+            gridSpan: 3,
           },
           default: 'or',
           'x-component-props': {

+ 29 - 0
src/pages/Northbound/DuerOS/index.tsx

@@ -141,6 +141,15 @@ export default () => {
         defaultMessage: '产品',
       }),
       dataIndex: 'productName',
+      hideInSearch: true,
+      valueType: 'select',
+      request: async () => {
+        const res = await service.getProduct();
+        if (res.status === 200) {
+          return res.result.map((pItem: any) => ({ label: pItem.name, value: pItem.id }));
+        }
+        return [];
+      },
     },
     {
       title: intl.formatMessage({
@@ -149,10 +158,19 @@ export default () => {
       }),
       dataIndex: 'applianceType',
       renderText: (data) => data.text,
+      valueType: 'select',
+      request: async () => {
+        const res = await service.getTypes();
+        if (res.status === 200) {
+          return res.result.map((pItem: any) => ({ label: pItem.name, value: pItem.id }));
+        }
+        return [];
+      },
     },
     {
       title: '说明',
       dataIndex: 'description',
+      hideInSearch: true,
     },
     {
       title: '状态',
@@ -164,6 +182,17 @@ export default () => {
         };
         return map[data.value];
       },
+      valueType: 'select',
+      valueEnum: {
+        disabled: {
+          text: '禁用',
+          status: 'disabled',
+        },
+        enabled: {
+          text: '正常',
+          status: 'enabled',
+        },
+      },
     },
     {
       title: intl.formatMessage({

+ 50 - 0
src/pages/notice/Template/index.tsx

@@ -38,6 +38,54 @@ export const state = model<{
   debug: false,
   log: false,
 });
+
+const list = {
+  weixin: {
+    corpMessage: {
+      text: '企业消息',
+      status: 'corpMessage',
+    },
+    officialMessage: {
+      text: '服务号消息',
+      status: 'officialMessage',
+    },
+  },
+  dingTalk: {
+    dingTalkMessage: {
+      text: '钉钉消息',
+      status: 'dingTalkMessage',
+    },
+    dingTalkRobotWebHook: {
+      text: '群机器人消息',
+      status: 'dingTalkRobotWebHook',
+    },
+  },
+  voice: {
+    aliyun: {
+      text: '阿里云语音',
+      status: 'aliyun',
+    },
+  },
+  sms: {
+    aliyunSms: {
+      text: '阿里云短信',
+      status: 'aliyunSms',
+    },
+  },
+  email: {
+    embedded: {
+      text: '默认',
+      status: 'embedded',
+    },
+  },
+  webhook: {
+    http: {
+      text: 'Webhook',
+      status: 'http',
+    },
+  },
+};
+
 const Template = observer(() => {
   const intl = useIntl();
   const location = useLocation<{ id: string }>();
@@ -56,6 +104,8 @@ const Template = observer(() => {
       dataIndex: 'provider',
       title: '通知方式',
       renderText: (text, record) => typeList[record.type][record.provider],
+      valueType: 'select',
+      valueEnum: list[id],
     },
     {
       dataIndex: 'description',

+ 27 - 10
src/pages/rule-engine/Alarm/Configuration/Save/index.tsx

@@ -1,6 +1,6 @@
 import { message, Modal, Typography } from 'antd';
 import { useMemo } from 'react';
-import { createForm, onFieldInit } from '@formily/core';
+import { createForm, Field, onFieldInit, onFieldValueChange } from '@formily/core';
 import { createSchemaField } from '@formily/react';
 import { Form, FormGrid, FormItem, Input, Radio, Select } from '@formily/antd';
 import { ISchema } from '@formily/json-schema';
@@ -11,6 +11,7 @@ import { useAsyncDataSource } from '@/utils/util';
 import styles from './index.less';
 import { service as ConfigService } from '../../Config';
 import { Store } from 'jetlinks-store';
+import encodeQuery from '@/utils/encodeQuery';
 
 interface Props {
   visible: boolean;
@@ -58,15 +59,6 @@ const Save = (props: Props) => {
     });
   };
 
-  const getScene = () => {
-    return service.getScene().then((resp) => {
-      Store.set('scene-data', resp.result);
-      return resp.result.map((item: { id: string; name: string }) => ({
-        label: item.name,
-        value: item.id,
-      }));
-    });
-  };
   const form = useMemo(
     () =>
       createForm({
@@ -80,11 +72,36 @@ const Save = (props: Props) => {
               disabled: resp.result > 0,
             });
           });
+          onFieldValueChange('targetType', async (field: Field, f) => {
+            if (field.modified) {
+              f.setFieldState(field.query('.sceneId'), (state) => {
+                state.value = undefined;
+              });
+            }
+          });
         },
       }),
     [props.data, props.visible],
   );
 
+  const getScene = () => {
+    return service
+      .getScene(
+        encodeQuery({
+          terms: {
+            triggerType: form.getValuesIn('targetType'),
+          },
+        }),
+      )
+      .then((resp) => {
+        Store.set('scene-data', resp.result);
+        return resp.result.map((item: { id: string; name: string }) => ({
+          label: item.name,
+          value: item.id,
+        }));
+      });
+  };
+
   const getSupports = () => service.getTargetTypes();
 
   const SchemaField = createSchemaField({

+ 2 - 1
src/pages/rule-engine/Alarm/Configuration/service.ts

@@ -13,9 +13,10 @@ class Service extends BaseService<ConfigItem> {
       }));
     });
 
-  public getScene = () =>
+  public getScene = (params: Record<string, any>) =>
     request(`/${SystemConst.API_BASE}/scene/_query/no-paging?paging=false`, {
       method: 'GET',
+      params,
     });
 
   public _enable = (id: string) =>