Bläddra i källkod

fix(bug): fix bug

lind 3 år sedan
förälder
incheckning
4a24b56d30

+ 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

@@ -178,7 +178,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