hear пре 3 година
родитељ
комит
83bd61bbf1

+ 2 - 2
src/app.tsx

@@ -446,9 +446,9 @@ export function render(oldRender: any) {
         ],
       },
     ];
-    Service.settingDetail('api').then((res) => {
+    Service.settingDetail('amap').then((res) => {
       if (res && res.status === 200 && res.result) {
-        localStorage.setItem(SystemConst.AMAP_KEY, res.result.api);
+        localStorage.setItem(SystemConst.AMAP_KEY, res.result.apiKey);
       }
     });
     Service.getSystemVersion().then((resp) => {

+ 2 - 1
src/components/AMapComponent/amap.tsx

@@ -19,6 +19,7 @@ export default (props: AMapProps) => {
   const isOpenUi = 'AMapUI' in props || props.AMapUI;
 
   const amapKey = localStorage.getItem(SystemConst.AMAP_KEY);
+  console.log(amapKey);
 
   const getAMapUI = () => {
     const version = typeof props.AMapUI === 'string' ? props.AMapUI : '1.1';
@@ -36,7 +37,7 @@ export default (props: AMapProps) => {
     }
   };
 
-  console.log(isOpenUi, uiLoading);
+  // console.log(isOpenUi, uiLoading);
 
   return (
     <div style={style || { width: '100%', height: '100%' }} className={className}>

+ 1 - 0
src/components/ProTableCard/CardItems/DataCollect/channel.tsx

@@ -28,6 +28,7 @@ export default (props: ChannelCardProps) => {
       status={props.state?.value}
       statusText={props.state?.text}
       showMask={false}
+      showStatus={false}
       statusNames={{
         running: StatusColorEnum.success,
         disabled: StatusColorEnum.processing,

+ 14 - 9
src/pages/device/Instance/Detail/Running/Property/index.tsx

@@ -1,6 +1,6 @@
 import { Col, Empty, Input, Pagination, Row, Space, Spin, Table, Tooltip } from 'antd';
 import CheckButton from '@/components/CheckButton';
-import { useCallback, useEffect, useRef, useState } from 'react';
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
 import type { PropertyMetadata } from '@/pages/device/Product/typings';
 import PropertyCard from './PropertyCard';
 import {
@@ -229,6 +229,18 @@ const Property = (props: Props) => {
     });
   };
 
+  const memo = useMemo(
+    () => (
+      <EditProperty
+        data={currentInfo}
+        onCancel={() => {
+          setVisible(false);
+        }}
+      />
+    ),
+    [propertyValue],
+  );
+
   useEffect(() => {
     if (!loading1) {
       subscribeProperty();
@@ -352,14 +364,7 @@ const Property = (props: Props) => {
           </div>
         )}
       </Spin>
-      {visible && (
-        <EditProperty
-          data={currentInfo}
-          onCancel={() => {
-            setVisible(false);
-          }}
-        />
-      )}
+      {visible && memo}
       {infoVisible && <PropertyLog data={currentInfo} close={() => setInfoVisible(false)} />}
       {indicatorVisible && (
         <Indicators

+ 1 - 1
src/pages/device/Product/Detail/Access/AccessConfig/index.tsx

@@ -230,7 +230,7 @@ const AccessConfig = (props: Props) => {
         <Row gutter={[16, 16]}>
           {(dataSource?.data || []).map((item: any) => (
             <Col
-              key={item.name}
+              key={item.id}
               span={12}
               onClick={() => {
                 setCurrrent(item);

+ 1 - 1
src/pages/device/components/Metadata/Cat/index.tsx

@@ -71,7 +71,7 @@ const Cat = observer((props: Props) => {
             type="primary"
             onClick={async () => {
               try {
-                downloadObject(JSON.parse(value), `设备-物模型`);
+                downloadObject(JSON.parse(value), `设备-物模型`, 'YYYY/MM/DD');
               } catch (e) {
                 message.error('物模型格式错误!');
               }

+ 2 - 2
src/pages/home/comprehensive/index.tsx

@@ -46,7 +46,7 @@ const Comprehensive = () => {
       setProductCount(resp.result);
     }
     if (resp.status === 403) {
-      setProductMessage('暂无产品权限');
+      setProductMessage('暂无权限');
     }
   };
 
@@ -56,7 +56,7 @@ const Comprehensive = () => {
       setDeviceCount(resp.result);
     }
     if (resp.status === 403) {
-      setDeviceMessage('暂无设备权限');
+      setDeviceMessage('暂无权限');
     }
   };
 

+ 2 - 2
src/pages/home/device/index.tsx

@@ -30,7 +30,7 @@ const Device = () => {
       setProductCount(resp.result);
     }
     if (resp.status === 403) {
-      setProductMessage('暂无产品权限');
+      setProductMessage('暂无权限');
     }
   };
 
@@ -40,7 +40,7 @@ const Device = () => {
       setDeviceCount(resp.result);
     }
     if (resp.status === 403) {
-      setDeviceMessage('暂无设备权限');
+      setDeviceMessage('暂无权限');
     }
   };
 

+ 23 - 34
src/pages/link/Type/Detail/index.tsx

@@ -130,26 +130,14 @@ const Save = observer(() => {
             if (param?.id && param.id !== ':id') {
               const resp = await service.detail(param.id);
               const data = resp?.result || {};
-              // if (data?.shareCluster === false) {
-              //   const cluster = (data?.cluster || []).map((item: any) => {
-              //     return {
-              //       ...item.configuration,
-              //       configuration: item,
-              //     };
-              //   });
-              //   console.log(cluster, 'cluster')
-              //   const obj = _.cloneDeep({ ...data, cluster });
-              //   form1.setValues({ ...obj });
-              // }
               if (data?.shareCluster === false) {
-                const _cluster = _.cloneDeep(data.cluster[0]);
-                data.cluster[0] = {
-                  ..._cluster.configuration,
-                };
-                form1.setValues({ ...data });
-              } else {
-                form1.setValues({ ...data });
+                data.cluster = (data?.cluster || []).map((item: any) => {
+                  return {
+                    ...item.configuration,
+                  };
+                });
               }
+              form1.setValues({ ...data });
             }
           });
           onFieldValueChange('type', (field, f) => {
@@ -525,21 +513,21 @@ const Save = observer(() => {
             'x-decorator': 'FormItem',
             'x-component': 'Input',
           },
-          maxMessageSize: {
-            title: '最大消息长度',
-            'x-decorator-props': {
-              gridSpan: 1,
-              tooltip: '单次收发消息的最大长度,单位:字节;设置过大可能会影响性能',
-              layout: 'vertical',
-              labelAlign: 'left',
-            },
-            'x-component-props': {
-              placeholder: '请输入最大消息长度',
-            },
-            required: true,
-            'x-decorator': 'FormItem',
-            'x-component': 'Input',
-          },
+          // maxMessageSize: {
+          //   title: '最大消息长度',
+          //   'x-decorator-props': {
+          //     gridSpan: 1,
+          //     tooltip: '单次收发消息的最大长度,单位:字节;设置过大可能会影响性能',
+          //     layout: 'vertical',
+          //     labelAlign: 'left',
+          //   },
+          //   'x-component-props': {
+          //     placeholder: '请输入最大消息长度',
+          //   },
+          //   required: true,
+          //   'x-decorator': 'FormItem',
+          //   'x-component': 'Input',
+          // },
           topicPrefix: {
             title: '订阅前缀',
             'x-component-props': {
@@ -574,7 +562,8 @@ const Save = observer(() => {
           fulfill: {
             state: {
               // visible: '{{$deps[0]==="UDP"}}',
-              visible: '{{["MQTT_SERVER"].includes($deps[0])}}',
+              visible: '{{["MQTT_SERVER","MQTT_CLIENT"].includes($deps[0])}}',
+              // hidden:'{{["MQTT_SERVER"].includes($deps[0])}}'
             },
           },
         },

+ 8 - 3
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/TypeModel.tsx

@@ -95,10 +95,14 @@ export default observer((props: Props) => {
 
   useEffect(() => {
     setValue(props.value);
-    setLabelValue(props.label);
+    // setLabelValue(props.label);
     // console.log('typemodel', props.value);
   }, [props.value]);
 
+  useEffect(() => {
+    setLabelValue(props.label);
+  }, []);
+
   const renderNode = (type: string) => {
     switch (type) {
       case 'int':
@@ -126,11 +130,12 @@ export default observer((props: Props) => {
             fieldNames={{ label: 'text', value: 'value' }}
             placeholder={'请选择'}
             onChange={(e, options: any) => {
-              // console.log(options);
+              console.log(options?.text);
               setValue(e);
               setLabelValue(options?.text);
+              // DeviceModel.propertiesValue = options?.text
               if (props.onChange) {
-                props.onChange(e, source);
+                props.onChange(e, source, options?.text);
               }
               // onChange(e)
             }}

+ 13 - 5
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/WriteProperty.tsx

@@ -7,7 +7,7 @@ interface Props {
   properties: any[];
   value?: any;
   id?: string;
-  onChange?: (value?: any, text?: any) => void;
+  onChange?: (value?: any, text?: any, valueLable?: any) => void;
   propertiesChange?: (value?: string) => void;
   name?: any;
   onColumns?: (col: any, text?: any) => void;
@@ -25,6 +25,7 @@ export default (props: Props) => {
   const [format, setFormat] = useState<any>('HH:mm:ss');
   const [enumList, setEnumList] = useState<any>([]);
   const [label, setLabel] = useState<any>();
+  const ref = useRef<any>('');
 
   useEffect(() => {
     // console.log(props.value);
@@ -47,8 +48,8 @@ export default (props: Props) => {
                 console.log(propertiesItem.valueType.elements, props.value[key].value);
                 setEnumList(propertiesItem.valueType.elements);
                 const text = propertiesItem.valueType.elements.find(
-                  (item: any) => item.value === props.value[key].value?.[0],
-                ).text;
+                  (item: any) => item.value === props.value[key].value,
+                )?.text;
                 setLabel(text);
                 // console.log(text);
               }
@@ -69,7 +70,12 @@ export default (props: Props) => {
           source: source,
         },
       };
-      props.onChange(obj, textRef.current);
+      //处理枚举外部回显
+      if (ref.current) {
+        props.onChange(obj, textRef.current, ref.current);
+      } else {
+        props.onChange(obj, textRef.current);
+      }
     }
   }, [propertiesValue, source]);
 
@@ -119,8 +125,10 @@ export default (props: Props) => {
                 props.onColumns(col);
               }
             }}
-            onChange={(value, sources) => {
+            onChange={(value, sources, text) => {
               // console.log(value, sources);
+              console.log(text);
+              ref.current = text;
               setPropertiesValue(value);
               setSource(sources);
             }}

+ 7 - 2
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/index.tsx

@@ -193,10 +193,15 @@ export default observer((props: Props) => {
                 DeviceModel.actionName = text;
                 // console.log(text)
               }}
-              onChange={(value, text) => {
+              onChange={(value, text, valueLable) => {
                 const item = value[Object.keys(value)?.[0]]?.value;
+                // console.log(`valueLable`,valueLable)
                 DeviceModel.propertiesName = text;
-                DeviceModel.propertiesValue = item;
+                if (valueLable) {
+                  DeviceModel.propertiesValue = valueLable;
+                } else {
+                  DeviceModel.propertiesValue = item;
+                }
               }}
               onRest={(value: any) => {
                 form.setFieldValue(['message', 'properties'], {

+ 1 - 1
src/pages/rule-engine/Scene/Save/action/DeviceOutput/index.tsx

@@ -140,7 +140,7 @@ export default observer((props: Props) => {
       }));
       // console.log(_options.taglist, 'taglist')
     }
-    // console.log(item,_options);
+    // console.log(DeviceModel.propertiesValue,_options);
     props.save(item, _options);
     init();
   };

+ 5 - 5
src/pages/system/Basis/index.tsx

@@ -23,10 +23,10 @@ const Basis = () => {
       const basis = res.result?.filter((item: any) => item.scope === 'front');
       const api = res.result?.filter((item: any) => item.scope === 'amap');
       const basePath = res.result?.filter((item: any) => item.scope === 'paths');
-      localStorage.setItem(SystemConst.AMAP_KEY, api[0].properties.api);
+      localStorage.setItem(SystemConst.AMAP_KEY, api[0].properties.apiKey);
       form.setFieldsValue({
         ...basis[0].properties,
-        apikey: api[0].properties.api,
+        apiKey: api[0].properties.apiKey,
         'base-path': basePath[0].properties['base-path'],
       });
       setInitialState({
@@ -45,14 +45,14 @@ const Basis = () => {
           scope: 'front',
           properties: {
             ...formData,
-            apikey: '',
+            apiKey: '',
             'base-path': '',
           },
         },
         {
           scope: 'amap',
           properties: {
-            api: formData.apikey,
+            apiKey: formData.apiKey,
           },
         },
         {
@@ -105,7 +105,7 @@ const Basis = () => {
               </Form.Item>
               <Form.Item
                 label="高德API Key"
-                name="apikey"
+                name="apiKey"
                 tooltip="配置后平台可调用高德地图GIS服务"
               >
                 <Input />

+ 2 - 2
src/utils/util.ts

@@ -49,11 +49,11 @@ export const downloadFileByUrl = (url: string, name: string, type: string) => {
  * @param record
  * @param fileName
  */
-export const downloadObject = (record: Record<string, any>, fileName: string) => {
+export const downloadObject = (record: Record<string, any>, fileName: string, format?: string) => {
   // 创建隐藏的可下载链接
   const ghostLink = document.createElement('a');
   ghostLink.download = `${record?.name || ''}${fileName}_${moment(new Date()).format(
-    'YYYY/MM/DD HH:mm:ss',
+    format || 'YYYY/MM/DD HH:mm:ss',
   )}.json`;
   ghostLink.style.display = 'none';
   //字符串内容转成Blob地址