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

fix: bug#5163、5129、5126、5089

xieyonghong 3 лет назад
Родитель
Сommit
9deb15b675

+ 2 - 2
src/components/FormItems/MetadataJsonInput/index.tsx

@@ -1,5 +1,5 @@
 import { Input, Modal } from 'antd';
-import { EnvironmentOutlined } from '@ant-design/icons';
+import { FormOutlined } from '@ant-design/icons';
 import { useEffect, useState } from 'react';
 import MonacoEditor from 'react-monaco-editor';
 import { isObject } from 'lodash';
@@ -75,7 +75,7 @@ export default (props: MetaDataJsonInputProps) => {
     <>
       <Input
         addonAfter={
-          <EnvironmentOutlined
+          <FormOutlined
             onClick={() => {
               setMonacoValue(value);
               setVisible(true);

+ 9 - 0
src/components/ProTableCard/index.less

@@ -217,6 +217,15 @@
       cursor: pointer;
       transition: all 0.3s;
 
+      > div {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        width: 100%;
+        height: 100%;
+        padding: 0 !important;
+      }
+
       &.show {
         background-color: rgba(#000, 0.5);
         visibility: visible;

+ 75 - 12
src/pages/device/Instance/Detail/Functions/form.tsx

@@ -1,6 +1,6 @@
 import type { FunctionMetadata } from '@/pages/device/Product/typings';
 import React, { useEffect, useRef, useState } from 'react';
-import { Button, DatePicker, Input, InputNumber, Select } from 'antd';
+import { Button, DatePicker, Input, InputNumber, Select, Tooltip } from 'antd';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import type { ProColumns } from '@jetlinks/pro-table';
 import { EditableProTable } from '@jetlinks/pro-table';
@@ -10,6 +10,7 @@ import { InstanceModel, service } from '@/pages/device/Instance';
 import moment from 'moment';
 import './index.less';
 import { GeoPoint, MetadataJsonInput } from '@/components';
+import { QuestionCircleOutlined } from '@ant-design/icons';
 
 type FunctionProps = {
   data: FunctionMetadata;
@@ -82,22 +83,88 @@ export default (props: FunctionProps) => {
   const columns: ProColumns<FunctionTableDataType>[] = [
     {
       dataIndex: 'name',
-      title: '名称',
+      title: '参数名称',
       width: 120,
       editable: false,
       ellipsis: true,
     },
     {
       dataIndex: 'type',
-      title: '类型',
+      title: '输入类型',
       width: 120,
       editable: false,
+      render: (row) => {
+        switch (row) {
+          case 'array':
+            return (
+              <span>
+                {row}
+                <Tooltip
+                  title={
+                    <div>
+                      <p>输入示例:</p>
+                      <p>配置类型为int时,输入[1,2,3,4]</p>
+                    </div>
+                  }
+                >
+                  <QuestionCircleOutlined style={{ marginLeft: 8 }} />
+                </Tooltip>
+              </span>
+            );
+          case 'object':
+            return (
+              <span>
+                {row}
+                <Tooltip
+                  title={
+                    <div>
+                      <p>请按照json格式输入</p>
+                    </div>
+                  }
+                >
+                  <QuestionCircleOutlined style={{ marginLeft: 8 }} />
+                </Tooltip>
+              </span>
+            );
+          case 'file':
+            return (
+              <span>
+                {row}
+                <Tooltip
+                  title={
+                    <div>
+                      <p>输入示例:</p>
+                      <p>模型配置为base64时,输入YXNkZmRzYWY=</p>
+                    </div>
+                  }
+                >
+                  <QuestionCircleOutlined style={{ marginLeft: 8 }} />
+                </Tooltip>
+              </span>
+            );
+          case 'geoPoint':
+            return (
+              <span>
+                {row}
+                <Tooltip
+                  title={
+                    <div>
+                      <p>输入示例:</p>
+                      <p>[102,12231, 39.251423]</p>
+                    </div>
+                  }
+                >
+                  <QuestionCircleOutlined style={{ marginLeft: 8 }} />
+                </Tooltip>
+              </span>
+            );
+          default:
+            return row;
+        }
+      },
     },
     {
-      title: intl.formatMessage({
-        id: 'pages.data.option',
-        defaultMessage: '操作',
-      }),
+      title: '值',
       dataIndex: 'value',
       align: 'center',
       renderFormItem: (_, row: any) => {
@@ -111,7 +178,6 @@ export default (props: FunctionProps) => {
     const properties = data.valueType ? data.valueType.properties : data.inputs;
 
     for (const datum of properties) {
-      console.log(datum);
       const type = datum.valueType ? datum.valueType.type : '-';
 
       array.push({
@@ -191,10 +257,7 @@ export default (props: FunctionProps) => {
               });
             }}
           >
-            {intl.formatMessage({
-              id: 'pages.data.option.cancel',
-              defaultMessage: '取消',
-            })}
+            清空
           </Button>
         </div>
       </div>

+ 17 - 10
src/pages/device/Instance/Detail/Functions/index.tsx

@@ -5,6 +5,7 @@ import FnForm from './form';
 import AModel from './AdvancedMode';
 import { useDomFullHeight } from '@/hooks';
 import Empty from '@/pages/device/components/Empty';
+import { ExclamationCircleOutlined } from '@ant-design/icons';
 
 const Functions = () => {
   const functionList = JSON.parse(InstanceModel.detail.metadata || '{}')
@@ -17,16 +18,22 @@ const Functions = () => {
       {functionList ? (
         <Tabs>
           <Tabs.TabPane tab={'精简模式'} key={1}>
-            <Tabs tabPosition="left">
-              {functionList &&
-                functionList.map((fn) => {
-                  return (
-                    <Tabs.TabPane tab={fn.name} key={fn.id}>
-                      <FnForm data={fn} />
-                    </Tabs.TabPane>
-                  );
-                })}
-            </Tabs>
+            <>
+              <div style={{ paddingBottom: 12 }}>
+                <ExclamationCircleOutlined style={{ marginRight: 12 }} />
+                精简模式下参数只支持已输入框的方式录入
+              </div>
+              <Tabs tabPosition="left">
+                {functionList &&
+                  functionList.map((fn) => {
+                    return (
+                      <Tabs.TabPane tab={fn.name} key={fn.id}>
+                        <FnForm data={fn} />
+                      </Tabs.TabPane>
+                    );
+                  })}
+              </Tabs>
+            </>
           </Tabs.TabPane>
           <Tabs.TabPane tab={'高级模式'} key={2}>
             <Tabs tabPosition="left">

+ 6 - 1
src/pages/device/Instance/Detail/Info/index.tsx

@@ -6,7 +6,7 @@ import { useIntl } from '@@/plugin-locale/localeExports';
 import Config from '@/pages/device/Instance/Detail/Config';
 import Reation from '@/pages/device/Instance/Detail/Reation';
 import Save from '../../Save';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
 import type { DeviceInstance } from '../../typings';
 import { EditOutlined } from '@ant-design/icons';
 import Tags from '@/pages/device/Instance/Detail/Tags';
@@ -19,6 +19,10 @@ const Info = observer(() => {
   const { permission } = PermissionButton.usePermission('device/Instance');
   const { minHeight } = useDomFullHeight(`.device-detail-body`);
 
+  useEffect(() => {
+    console.log(InstanceModel.detail);
+  }, [InstanceModel.detail]);
+
   return (
     <>
       <Card className={'device-detail-body'} style={{ minHeight }}>
@@ -131,6 +135,7 @@ const Info = observer(() => {
             InstanceModel.detail = {
               ...InstanceModel.detail,
               ...data,
+              describe: data.description,
             };
           }
         }}

+ 1 - 1
src/pages/device/Instance/Save/index.tsx

@@ -238,7 +238,7 @@ const Save = (props: Props) => {
         </Row>
         <Row>
           <Col span={24}>
-            <Form.Item label={intlFormat('pages.table.description', '说明')} name={'describe'}>
+            <Form.Item label={intlFormat('pages.table.description', '说明')} name={'description'}>
               <Input.TextArea
                 placeholder={
                   intlFormat('pages.form.tip.input', '请输入') +

+ 10 - 8
src/pages/device/Instance/index.tsx

@@ -662,14 +662,16 @@ const Instance = () => {
                   disabled: record.state.value !== 'notActive',
                   onConfirm: async () => {
                     if (record.state.value === 'notActive') {
-                      await service.remove(record.id);
-                      onlyMessage(
-                        intl.formatMessage({
-                          id: 'pages.data.option.success',
-                          defaultMessage: '操作成功!',
-                        }),
-                      );
-                      actionRef.current?.reload();
+                      const resp: any = await service.remove(record.id);
+                      if (resp.code === 200) {
+                        onlyMessage(
+                          intl.formatMessage({
+                            id: 'pages.data.option.success',
+                            defaultMessage: '操作成功!',
+                          }),
+                        );
+                        actionRef.current?.reload();
+                      }
                     } else {
                       onlyMessage(
                         intl.formatMessage({ id: 'pages.device.instance.deleteTip' }),

+ 8 - 8
src/pages/link/Type/index.tsx

@@ -325,6 +325,7 @@ const Network = () => {
               </PermissionButton>,
               <PermissionButton
                 type="link"
+                key="other-delete"
                 style={{ padding: 0 }}
                 isPermission={networkPermission.delete}
                 disabled={record.state.value === 'enabled'}
@@ -337,19 +338,18 @@ const Network = () => {
                         })
                       : '请先禁用该组件,再删除。',
                 }}
-              >
-                <Popconfirm
-                  title="确认删除?"
-                  onConfirm={async () => {
+                popConfirm={{
+                  title: '确认删除?',
+                  onConfirm: async () => {
                     const response: any = await service.remove(record.id);
                     if (response.status === 200) {
                       onlyMessage('删除成功');
                       actionRef.current?.reload();
                     }
-                  }}
-                >
-                  <DeleteOutlined />
-                </Popconfirm>
+                  },
+                }}
+              >
+                <DeleteOutlined />
               </PermissionButton>,
             ]}
           />

+ 4 - 2
src/pages/rule-engine/Scene/Save/index.tsx

@@ -150,7 +150,8 @@ export default () => {
         <>
           <InputNumber
             value={shakeLimit.time}
-            min={0}
+            min={1}
+            max={100}
             onChange={(e: number) => {
               const newShake = {
                 ...shakeLimit,
@@ -162,7 +163,8 @@ export default () => {
           <span> 秒内发生 </span>
           <InputNumber
             value={shakeLimit.threshold}
-            min={0}
+            min={1}
+            max={100}
             onChange={(e: number) => {
               const newShake = {
                 ...shakeLimit,