Sfoglia il codice sorgente

fix: automaticLayout: true

100011797 3 anni fa
parent
commit
225b135230

+ 1 - 1
src/components/FMonacoEditor/index.tsx

@@ -47,7 +47,7 @@ export const JMonacoEditor = (props: Props) => {
             }
           }}
           {...props}
-          options={{ wordWrap: 'on' }}
+          options={{ wordWrap: 'on', automaticLayout: true }}
           editorDidMount={editorDidMountHandle}
         />
       )}

+ 1 - 0
src/pages/DataCollect/Collector/components/Device/Save/index.tsx

@@ -127,6 +127,7 @@ export default (props: Props) => {
             'x-component-props': {
               placeholder: '请选择所属通道',
             },
+            'x-disabled': !!props.data?.id,
             'x-validator': [
               {
                 required: true,

+ 2 - 2
src/pages/DataCollect/Collector/components/Device/index.tsx

@@ -415,8 +415,8 @@ export default observer((props: Props) => {
       {CollectorModel.visible && (
         <Save
           data={CollectorModel.current}
-          channelId={props.id}
-          provider={props.provider || CollectorModel.current?.provider}
+          // channelId={props.id}
+          // provider={props.provider || CollectorModel.current?.provider}
           close={() => {
             CollectorModel.visible = false;
           }}

+ 68 - 56
src/pages/DataCollect/Collector/components/Point/CollectorCard/WritePoint.tsx

@@ -34,62 +34,74 @@ const WritePoint = (props: Props) => {
       createForm({
         effects() {
           onFormInit((f) => {
-            let valueType: string =
-              props.data?.provider === 'OPC_UA'
-                ? props?.data?.configuration?.type || 'Number'
-                : props.data?.configuration?.codec?.provider || 'int8';
-            valueType = valueType.toLocaleLowerCase();
-            switch (valueType) {
-              case 'boolean':
-                f.setFieldState('propertyValue', async (state) => {
-                  state.dataSource = [
-                    {
-                      label: '是',
-                      value: true,
-                    },
-                    {
-                      label: '否',
-                      value: false,
-                    },
-                  ];
-                  state.componentProps = {
-                    placeholder: '请选择',
-                  };
-                  state.componentType = 'Select';
-                });
-                break;
-              case 'int8':
-              case 'int16':
-              case 'int32':
-              case 'int64':
-              case 'ieee754_float':
-              case 'ieee754_double':
-              case 'hex':
-              case 'number':
-                f.setFieldState('propertyValue', (state) => {
-                  state.componentType = 'NumberPicker';
-                  state.componentProps = {
-                    placeholder: '请输入',
-                  };
-                });
-                break;
-              case 'date':
-                f.setFieldState('propertyValue', (state) => {
-                  state.componentType = 'DatePicker';
-                  state.componentProps = {
-                    placeholder: '请选择',
-                    format: 'YYYY-MM-DD HH:mm:ss',
-                  };
-                });
-                break;
-              default:
-                f.setFieldState('propertyValue', (state) => {
-                  state.componentType = 'Input';
-                  state.componentProps = {
-                    placeholder: '请输入',
-                  };
-                });
-                break;
+            if (
+              props.data?.provider === 'MODBUS_TCP' &&
+              props.data?.configuration.function === 'Coils'
+            ) {
+              f.setFieldState('propertyValue', (state) => {
+                state.componentType = 'Input.TextArea';
+                state.componentProps = {
+                  placeholder: '请输入',
+                };
+              });
+            } else {
+              let valueType: string =
+                props.data?.provider === 'OPC_UA'
+                  ? props?.data?.configuration?.type || 'Number'
+                  : props.data?.configuration?.codec?.provider || 'int8';
+              valueType = valueType.toLocaleLowerCase();
+              switch (valueType) {
+                case 'boolean':
+                  f.setFieldState('propertyValue', async (state) => {
+                    state.dataSource = [
+                      {
+                        label: '是',
+                        value: true,
+                      },
+                      {
+                        label: '否',
+                        value: false,
+                      },
+                    ];
+                    state.componentProps = {
+                      placeholder: '请选择',
+                    };
+                    state.componentType = 'Select';
+                  });
+                  break;
+                case 'int8':
+                case 'int16':
+                case 'int32':
+                case 'int64':
+                case 'ieee754_float':
+                case 'ieee754_double':
+                case 'hex':
+                case 'number':
+                  f.setFieldState('propertyValue', (state) => {
+                    state.componentType = 'NumberPicker';
+                    state.componentProps = {
+                      placeholder: '请输入',
+                    };
+                  });
+                  break;
+                case 'date':
+                  f.setFieldState('propertyValue', (state) => {
+                    state.componentType = 'DatePicker';
+                    state.componentProps = {
+                      placeholder: '请选择',
+                      format: 'YYYY-MM-DD HH:mm:ss',
+                    };
+                  });
+                  break;
+                default:
+                  f.setFieldState('propertyValue', (state) => {
+                    state.componentType = 'Input';
+                    state.componentProps = {
+                      placeholder: '请输入',
+                    };
+                  });
+                  break;
+              }
             }
           });
         },

+ 18 - 10
src/pages/DataCollect/Collector/components/Tree/index.tsx

@@ -48,13 +48,17 @@ export default observer((props: Props) => {
       .queryCollector({ ...params, paging: false, sorts: [{ name: 'createTime', order: 'desc' }] })
       .then((resp) => {
         if (resp.status === 200) {
-          TreeModel.dataSource = [
-            {
-              id: '*',
-              name: '全部',
-              children: resp.result,
-            },
-          ];
+          if (params.terms) {
+            TreeModel.dataSource = resp.result;
+          } else {
+            TreeModel.dataSource = [
+              {
+                id: '*',
+                name: '全部',
+                children: resp.result,
+              },
+            ];
+          }
           props.change(TreeModel.dataSource[0]);
         }
         TreeModel.loading = false;
@@ -95,9 +99,13 @@ export default observer((props: Props) => {
           placeholder="请输入名称"
           allowClear
           onSearch={(val) => {
-            TreeModel.param = {
-              terms: [{ column: 'name', value: `%${val}%`, termType: 'like' }],
-            };
+            if (val) {
+              TreeModel.param = {
+                terms: [{ column: 'name', value: `%${val}%`, termType: 'like' }],
+              };
+            } else {
+              TreeModel.param = {};
+            }
           }}
           style={{ width: '100%' }}
         />

+ 4 - 0
src/pages/device/Instance/Detail/Functions/AdvancedMode.tsx

@@ -86,6 +86,10 @@ export default (props: FunctionProps) => {
     handleData(props.data);
   }, [props.data]);
 
+  useEffect(() => {
+    monacoRef.current?.layout();
+  });
+
   return (
     <div className="device-function-content">
       <div className="left">

+ 9 - 7
src/pages/device/Instance/Detail/MetadataLog/Property/index.tsx

@@ -15,7 +15,7 @@ import type { PropertyMetadata } from '@/pages/device/Product/typings';
 import encodeQuery from '@/utils/encodeQuery';
 import { useEffect, useState } from 'react';
 import moment from 'moment';
-import FileComponent from '../../Running/Property/FileComponent';
+import FileComponent, { getType } from '../../Running/Property/FileComponent';
 import { DownloadOutlined, SearchOutlined } from '@ant-design/icons';
 import Detail from './Detail';
 import AMap from './AMap';
@@ -69,22 +69,24 @@ const PropertyLog = (props: Props) => {
       dataIndex: 'action',
       key: 'action',
       render: (text: any, record: any) => [
-        data.valueType?.type === 'file' ? (
+        (data.valueType?.type === 'file' && data?.valueType?.fileType === 'Binary(二进制)') ||
+        (!getType(record?.value) && data?.valueType?.fileType === 'base64') ? (
           <a style={{ marginRight: 20 }}>
             <ATooltip title="下载">
               <DownloadOutlined
                 onClick={() => {
-                  const type = (record?.value || '').split('.').pop();
-                  const downloadUrl = record.value;
                   const downNode = document.createElement('a');
-                  downNode.href = downloadUrl;
-                  downNode.target = '_blank';
                   downNode.download = `${InstanceModel.detail.name}-${data.name}${moment(
                     new Date().getTime(),
-                  ).format('YYYY-MM-DD-HH-mm-ss')}.${type}`;
+                  ).format('YYYY-MM-DD-HH-mm-ss')}.txt`;
                   downNode.style.display = 'none';
+                  //字符串内容转成Blob地址
+                  const blob = new Blob([record.value]);
+                  downNode.href = URL.createObjectURL(blob);
+                  //触发点击
                   document.body.appendChild(downNode);
                   downNode.click();
+                  //移除
                   document.body.removeChild(downNode);
                 }}
               />

+ 56 - 23
src/pages/device/Instance/Detail/Running/Property/FileComponent/index.tsx

@@ -25,6 +25,27 @@ imgMap.set('video', require('/public/images/running/video.png'));
 imgMap.set('other', require('/public/images/running/other.png'));
 imgMap.set('obj', require('/public/images/running/obj.png'));
 
+const imgList = ['.jpg', '.png', '.swf', '.tiff'];
+const videoList = ['.m3u8', '.flv', '.mp4', '.rmvb', '.mvb'];
+const fileList = ['.txt', '.doc', '.xls', '.pdf', '.ppt', '.docx', '.xlsx', '.pptx'];
+
+export const getType = (url: string) => {
+  let t: string = '';
+  [...imgList, ...videoList, ...fileList].map((item) => {
+    const str = item.slice(1, item.length);
+    if (url.indexOf(str) !== -1) {
+      if (imgList.includes(item)) {
+        t = 'img';
+      } else if (videoList.includes(item)) {
+        t = 'video';
+      } else {
+        t = str;
+      }
+    }
+  });
+  return t;
+};
+
 const FileComponent = (props: Props) => {
   const { data, value } = props;
   const [type, setType] = useState<string>('other');
@@ -33,7 +54,7 @@ const FileComponent = (props: Props) => {
   const [temp, setTemp] = useState<boolean>(false);
 
   const renderFile = () => {
-    if (['.jpg', '.png', '.swf', '.tiff'].some((item) => value?.formatValue.includes(item))) {
+    if (imgList.some((item) => value?.formatValue.includes(item))) {
       // 图片
       return (
         <div
@@ -61,9 +82,7 @@ const FileComponent = (props: Props) => {
         </div>
       );
     }
-    if (
-      ['.m3u8', '.flv', '.mp4', '.rmvb', '.mvb'].some((item) => value?.formatValue.includes(item))
-    ) {
+    if (videoList.some((item) => value?.formatValue.includes(item))) {
       return (
         <div
           className={props.type === 'card' ? styles.cardValue : styles.otherValue}
@@ -83,15 +102,8 @@ const FileComponent = (props: Props) => {
           <img src={imgMap.get('video')} />
         </div>
       );
-    } else if (
-      ['.txt', '.doc', '.xls', '.pdf', '.ppt', '.docx', '.xlsx', '.pptx'].some((item) =>
-        value?.formatValue.includes(item),
-      )
-    ) {
-      const flag =
-        ['.txt', '.doc', '.xls', '.pdf', '.ppt', '.docx', '.xlsx', '.pptx'].find((item) =>
-          value?.formatValue.includes(item),
-        ) || '--';
+    } else if (fileList.some((item) => value?.formatValue.includes(item))) {
+      const flag = fileList.find((item) => value?.formatValue.includes(item)) || '--';
       return (
         <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
           <img src={imgMap.get(flag.slice(1))} />
@@ -106,6 +118,28 @@ const FileComponent = (props: Props) => {
     }
   };
 
+  const base64Render = () => {
+    const _type = getType(value?.formatValue);
+    if (!!_type) {
+      return (
+        <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
+          <img
+            src={imgMap.get(_type)}
+            onError={(e: any) => {
+              e.target.src = imgMap.get('other');
+            }}
+          />
+        </div>
+      );
+    } else {
+      return (
+        <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
+          <img src={imgMap.get('other')} />
+        </div>
+      );
+    }
+  };
+
   const renderValue = () => {
     if (value?.formatValue !== 0 && !value?.formatValue) {
       return (
@@ -116,16 +150,15 @@ const FileComponent = (props: Props) => {
         data?.valueType?.fileType === 'base64' ||
         data?.valueType?.fileType === 'Binary(二进制)'
       ) {
-        return (
-          <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
-            <img
-              src={value?.formatValue}
-              onError={(e: any) => {
-                e.target.src = imgMap.get('other');
-              }}
-            />
-          </div>
-        );
+        if (data?.valueType?.fileType === 'base64') {
+          return base64Render();
+        } else {
+          return (
+            <div className={props.type === 'card' ? styles.cardValue : styles.otherValue}>
+              <img src={imgMap.get('other')} />
+            </div>
+          );
+        }
       } else {
         return renderFile();
       }

+ 1 - 1
src/pages/link/AccessConfig/service.ts

@@ -27,7 +27,7 @@ class Service extends BaseService<AccessItem> {
       method: 'GET',
     });
   public getNetworkList = (networkType: string, params?: any) =>
-    request(`/${SystemConst.API_BASE}/network/config/${networkType}/_detail`, {
+    request(`/${SystemConst.API_BASE}/network/config/${networkType}/_alive`, {
       method: 'GET',
       params,
     });