Browse Source

fix: 合并冲突

sun-chaochao 3 years atrás
parent
commit
1dfa19bd25

+ 12 - 0
src/components/FInputGroup/index.tsx

@@ -0,0 +1,12 @@
+import { Input } from 'antd';
+import { GroupProps } from 'antd/lib/input';
+import React from 'react';
+
+const InputGroup = Input.Group;
+
+export const FInputGroup: React.FC<GroupProps> = (props) => {
+  return React.createElement(InputGroup, {
+    ...props,
+  });
+};
+export default FInputGroup;

+ 1 - 0
src/components/FInputGroup/style.ts

@@ -0,0 +1 @@
+import 'antd/lib/input/style/index';

+ 1 - 1
src/components/ProTableCard/TableCard.tsx

@@ -1,8 +1,8 @@
 import React, { useState } from 'react';
 import classNames from 'classnames';
 import { BadgeStatus } from '@/components';
-import { StatusColorEnum } from '@/components/BadgeStatus';
 import type { StatusColorType } from '@/components/BadgeStatus';
+import { StatusColorEnum } from '@/components/BadgeStatus';
 import './index.less';
 
 export interface TableCardProps {

+ 18 - 1
src/pages/device/components/Metadata/Cat/index.tsx

@@ -1,4 +1,4 @@
-import { Drawer, Tabs } from 'antd';
+import { Button, Drawer, message, Space, Tabs } from 'antd';
 import { useEffect, useState } from 'react';
 import { productModel, service } from '@/pages/device/Product';
 import MonacoEditor from 'react-monaco-editor';
@@ -6,6 +6,7 @@ import { observer } from '@formily/react';
 import { InstanceModel } from '@/pages/device/Instance';
 import { useLocation } from 'umi';
 import InstanceService from '@/pages/device/Instance/service';
+import { downloadObject } from '@/utils/util';
 
 interface Props {
   visible: boolean;
@@ -63,6 +64,22 @@ const Cat = observer((props: Props) => {
       title="查看物模型"
       onClose={() => props.close()}
       visible={props.visible}
+      extra={
+        <Space>
+          <Button
+            type="primary"
+            onClick={async () => {
+              try {
+                downloadObject(JSON.parse(value), `设备-物模型`);
+              } catch (e) {
+                message.error('物模型格式错误!');
+              }
+            }}
+          >
+            导出模型文件
+          </Button>
+        </Space>
+      }
     >
       <div style={{ background: 'rgb(236, 237, 238)' }}>
         <p style={{ padding: 10 }}>

+ 5 - 4
src/pages/notice/Template/Debug/index.tsx

@@ -203,9 +203,10 @@ const Debug = observer(() => {
     const data: { configId: string; variableDefinitions: any } = await form.submit();
     // 应该取选择的配置信息
     if (!state.current) return;
-    const resp = await service.debug(data.configId, state?.current.id, {
-      template: state.current,
-      context: data.variableDefinitions?.reduce(
+    const resp = await service.debug(
+      data.configId,
+      state?.current.id,
+      data.variableDefinitions?.reduce(
         (previousValue: any, currentValue: { id: any; value: any }) => {
           return {
             ...previousValue,
@@ -214,7 +215,7 @@ const Debug = observer(() => {
         },
         {},
       ),
-    });
+    );
     if (resp.status === 200) {
       message.success('操作成功!');
     }

+ 4 - 4
src/pages/notice/Template/Detail/index.tsx

@@ -265,7 +265,7 @@ const Detail = observer(() => {
                   : {
                       id: item,
                       type: 'string',
-                      format: 's%',
+                      format: '%s',
                     },
               );
               form1.setValuesIn('variableDefinitions', _result);
@@ -313,7 +313,7 @@ const Detail = observer(() => {
                   : {
                       id: item,
                       type: 'string',
-                      format: 's%',
+                      format: '%s',
                     },
               );
               form1.setValuesIn('variableDefinitions', _result);
@@ -354,7 +354,7 @@ const Detail = observer(() => {
               case 'string':
                 format.setComponent(PreviewText.Input);
                 if (fieldModified) {
-                  format.setValue('s%');
+                  format.setValue('%s');
                 }
                 break;
               case 'number':
@@ -1200,7 +1200,7 @@ const Detail = observer(() => {
             column2: {
               type: 'void',
               'x-component': 'ArrayTable.Column',
-              'x-component-props': { title: '名称' },
+              'x-component-props': { title: '名称', width: '120px' },
               properties: {
                 name: {
                   type: 'string',

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

@@ -213,7 +213,7 @@ const Save = (props: Props) => {
       visible={visible}
       onOk={handleSave}
       onCancel={() => close()}
-      title="新增告警"
+      title={`${props.data ? '编辑' : '新增'}告警`}
     >
       <Form className={styles.form} form={form} layout="vertical">
         <SchemaField

+ 3 - 1
src/pages/rule-engine/Alarm/Configuration/index.tsx

@@ -182,7 +182,9 @@ const Configuration = () => {
         search={false}
         params={param}
         columns={columns}
-        request={(params) => service.query(params)}
+        request={(params) =>
+          service.query({ ...params, sorts: [{ name: 'createTime', order: 'desc' }] })
+        }
         gridColumn={3}
         cardRender={(record) => (
           <AlarmConfig

+ 7 - 0
src/pages/rule-engine/Alarm/Log/TabComponent/index.less

@@ -67,6 +67,7 @@
 
           .alarm-type {
             max-width: 120px;
+
             .name {
               color: #000;
               font-size: 18px;
@@ -85,8 +86,10 @@
           justify-content: space-between;
           width: 50%;
           padding-left: @alarm-log-padding-left;
+
           .alarm-log-time {
             max-width: 165px;
+
             .log-title {
               margin-top: 8px;
               color: #666;
@@ -100,6 +103,7 @@
               .ellipsis();
             }
           }
+
           .alarm-log-status {
             margin-left: @alarm-log-padding-left;
           }
@@ -133,8 +137,10 @@
             }
           }
         }
+
         .alarm-log-action:hover {
           background-color: @primary-color;
+
           .icon,
           div {
             color: #fff;
@@ -168,6 +174,7 @@
       }
     }
   }
+
   .alarm-log-item:hover {
     box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
   }

+ 41 - 112
src/pages/rule-engine/Scene/TriggerTerm/index.tsx

@@ -23,6 +23,7 @@ import Service from '@/pages/rule-engine/Scene/service';
 import { useAsyncDataSource } from '@/utils/util';
 import { Store } from 'jetlinks-store';
 import { treeFilter } from '@/utils/tree';
+import FInputGroup from '@/components/FInputGroup';
 
 const service = new Service('scene');
 
@@ -34,56 +35,9 @@ interface Props {
 }
 
 const TriggerTerm = (props: Props, ref: any) => {
-  const requestParams = {
-    trigger: {
-      type: 'device',
-      device: {
-        productId: '0412-zj',
-        selector: 'device',
-        selectorValue: [
-          {
-            id: '0412-zj',
-            name: '0412-zj',
-          },
-        ],
-        operation: {
-          operator: 'reportProperty',
-          timer: {
-            trigger: 'week',
-            cron: '',
-            when: [1, 3, 5],
-            mod: 'period',
-            period: {
-              from: '09:30',
-              to: '14:30',
-              every: 1,
-              unit: 'hours',
-            },
-            once: {
-              time: '',
-            },
-          },
-          eventId: '',
-          readProperties: ['temparature', 'temperature-k', 'test-zhibioa'],
-          writeProperties: {},
-          functionId: '',
-          functionParameters: [
-            {
-              name: '',
-              value: {},
-            },
-          ],
-        },
-        defaultVariable: [],
-      },
-      timer: {},
-      defaultVariable: [],
-    },
-  };
-
   const parseTermRef = useRef<any>();
   const getParseTerm = () =>
-    service.getParseTerm(requestParams || props.params).then((data) => {
+    service.getParseTerm(props.params).then((data) => {
       Store.set('trigger-parse-term', data);
       parseTermRef.current = data;
       return data.map((item: any) => ({
@@ -97,55 +51,7 @@ const TriggerTerm = (props: Props, ref: any) => {
     () =>
       createForm({
         validateFirst: true,
-        initialValues:
-          {
-            trigger: [
-              {
-                terms: [
-                  {
-                    column: 'properties.temprature.current',
-                    termType: 'gt',
-                    source: 'manual',
-                    value: 123,
-                  },
-                  {
-                    column: 'properties.test-zhibioa.recent',
-                    termType: 'gt',
-                    source: 'metrics',
-                    value: '123',
-                  },
-                  {
-                    column: 'properties.test-zhibioa.current',
-                    termType: 'lte',
-                    source: 'manual',
-                    value: 223,
-                  },
-                ],
-              },
-              {
-                terms: [
-                  {
-                    column: 'properties.temprature.current',
-                    termType: 'btw',
-                    source: 'manual',
-                    value: 23,
-                  },
-                  {
-                    column: 'properties.temperature-k.current',
-                    termType: 'gt',
-                    source: 'manual',
-                    value: 123,
-                  },
-                  {
-                    column: '_now',
-                    termType: 'eq',
-                    source: 'manual',
-                    value: '2022-04-29 00:00:07',
-                  },
-                ],
-              },
-            ],
-          } || props.value,
+        initialValues: props.value,
 
         effects() {
           onFormValuesChange(async (f) => {
@@ -158,13 +64,13 @@ const TriggerTerm = (props: Props, ref: any) => {
             const value = (field as Field).value;
 
             // 找到选中的
-            const _data = await service.getParseTerm(requestParams || props.params);
+            const _data = await service.getParseTerm(props.params);
             if (!_data) return;
             // 树形搜索
             const treeValue = treeFilter(_data, value, 'column');
             // 找到
             const target =
-              treeValue && treeValue[0].children
+              treeValue && treeValue[0]?.children
                 ? treeValue[0]?.children.find((item) => item.column === value)
                 : treeValue[0];
 
@@ -254,6 +160,7 @@ const TriggerTerm = (props: Props, ref: any) => {
       FormGrid,
       FTermTypeSelect,
       TreeSelect,
+      FInputGroup,
     },
   });
 
@@ -302,7 +209,7 @@ const TriggerTerm = (props: Props, ref: any) => {
                         'x-decorator': 'FormItem',
                         'x-component': 'TreeSelect',
                         'x-decorator-props': {
-                          gridSpan: 4,
+                          gridSpan: 6,
                         },
                         'x-component-props': {
                           placeholder: '请选择参数',
@@ -322,21 +229,43 @@ const TriggerTerm = (props: Props, ref: any) => {
                           placeholder: '操作符',
                         },
                       },
-                      source: {
-                        type: 'string',
+                      inputGroup: {
+                        type: 'void',
+                        'x-component': 'FInputGroup',
                         'x-decorator': 'FormItem',
-                        'x-component': 'Select',
                         'x-decorator-props': {
-                          gridSpan: 1,
+                          gridSpan: 4,
+                          style: {
+                            width: '100%',
+                          },
                         },
-                      },
-                      value: {
-                        type: 'string',
-                        'x-decorator': 'FormItem',
-                        'x-component': 'Input',
-                        'x-component-props': {},
-                        'x-decorator-props': {
-                          gridSpan: 3,
+                        'x-component-props': {
+                          compact: true,
+                          style: {
+                            width: '100%',
+                          },
+                        },
+                        properties: {
+                          source: {
+                            type: 'string',
+                            'x-component': 'Select',
+                            'x-decorator': 'FormItem',
+                            'x-component-props': {
+                              style: {
+                                minWidth: '110px',
+                              },
+                            },
+                          },
+                          value: {
+                            type: 'string',
+                            'x-component': 'Input',
+                            'x-decorator': 'FormItem',
+                            'x-decorator-props': {
+                              style: {
+                                width: 'calc(100% - 110px)',
+                              },
+                            },
+                          },
                         },
                       },
                       remove: {