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

feat(merge): merge wzy

Next wzy
Lind 3 лет назад
Родитель
Сommit
82432ebaa2

+ 1 - 1
config/routes.ts

@@ -25,7 +25,7 @@
           {
             name: 'bind',
             path: '/account/center/bind',
-            component: './account/Center/Bind',
+            component: './account/Center/bind',
           },
         ],
       },

+ 15 - 10
src/pages/device/Instance/Detail/Opcua/index.tsx

@@ -1,6 +1,6 @@
 import PermissionButton from '@/components/PermissionButton';
 import { Badge, Card, Empty, message, Tabs, Tooltip } from 'antd';
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
 import { useIntl } from 'umi';
 import styles from '@/pages/link/Channel/Opcua/Access/index.less';
 import ProTable, { ActionType, ProColumns } from '@jetlinks/pro-table';
@@ -181,6 +181,19 @@ const Opcua = () => {
       });
   };
 
+  const edit = useMemo(
+    () => (
+      <Save
+        data={channel}
+        close={() => {
+          setVisible(false);
+        }}
+        device={InstanceModel.detail}
+      />
+    ),
+    [channel.id],
+  );
+
   useEffect(() => {
     const { id } = InstanceModel.detail;
     setDeviceId(id);
@@ -342,15 +355,7 @@ const Opcua = () => {
       ) : (
         <Empty />
       )}
-      {visible && (
-        <Save
-          data={channel}
-          close={() => {
-            setVisible(false);
-          }}
-          device={InstanceModel.detail}
-        />
-      )}
+      {visible && edit}
       {pointVisiable && (
         <AddPoint
           deviceId={deviceId}

+ 9 - 17
src/pages/link/Channel/Modbus/Access/addPoint/index.tsx

@@ -60,6 +60,7 @@ const AddPoint = (props: Props) => {
             ...props.data?.codecConfig,
             readIndex: props.data?.codecConfig?.readIndex || 0,
             scaleFactor: props.data?.codecConfig?.scaleFactor || 1,
+            revertBytes: props.data?.codecConfig?.revertBytes || false,
           },
         }}
       >
@@ -139,23 +140,14 @@ const AddPoint = (props: Props) => {
             </Form.Item>
           </Col>
           <Col span={12}>
-            <Form.Item
-              label="读取长度"
-              name={['codecConfig', 'readLength']}
-              required
-              rules={[
-                { required: true, message: '请输入读取长度' },
-                ({}) => ({
-                  validator(_, value) {
-                    if (value !== 0 || /(^[1-9]\d*$)/.test(value)) {
-                      return Promise.resolve();
-                    }
-                    return Promise.reject(new Error('请输入正整数'));
-                  },
-                }),
-              ]}
-            >
-              <InputNumber style={{ width: '100%' }} placeholder="请输入" min={1} />
+            <Form.Item label="读取长度" name={['codecConfig', 'readLength']} required>
+              <Select placeholder="请选择">
+                <Select.Option value={1}>1</Select.Option>
+                <Select.Option value={2}>2</Select.Option>
+                <Select.Option value={3}>3</Select.Option>
+                <Select.Option value={4}>4</Select.Option>
+                <Select.Option value={8}>8</Select.Option>
+              </Select>
             </Form.Item>
           </Col>
         </Row>

+ 12 - 8
src/pages/link/Channel/Opcua/Save/index.tsx

@@ -6,7 +6,7 @@ import type { ISchema } from '@formily/json-schema';
 import { service } from '@/pages/link/Channel/Opcua';
 import { Modal } from '@/components';
 import { message } from 'antd';
-import { useEffect, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
 
 interface Props {
   data: Partial<OpaUa>;
@@ -19,13 +19,17 @@ const Save = (props: Props) => {
   const [policies, setPolicies] = useState<any>([]);
   const [modes, setModes] = useState<any>([]);
 
-  const form = createForm({
-    validateFirst: true,
-    initialValues: {
-      ...props.data,
-      clientConfigs: props.data?.clientConfigs?.[0],
-    },
-  });
+  const form = useMemo(
+    () =>
+      createForm({
+        validateFirst: true,
+        initialValues: {
+          ...props.data,
+          clientConfigs: props.data?.clientConfigs?.[0],
+        },
+      }),
+    [props.data.id],
+  );
 
   const SchemaField = createSchemaField({
     components: {