Explorar el Código

fix: 修改数据采集

100011797 hace 3 años
padre
commit
516203d0fa

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

@@ -8,6 +8,7 @@ import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage, testDomain, testIP, testIPv6 } from '@/utils/util';
 import { action } from '@formily/reactive';
+import { RadioCard } from '@/components';
 
 interface Props {
   data: Partial<ChannelItem>;
@@ -17,7 +18,7 @@ interface Props {
 
 export default (props: Props) => {
   const [data, setData] = useState<Partial<ChannelItem>>(props.data);
-  // const [loading, setLoading] = useState<boolean>(false);
+  const [authTypeList, setAuthTypeList] = useState<any[]>([]);
 
   useEffect(() => {
     if (props.data?.id) {
@@ -27,6 +28,18 @@ export default (props: Props) => {
         }
       });
     }
+    service.queryAuthTypeList({}).then((resp) => {
+      if (resp.status === 200) {
+        setAuthTypeList(
+          (resp.result || []).map((item: any) => {
+            return {
+              label: item.text,
+              value: item.value,
+            };
+          }),
+        );
+      }
+    });
   }, [props.data]);
 
   const form = createForm({
@@ -35,7 +48,6 @@ export default (props: Props) => {
   });
 
   const getSecurityPolicyList = () => service.querySecurityPolicyList({});
-  const getAuthTypeList = () => service.queryAuthTypeList({});
   const getSecurityModesList = () => service.querySecurityModesList({});
   const getCertificateList = () => service.queryCertificateList({});
 
@@ -60,6 +72,7 @@ export default (props: Props) => {
       NumberPicker,
       Password,
       FormGrid,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -126,8 +139,8 @@ export default (props: Props) => {
             },
             'x-disabled': props.data?.id,
             enum: [
-              { label: 'OPC_UA', value: 'OPC_UA' },
-              { label: 'MODBUS_TCP', value: 'MODBUS_TCP' },
+              { label: 'OPC UA', value: 'OPC_UA' },
+              { label: 'MODBUS TCP', value: 'MODBUS_TCP' },
             ],
             'x-validator': [
               {
@@ -314,12 +327,19 @@ export default (props: Props) => {
           },
           'configuration.authType': {
             title: '权限认证',
-            'x-component': 'Select',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
+              model: 'singular',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+              },
               placeholder: '请选择权限认证',
             },
             'x-validator': [
@@ -329,12 +349,24 @@ export default (props: Props) => {
               },
             ],
             'x-reactions': [
-              '{{useAsyncDataSource(getAuthTypeList)}}',
+              // '{{useAsyncDataSource(getAuthTypeList)}}',
               {
                 dependencies: ['..provider'],
                 fulfill: {
                   state: {
                     visible: '{{$deps[0]==="OPC_UA"}}',
+                    componentProps: {
+                      model: 'singular',
+                      itemStyle: {
+                        display: 'flex',
+                        flexDirection: 'column',
+                        justifyContent: 'space-around',
+                        minWidth: '130px',
+                        height: '50px',
+                      },
+                      placeholder: '请选择权限认证',
+                      options: [...authTypeList],
+                    },
                   },
                 },
               },
@@ -459,7 +491,7 @@ export default (props: Props) => {
           scope={{
             useAsyncDataSource,
             getSecurityPolicyList,
-            getAuthTypeList,
+            // getAuthTypeList,
             getSecurityModesList,
             getCertificateList,
           }}

+ 18 - 8
src/pages/link/DataCollect/components/Device/Save/index.tsx

@@ -7,6 +7,7 @@ import { Form, FormGrid, FormItem, Input, Select, NumberPicker, Password } from
 import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage } from '@/utils/util';
+import { RadioCard } from '@/components';
 
 interface Props {
   channelId?: string;
@@ -56,6 +57,7 @@ export default (props: Props) => {
       NumberPicker,
       Password,
       FormGrid,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -124,21 +126,29 @@ export default (props: Props) => {
             ],
           },
           'circuitBreaker.type': {
-            title: '处理方式',
-            'x-component': 'Select',
+            title: '故障处理',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
-              placeholder: '请选择处理方式',
+              placeholder: '请选择故障处理',
+              model: 'singular',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+                height: '50px',
+              },
+              options: [
+                { label: '降频', value: 'LowerFrequency' },
+                { label: '熔断', value: 'Break' },
+                { label: '忽略', value: 'Ignore' },
+              ],
             },
             default: 'LowerFrequency',
-            enum: [
-              { label: '降频', value: 'LowerFrequency' },
-              { label: '熔断', value: 'Break' },
-              { label: '忽略', value: 'Ignore' },
-            ],
             'x-validator': [
               {
                 required: true,

+ 16 - 7
src/pages/link/DataCollect/components/Point/Save/modbus.tsx

@@ -17,6 +17,7 @@ import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage } from '@/utils/util';
 import { action } from '@formily/reactive';
+import { RadioCard } from '@/components';
 
 interface Props {
   data: Partial<PointItem>;
@@ -49,6 +50,7 @@ export default (props: Props) => {
       Password,
       FormGrid,
       Checkbox,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -260,20 +262,27 @@ export default (props: Props) => {
           accessModes: {
             title: '访问类型',
             type: 'array',
-            'x-component': 'Select',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
               placeholder: '请选择访问类型',
-              mode: 'multiple',
+              model: 'multiple',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+                height: '50px',
+              },
+              options: [
+                { label: '读', value: 'read' },
+                { label: '写', value: 'write' },
+                { label: '订阅', value: 'subscribe' },
+              ],
             },
-            enum: [
-              { label: '读', value: 'read' },
-              { label: '写', value: 'write' },
-              { label: '订阅', value: 'subscribe' },
-            ],
             'x-validator': [
               {
                 required: true,

+ 17 - 8
src/pages/link/DataCollect/components/Point/Save/opc-ua.tsx

@@ -17,6 +17,7 @@ import type { ISchema } from '@formily/json-schema';
 import service from '@/pages/link/DataCollect/service';
 import { onlyMessage } from '@/utils/util';
 import { action } from '@formily/reactive';
+import { RadioCard } from '@/components';
 
 interface Props {
   data: Partial<PointItem>;
@@ -50,6 +51,7 @@ export default (props: Props) => {
       Password,
       FormGrid,
       Checkbox,
+      RadioCard,
     },
     scope: {
       icon(name: any) {
@@ -145,20 +147,27 @@ export default (props: Props) => {
           accessModes: {
             title: '访问类型',
             type: 'array',
-            'x-component': 'Select',
+            'x-component': 'RadioCard',
             'x-decorator': 'FormItem',
             'x-decorator-props': {
               gridSpan: 2,
             },
             'x-component-props': {
               placeholder: '请选择访问类型',
-              mode: 'multiple',
+              model: 'multiple',
+              itemStyle: {
+                display: 'flex',
+                flexDirection: 'column',
+                justifyContent: 'space-around',
+                minWidth: '130px',
+                height: '50px',
+              },
+              options: [
+                { label: '读', value: 'read' },
+                { label: '写', value: 'write' },
+                { label: '订阅', value: 'subscribe' },
+              ],
             },
-            enum: [
-              { label: '读', value: 'read' },
-              { label: '写', value: 'write' },
-              { label: '订阅', value: 'subscribe' },
-            ],
             'x-validator': [
               {
                 required: true,
@@ -175,7 +184,7 @@ export default (props: Props) => {
             },
             default: 3000,
             'x-reactions': {
-              dependencies: ['.accessModes'],
+              dependencies: ['..accessModes'],
               fulfill: {
                 state: {
                   visible: '{{($deps[0] || []).includes("subscribe")}}',

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

@@ -159,7 +159,7 @@ export default observer((props: Props) => {
                   key="button"
                   type="primary"
                 >
-                  新增
+                  {props?.provider === 'OPC_UA' ? '扫描' : '新增'}
                 </PermissionButton>
               </div>
             )}