Просмотр исходного кода

fix(triggerTerms): triggerTerms

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

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

@@ -109,7 +109,7 @@ export const FTermArrayCards: ComposedArrayCards = observer((props) => {
                               width: 100,
                             },
                           },
-                          default: 'and',
+                          'x-value': 'and',
                           enum: [
                             { label: '并且', value: 'and' },
                             { label: '或者', value: 'or' },

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

@@ -21,7 +21,7 @@ const FTermTypeSelect = (props: Props) => {
         onChange={(value) => props.onChange(value)}
         value={props.value}
         style={{ width: '200px' }}
-        defaultValue={'or'}
+        defaultValue={'and'}
         options={[
           { label: '并且', value: 'and' },
           { label: '或者', value: 'or' },

+ 57 - 2
src/pages/rule-engine/Scene/TriggerTerm/index.tsx

@@ -178,6 +178,14 @@ const TriggerTerm = (props: Props, ref: any) => {
                     };
                   }
                 });
+                form1.setFieldState(field.query('.value2'), (state) => {
+                  state.componentType = valueTypeMap[valueType];
+                  if (valueType === 'date') {
+                    state.componentProps = {
+                      showTime: true,
+                    };
+                  }
+                });
               } else if (source === 'metrics') {
                 // 指标
                 form1.setFieldState(value, (state) => {
@@ -224,6 +232,9 @@ const TriggerTerm = (props: Props, ref: any) => {
         type: 'array',
         'x-component': 'FTermArrayCards',
         'x-decorator': 'FormItem',
+        'x-value': {
+          termType: 'and',
+        },
         'x-component-props': {
           title: '分组',
         },
@@ -323,11 +334,55 @@ const TriggerTerm = (props: Props, ref: any) => {
                               },
                             },
                             required: true,
+                            'x-reactions': [
+                              {
+                                dependencies: ['.source'],
+                                fulfill: {
+                                  state: {
+                                    visible: '{{$deps[0]==="manual"}}',
+                                  },
+                                },
+                              },
+                              {
+                                dependencies: ['..termType'],
+                                when: '{{["nbtw","btw"].includes($deps[0])}}',
+                                fulfill: {
+                                  state: {
+                                    decoratorProps: {
+                                      style: {
+                                        width: 'calc(50% - 55px)',
+                                      },
+                                    },
+                                  },
+                                },
+                                otherwise: {
+                                  state: {
+                                    decoratorProps: {
+                                      style: {
+                                        width: 'calc(100% - 110px)',
+                                      },
+                                    },
+                                  },
+                                },
+                              },
+                            ],
+                          },
+                          value2: {
+                            type: 'string',
+                            'x-component': 'Input',
+                            'x-decorator': 'FormItem',
+                            'x-decorator-props': {
+                              style: {
+                                width: 'calc(50% - 55px)',
+                              },
+                            },
+                            required: true,
                             'x-reactions': {
-                              dependencies: ['.source'],
+                              dependencies: ['.source', '..termType'],
                               fulfill: {
                                 state: {
-                                  visible: '{{$deps[0]==="manual"}}',
+                                  visible:
+                                    '{{$deps[0]==="manual"&&["nbtw","btw"].includes($deps[1])}}',
                                 },
                               },
                             },