100011797 3 лет назад
Родитель
Сommit
d83e108c84

+ 1 - 1
src/components/ProTableCard/CardItems/DataCollect/device.tsx

@@ -53,7 +53,7 @@ export default (props: CollectorCardProps) => {
             </div>
             <div>
               <label>所属通道</label>
-              <Ellipsis title={props?.channelName || ''} />
+              <Ellipsis title={props?.channelName || props?.channelId || ''} />
             </div>
           </div>
         </div>

+ 2 - 1
src/pages/link/DataCollect/components/Channel/Save/index.tsx

@@ -319,7 +319,7 @@ export default (props: Props) => {
                 dependencies: ['.securityMode'],
                 fulfill: {
                   state: {
-                    visible: '{{$deps[0]==="SingAndEncrypt" || $deps[0]==="Sign"}}',
+                    visible: '{{$deps[0]==="SignAndEncrypt" || $deps[0]==="Sign"}}',
                   },
                 },
               },
@@ -332,6 +332,7 @@ export default (props: Props) => {
             'x-decorator-props': {
               gridSpan: 2,
             },
+            default: 'anonymous',
             'x-component-props': {
               model: 'singular',
               itemStyle: {

+ 5 - 7
src/pages/link/DataCollect/components/Channel/index.tsx

@@ -39,9 +39,10 @@ export default observer((props: Props) => {
   });
 
   const test = (value: string) => {
-    // (value) => ({ name$LIKE: value })
-    console.log(value);
-    return { runningState: value };
+    if (value === 'error') {
+      return '';
+    }
+    return value;
   };
 
   const columns: ProColumns<ChannelItem>[] = [
@@ -187,10 +188,7 @@ export default observer((props: Props) => {
                             //     : undefined
                             // }
                             popConfirm={{
-                              title: intl.formatMessage({
-                                id: 'pages.data.option.remove.tips',
-                                defaultMessage: '是否删除?',
-                              }),
+                              title: '该操作将会删除下属采集器与点位,确定删除?',
                               onConfirm: async () => {
                                 await service.removeChannel(record.id);
                                 onlyMessage(

+ 63 - 35
src/pages/link/DataCollect/components/Device/index.tsx

@@ -41,42 +41,72 @@ export default observer((props: Props) => {
     total: 0,
   });
 
-  const columns: ProColumns<CollectorItem>[] = [
-    {
-      title: '名称',
-      dataIndex: 'name',
-    },
-    {
-      title: '通讯协议',
-      dataIndex: 'provider',
-      valueType: 'select',
-      valueEnum: {
-        OPC_UA: {
-          text: 'OPC_UA',
-          status: 'OPC_UA',
+  const columns: ProColumns<CollectorItem>[] = props.type
+    ? [
+        {
+          title: '名称',
+          dataIndex: 'name',
         },
-        MODBUS_TCP: {
-          text: 'MODBUS_TCP',
-          status: 'MODBUS_TCP',
+        {
+          title: '通讯协议',
+          dataIndex: 'provider',
+          valueType: 'select',
+          valueEnum: {
+            OPC_UA: {
+              text: 'OPC_UA',
+              status: 'OPC_UA',
+            },
+            MODBUS_TCP: {
+              text: 'MODBUS_TCP',
+              status: 'MODBUS_TCP',
+            },
+          },
+        },
+        {
+          title: '状态',
+          dataIndex: 'state',
+          valueType: 'select',
+          valueEnum: {
+            enabled: {
+              text: '正常',
+              status: 'enabled',
+            },
+            disabled: {
+              text: '禁用',
+              status: 'disabled',
+            },
+          },
+        },
+        {
+          title: '说明',
+          dataIndex: 'description',
         },
-      },
-    },
-    {
-      title: '状态',
-      dataIndex: 'state',
-      valueType: 'select',
-      valueEnum: {
-        enabled: {
-          text: '正常',
-          status: 'enabled',
+      ]
+    : [
+        {
+          title: '名称',
+          dataIndex: 'name',
         },
-        disabled: {
-          text: '禁用',
-          status: 'disabled',
+        {
+          title: '状态',
+          dataIndex: 'state',
+          valueType: 'select',
+          valueEnum: {
+            enabled: {
+              text: '正常',
+              status: 'enabled',
+            },
+            disabled: {
+              text: '禁用',
+              status: 'disabled',
+            },
+          },
+        },
+        {
+          title: '说明',
+          dataIndex: 'description',
         },
-      },
-    },
-  ];
+      ];
   const handleSearch = (params: any) => {
     setLoading(true);
     setParam(params);
@@ -213,9 +243,7 @@ export default observer((props: Props) => {
                             }
                             disabled={record?.state?.value !== 'disabled'}
                             popConfirm={{
-                              title: intl.formatMessage({
-                                id: 'pages.data.option.remove.tips',
-                              }),
+                              title: '该操作将会删除下属点位,确定删除?',
                               disabled: record?.state?.value !== 'disabled',
                               onConfirm: async () => {
                                 if (record?.state?.value === 'disabled') {

+ 64 - 24
src/pages/link/DataCollect/components/Point/Save/modbus.tsx

@@ -83,7 +83,7 @@ export default (props: Props) => {
           message: '最多可输入64个字符',
         };
       }
-      if (!(value % 1 === 0)) {
+      if (!(Number(value) % 1 === 0) || Number(value) <= 0) {
         return {
           type: 'error',
           message: '请输入非0正整数',
@@ -91,6 +91,24 @@ export default (props: Props) => {
       }
       return '';
     },
+    checkScaleFactor(value) {
+      if (String(value).length > 64) {
+        return {
+          type: 'error',
+          message: '最多可输入64个字符',
+        };
+      }
+      return '';
+    },
+    checkAddressLength(value) {
+      if (!(Number(value) % 1 === 0)) {
+        return {
+          type: 'error',
+          message: '请输入0~255之间的正整数',
+        };
+      }
+      return '';
+    },
   });
 
   const schema: ISchema = {
@@ -139,7 +157,7 @@ export default (props: Props) => {
             enum: [
               { label: '线圈寄存器', value: 'Coils' },
               { label: '保存寄存器', value: 'HoldingRegisters' },
-              { label: '输入寄存器', value: 'InputRegisters' },
+              { label: '输入寄存器', value: 'DiscreteInputs' },
             ],
             'x-validator': [
               {
@@ -150,7 +168,7 @@ export default (props: Props) => {
           },
           'configuration.parameter.address': {
             title: '地址',
-            'x-component': 'Input',
+            'x-component': 'NumberPicker',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
@@ -172,7 +190,7 @@ export default (props: Props) => {
                 message: '请输入0-255之间的正整数',
               },
               {
-                checkLength: true,
+                checkAddressLength: true,
               },
             ],
           },
@@ -185,6 +203,15 @@ export default (props: Props) => {
             },
             'x-component-props': {
               placeholder: '请输入起始位置',
+              stringMode: true,
+            },
+            'x-reactions': {
+              dependencies: ['...function'],
+              fulfill: {
+                state: {
+                  visible: '{{$deps[0] === "HoldingRegisters"}}',
+                },
+              },
             },
             'x-validator': [
               {
@@ -192,7 +219,7 @@ export default (props: Props) => {
                 message: '请输入起始位置',
               },
               {
-                min: 0,
+                min: 1,
                 message: '请输入非0正整数',
               },
               {
@@ -209,14 +236,16 @@ export default (props: Props) => {
             },
             'x-component-props': {
               placeholder: '请输入寄存器数量',
+              stringMode: true,
             },
+            default: 1,
             'x-validator': [
               {
                 required: true,
                 message: '请输入寄存器数量',
               },
               {
-                min: 0,
+                min: 1,
                 message: '请输入非0正整数',
               },
               {
@@ -234,7 +263,17 @@ export default (props: Props) => {
             'x-component-props': {
               placeholder: '请选择数据类型',
             },
-            'x-reactions': '{{useAsyncDataSource(getCodecProvider)}}',
+            'x-reactions': [
+              '{{useAsyncDataSource(getCodecProvider)}}',
+              {
+                dependencies: ['..function'],
+                fulfill: {
+                  state: {
+                    visible: '{{$deps[0] === "HoldingRegisters"}}',
+                  },
+                },
+              },
+            ],
             'x-validator': [
               {
                 required: true,
@@ -252,12 +291,16 @@ export default (props: Props) => {
             default: 1,
             'x-component-props': {
               placeholder: '请输入缩放因子',
+              stringMode: true,
             },
             'x-validator': [
               {
                 required: true,
                 message: '请输入缩放因子',
               },
+              {
+                checkScaleFactor: true,
+              },
             ],
           },
           accessModes: {
@@ -281,7 +324,7 @@ export default (props: Props) => {
               options: [
                 { label: '读', value: 'read' },
                 { label: '写', value: 'write' },
-                { label: '订阅', value: 'subscribe' },
+                // { label: '订阅', value: 'subscribe' },
               ],
             },
             'x-validator': [
@@ -299,17 +342,10 @@ export default (props: Props) => {
               gridSpan: 2,
             },
             default: 3000,
-            'x-reactions': {
-              dependencies: ['..accessModes'],
-              fulfill: {
-                state: {
-                  visible: '{{($deps[0] || []).includes("subscribe")}}',
-                },
-              },
-            },
             'x-component-props': {
               placeholder: '请输入采集频率',
               addonAfter: '毫秒',
+              stringMode: true,
               style: {
                 width: '100%',
               },
@@ -320,6 +356,10 @@ export default (props: Props) => {
                 message: '请输入采集频率',
               },
               {
+                min: 1,
+                message: '请输入非0正整数',
+              },
+              {
                 checkLength: true,
               },
             ],
@@ -332,14 +372,14 @@ export default (props: Props) => {
             'x-decorator-props': {
               gridSpan: 2,
             },
-            'x-reactions': {
-              dependencies: ['.accessModes'],
-              fulfill: {
-                state: {
-                  visible: '{{($deps[0] || []).includes("subscribe")}}',
-                },
-              },
-            },
+            // 'x-reactions': {
+            //   dependencies: ['.accessModes'],
+            //   fulfill: {
+            //     state: {
+            //       visible: '{{($deps[0] || []).includes("subscribe")}}',
+            //     },
+            //   },
+            // },
             enum: [
               {
                 label: '只推送变化的数据',

+ 11 - 4
src/pages/link/DataCollect/components/Point/Save/scan.tsx

@@ -1,4 +1,4 @@
-import { Button, Empty, Modal, Spin, Transfer, Tree } from 'antd';
+import { Button, Empty, Modal, Popconfirm, Spin, Transfer, Tree } from 'antd';
 import type { TransferDirection } from 'antd/es/transfer';
 import { useEffect, useState } from 'react';
 import service from '@/pages/link/DataCollect/service';
@@ -152,13 +152,16 @@ const TreeTransfer = ({
                         <Ellipsis title={item?.title || item.key} />
                       </div>
                       <div style={{ width: 20, marginLeft: 10 }}>
-                        <CloseOutlined
-                          onClick={() => {
+                        <Popconfirm
+                          title={'确认删除?'}
+                          onConfirm={() => {
                             if (onItemRemove) {
                               onItemRemove([item.key]);
                             }
                           }}
-                        />
+                        >
+                          <CloseOutlined />
+                        </Popconfirm>
                       </div>
                     </div>
                   );
@@ -224,6 +227,10 @@ export default (props: Props) => {
           key={2}
           loading={spinning}
           onClick={async () => {
+            if (!arr.length) {
+              onlyMessage('请选择目标数据', 'error');
+              return;
+            }
             const list = arr.map((item) => {
               return {
                 id: item.key,

+ 4 - 0
src/pages/link/DataCollect/components/Point/index.tsx

@@ -78,6 +78,10 @@ export default observer((props: Props) => {
         },
       },
     },
+    {
+      title: '说明',
+      dataIndex: 'description',
+    },
   ];
 
   const subRef = useRef<any>(null);

+ 2 - 2
src/pages/link/DataCollect/components/Tree/index.tsx

@@ -64,7 +64,7 @@ export default observer((props: Props) => {
     <div>
       <div>
         <Input.Search
-          placeholder="搜索"
+          placeholder="请输入名称"
           allowClear
           onSearch={(val) => {
             TreeModel.param = {
@@ -122,7 +122,7 @@ export default observer((props: Props) => {
                             />
                           </Tooltip>
                           <Popconfirm
-                            title={'确认删除?'}
+                            title={'该操作将会删除下属采集器与点位,确定删除?'}
                             onConfirm={async () => {
                               const resp = await service.removeChannel(item.id);
                               if (resp.status === 200) {