xieyonghong пре 3 година
родитељ
комит
a2c083df2c

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

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

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

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

+ 14 - 0
src/pages/device/components/Metadata/Base/Edit/index.tsx

@@ -715,6 +715,20 @@ const Edit = observer((props: Props) => {
                         labelAlign: 'left',
                         labelAlign: 'left',
                         layout: 'vertical',
                         layout: 'vertical',
                       },
                       },
+                      'x-validator': [
+                        {
+                          max: 64,
+                          message: '最多可输入64个字符',
+                        },
+                        {
+                          required: true,
+                          message: '请输入标识',
+                        },
+                        {
+                          validateId: true,
+                          message: 'ID只能由数字、26个英文字母或者下划线组成',
+                        },
+                      ],
                     },
                     },
                     name: {
                     name: {
                       // 名称
                       // 名称

+ 69 - 8
src/pages/rule-engine/Scene/TriggerTerm/index.tsx

@@ -154,7 +154,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                 : treeValue[0];
                 : treeValue[0];
 
 
             const source = (field as Field).value;
             const source = (field as Field).value;
-            const value = field.query(source === 'manual' ? '.value' : '.metric');
+            const value = field.query(source === 'manual' ? '.value.0' : '.metric');
             if (target) {
             if (target) {
               if (source === 'manual') {
               if (source === 'manual') {
                 // 手动输入
                 // 手动输入
@@ -178,14 +178,27 @@ const TriggerTerm = (props: Props, ref: any) => {
                     };
                     };
                   }
                   }
                 });
                 });
+                form1.setFieldState(field.query('.value.1'), (state) => {
+                  state.componentType = valueTypeMap[valueType];
+                  if (valueType === 'date') {
+                    state.componentProps = {
+                      showTime: true,
+                    };
+                  }
+                });
               } else if (source === 'metrics') {
               } else if (source === 'metrics') {
+                const termType = field.query('..termType').value();
+                const tag = ['nbtw', 'btw'].includes(termType);
                 // 指标
                 // 指标
                 form1.setFieldState(value, (state) => {
                 form1.setFieldState(value, (state) => {
                   state.componentType = Select;
                   state.componentType = Select;
-                  state.dataSource = target?.metrics.map((item: any) => ({
-                    label: item.name,
-                    value: item.id,
-                  }));
+                  state.dataSource = target?.metrics
+                    ?.filter((i: { range: boolean }) => i.range === tag)
+                    .map((item: any) => ({
+                      label: item.name,
+                      value: item.id,
+                    }));
+                  state.value = undefined;
                 });
                 });
               }
               }
             }
             }
@@ -224,6 +237,9 @@ const TriggerTerm = (props: Props, ref: any) => {
         type: 'array',
         type: 'array',
         'x-component': 'FTermArrayCards',
         'x-component': 'FTermArrayCards',
         'x-decorator': 'FormItem',
         'x-decorator': 'FormItem',
+        'x-value': {
+          termType: 'and',
+        },
         'x-component-props': {
         'x-component-props': {
           title: '分组',
           title: '分组',
         },
         },
@@ -313,7 +329,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                               },
                               },
                             },
                             },
                           },
                           },
-                          value: {
+                          'value[0]': {
                             type: 'string',
                             type: 'string',
                             'x-component': 'Input',
                             'x-component': 'Input',
                             'x-decorator': 'FormItem',
                             'x-decorator': 'FormItem',
@@ -323,15 +339,60 @@ const TriggerTerm = (props: Props, ref: any) => {
                               },
                               },
                             },
                             },
                             required: true,
                             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)',
+                                      },
+                                    },
+                                  },
+                                },
+                              },
+                            ],
+                          },
+                          'value[1]': {
+                            type: 'string',
+                            'x-component': 'Input',
+                            'x-decorator': 'FormItem',
+                            'x-decorator-props': {
+                              style: {
+                                width: 'calc(50% - 55px)',
+                              },
+                            },
+                            required: true,
                             'x-reactions': {
                             'x-reactions': {
-                              dependencies: ['.source'],
+                              dependencies: ['..source', '...termType'],
                               fulfill: {
                               fulfill: {
                                 state: {
                                 state: {
-                                  visible: '{{$deps[0]==="manual"}}',
+                                  visible:
+                                    '{{$deps[0]==="manual"&&["nbtw","btw"].includes($deps[1])}}',
                                 },
                                 },
                               },
                               },
                             },
                             },
                           },
                           },
+
                           metric: {
                           metric: {
                             type: 'string',
                             type: 'string',
                             'x-component': 'Select',
                             'x-component': 'Select',