xieyonghong 3 éve
szülő
commit
04ea1f6a06

BIN
public/images/notice/webhook-backgroud.png


BIN
public/images/notice/webhook.png


+ 101 - 13
src/pages/notice/Config/Detail/index.tsx

@@ -53,6 +53,9 @@ export const docMap = {
   email: {
     embedded: <Email />,
   },
+  webhook: {
+    default: <div>webhook</div>,
+  },
 };
 
 const Detail = observer(() => {
@@ -87,6 +90,9 @@ const Detail = observer(() => {
   );
 
   useEffect(() => {
+    // if (id === 'webhook') {
+    //   setProvider('default');
+    // }
     if (state.current) {
       form.setValues(state.current);
     }
@@ -452,21 +458,103 @@ const Detail = observer(() => {
               },
             },
           },
+          webhook: {
+            type: 'void',
+            properties: {
+              url: {
+                title: 'Webhook',
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入Webhook',
+                },
+                'x-component': 'Input',
+                'x-decorator': 'FormItem',
+              },
+              headers: {
+                title: '请求头',
+                type: 'array',
+                'x-decorator': 'FormItem',
+                'x-component': 'ArrayTable',
+                'x-component-props': {
+                  pagination: { pageSize: 9999 },
+                  scroll: { x: '100%' },
+                },
+                items: {
+                  type: 'object',
+                  properties: {
+                    column1: {
+                      type: 'void',
+                      'x-component': 'ArrayTable.Column',
+                      'x-component-props': { width: 200, title: 'KEY' },
+                      properties: {
+                        key: {
+                          type: 'string',
+                          // 'x-decorator': 'Editable',
+                          'x-component': 'Input',
+                        },
+                      },
+                    },
+                    column2: {
+                      type: 'void',
+                      'x-component': 'ArrayTable.Column',
+                      'x-component-props': { width: 200, title: 'VALUE' },
+                      properties: {
+                        value: {
+                          type: 'string',
+                          // 'x-decorator': 'Editable',
+                          'x-component': 'Input',
+                        },
+                      },
+                    },
+                    column3: {
+                      type: 'void',
+                      'x-component': 'ArrayTable.Column',
+                      'x-component-props': {
+                        title: '操作',
+                        dataIndex: 'operations',
+                        width: 200,
+                        fixed: 'right',
+                      },
+                      properties: {
+                        item: {
+                          type: 'void',
+                          'x-component': 'FormItem',
+                          properties: {
+                            remove: {
+                              type: 'void',
+                              'x-component': 'ArrayTable.Remove',
+                            },
+                          },
+                        },
+                      },
+                    },
+                  },
+                },
+                properties: {
+                  add: {
+                    type: 'void',
+                    'x-component': 'ArrayTable.Addition',
+                    title: '添加条目',
+                  },
+                },
+              },
+            },
+          },
         },
-      },
-      description: {
-        title: '说明',
-        'x-decorator': 'FormItem',
-        'x-component': 'Input.TextArea',
-        'x-component-props': {
-          rows: 4,
-        },
-        'x-validator': [
-          {
-            max: 200,
-            message: '最多可输入200个字符',
+        description: {
+          title: '说明',
+          'x-decorator': 'FormItem',
+          'x-component': 'Input.TextArea',
+          'x-component-props': {
+            rows: 4,
           },
-        ],
+          'x-validator': [
+            {
+              max: 200,
+              message: '最多可输入200个字符',
+            },
+          ],
+        },
       },
     },
   };

+ 14 - 0
src/pages/notice/index.tsx

@@ -20,6 +20,7 @@ const dingTalkMessage = require('/public/images/notice/dingTalk-message.png');
 const dingTalkRebot = require('/public/images/notice/dingTalk-rebot.png');
 const sms = require('/public/images/notice/sms.png');
 const vocie = require('/public/images/notice/voice.png');
+const webhook = require('/public/images/notice/webhook.png');
 
 export const typeList = {
   weixin: [
@@ -60,6 +61,12 @@ export const typeList = {
       label: '默认',
     },
   ],
+  webhook: [
+    {
+      label: createImageLabel(webhook, 'Webhook'),
+      value: 'webhook',
+    },
+  ],
 };
 
 const Type = observer(() => {
@@ -89,6 +96,11 @@ const Type = observer(() => {
       name: '短信',
       describe: '支持阿里云短信消息类型',
     },
+    {
+      type: 'webhook',
+      name: 'webhook',
+      describe: '支持websocket消息通知',
+    },
   ];
 
   const iconMap = new Map();
@@ -97,6 +109,7 @@ const Type = observer(() => {
   iconMap.set('email', require('/public/images/notice/email.png'));
   iconMap.set('voice', require('/public/images/notice/voice.png'));
   iconMap.set('sms', require('/public/images/notice/sms.png'));
+  iconMap.set('webhook', require('/public/images/notice/webhook.png'));
 
   const bGroundMap = new Map();
   bGroundMap.set('dingTalk', require('/public/images/notice/dingtalk-background.png'));
@@ -104,6 +117,7 @@ const Type = observer(() => {
   bGroundMap.set('email', require('/public/images/notice/email-background.png'));
   bGroundMap.set('voice', require('/public/images/notice/voice-background.png'));
   bGroundMap.set('sms', require('/public/images/notice/sms-background.png'));
+  bGroundMap.set('webhook', require('/public/images/notice/webhook-backgroud.png'));
 
   return (
     <PageContainer

+ 9 - 1
src/pages/rule-engine/Scene/TriggerTerm/index.tsx

@@ -196,7 +196,10 @@ const TriggerTerm = (props: Props, ref: any) => {
   );
 
   useImperativeHandle(ref, () => ({
-    getTriggerForm: () => form.submit(),
+    getTriggerForm: async () => {
+      await form.validate();
+      await form.submit();
+    },
   }));
   const SchemaField = createSchemaField({
     components: {
@@ -261,6 +264,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                         'x-decorator-props': {
                           gridSpan: 6,
                         },
+                        required: true,
                         'x-component-props': {
                           placeholder: '请选择参数',
                           fieldNames: { value: 'column', label: 'name', options: 'children' },
@@ -279,6 +283,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                         'x-component-props': {
                           placeholder: '操作符',
                         },
+                        required: true,
                       },
                       value: {
                         type: 'object',
@@ -301,6 +306,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                             type: 'string',
                             'x-component': 'Select',
                             'x-decorator': 'FormItem',
+                            required: true,
                             'x-component-props': {
                               style: {
                                 minWidth: '110px',
@@ -316,6 +322,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                                 width: 'calc(100% - 110px)',
                               },
                             },
+                            required: true,
                             'x-reactions': {
                               dependencies: ['.source'],
                               fulfill: {
@@ -334,6 +341,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                                 width: '100%',
                               },
                             },
+                            required: true,
                             'x-decorator-props': {
                               style: {
                                 width: 'calc(100% - 110px)',