浏览代码

fix: merge next

hear 2 年之前
父节点
当前提交
5bf56a0899

+ 1 - 1
src/pages/DataCollect/Collector/components/Point/Save/modbus.tsx

@@ -42,7 +42,7 @@ export default (props: Props) => {
         ...props.data?.configuration,
         parameter: {
           ...props.data?.configuration?.parameter,
-          writeByteCount: [props.data?.configuration?.parameter?.writeByteCount],
+          writeByteCount: props.data?.configuration?.parameter?.writeByteCount,
         },
       },
       nspwc:

+ 5 - 0
src/pages/device/Instance/service.ts

@@ -399,6 +399,11 @@ class Service extends BaseService<DeviceInstance> {
     request(`/${SystemConst.API_BASE}/edge/remote/${deviceId}/url`, {
       method: 'GET',
     });
+  public _stopControl = (deviceId: string) =>
+    request(`/${SystemConst.API_BASE}/edge/remote/${deviceId}/stop`, {
+      method: 'POST',
+      data: {},
+    });
 }
 
 export default Service;

+ 45 - 0
src/pages/edge/Device/Remote/index.tsx

@@ -0,0 +1,45 @@
+import { useLocation } from '@/hooks';
+import { PageContainer } from '@ant-design/pro-layout';
+import { useEffect, useState } from 'react';
+import { service } from '@/pages/device/Instance';
+
+const Remote = () => {
+  const location = useLocation();
+  const [url, setUrl] = useState<string>('');
+
+  const _stop = async (id: string) => await service._stopControl(id);
+
+  useEffect(() => {
+    const params = new URLSearchParams(location.search);
+    const deviceId = params.get('id');
+    if (deviceId) {
+      service._control(deviceId).then((resp: any) => {
+        if (resp.status === 200) {
+          console.log(resp.result);
+          const item = `http://${resp.result?.url}/#/login?token=${resp.result.token}`;
+          setUrl(item);
+        }
+      });
+    }
+    return () => {
+      if (deviceId) {
+        _stop(deviceId);
+      }
+    };
+  }, [location]);
+
+  return (
+    <PageContainer>
+      {/* 远程控制 */}
+      <iframe
+        src={url}
+        style={{
+          width: '100%',
+          height: 'calc(100vh - 20vh)',
+        }}
+      ></iframe>
+    </PageContainer>
+  );
+};
+
+export default Remote;

+ 7 - 5
src/pages/edge/Device/index.tsx

@@ -80,11 +80,13 @@ export default () => {
     <PermissionButton
       type={'link'}
       onClick={() => {
-        service._control(record.id).then((resp: any) => {
-          if (resp.status === 200) {
-            window.open(resp.result);
-          }
-        });
+        const url = getMenuPathByParams(MENUS_CODE['edge/Device/Remote']);
+        history.push(`${url}?id=${record?.id}`);
+        // service._control(record.id).then((resp: any) => {
+        //   if (resp.status === 200) {
+        //     window.open(resp.result);
+        //   }
+        // });
       }}
       tooltip={{
         title: type === 'list' ? '远程控制' : '',

+ 3 - 2
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/WriteProperty.tsx

@@ -1,4 +1,5 @@
 import { Col, Row, Select } from 'antd';
+import { isBoolean } from 'lodash';
 import { useEffect, useRef, useState } from 'react';
 import TypeModel from './TypeModel';
 // import { useEffect, useState } from "react";
@@ -65,7 +66,7 @@ export default (props: Props) => {
   }, [props.properties]);
 
   useEffect(() => {
-    if (props.onChange && propertiesValue) {
+    if (props.onChange && (propertiesValue || isBoolean(propertiesValue))) {
       const obj = {
         [propertiesId || 0]: {
           value: propertiesValue,
@@ -143,7 +144,7 @@ export default (props: Props) => {
               }
             }}
             onChange={(value, sources, text) => {
-              console.log(value, sources);
+              // console.log(value, sources);
               // console.log(text);
               ref.current = text;
               setPropertiesValue(value);

+ 6 - 4
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/index.tsx

@@ -7,6 +7,7 @@ import FunctionCall from './functionCall';
 import ReadProperty from './ReadProperty';
 import WriteProperty from './WriteProperty';
 import { service } from '@/pages/device/Instance/index';
+import { isBoolean } from 'lodash';
 
 interface Props {
   get: (data: any) => void;
@@ -194,9 +195,10 @@ export default observer((props: Props) => {
               // { required: true, message: '请选择属性' },
               () => ({
                 validator(_, value) {
-                  const isValue = Object.values(value)?.[0];
-                  // console.log('-------',isValue,value)
-                  if (isValue) {
+                  const isValue: any = Object.values(value)?.[0];
+                  console.log('-------', isValue, isBoolean(isValue?.value));
+
+                  if (isValue || isBoolean(isValue?.value)) {
                     return Promise.resolve();
                   }
                   return Promise.reject(new Error('请选择属性'));
@@ -217,7 +219,7 @@ export default observer((props: Props) => {
                 const item = value[Object.keys(value)?.[0]]?.value;
                 const item1 = value[Object.keys(value)?.[0]]?.upperKey;
                 const source = value[Object.keys(value)?.[0]]?.source;
-                console.log(value);
+                console.log('changeValue-------', value);
                 DeviceModel.propertiesName = text;
                 if (valueLable) {
                   DeviceModel.propertiesValue = valueLable;

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

@@ -148,7 +148,7 @@ export default observer((props: Props) => {
       _options.propertiesValue =
         typeof DeviceModel.propertiesValue === 'object'
           ? JSON.stringify(DeviceModel.propertiesValue)
-          : DeviceModel.propertiesValue;
+          : `${DeviceModel.propertiesValue}`;
       _options.columns = DeviceModel.columns;
       _options.otherColumns = DeviceModel.columns;
       const cur: any = Object.values(value.message.properties)?.[0];

+ 6 - 3
src/pages/rule-engine/Scene/Save/action/ListItem/Item.tsx

@@ -6,7 +6,7 @@ import './index.less';
 import TriggerAlarm from '../TriggerAlarm';
 import { AddButton } from '@/pages/rule-engine/Scene/Save/components/Buttons';
 import FilterGroup from './FilterGroup';
-import { cloneDeep, flattenDeep, set } from 'lodash';
+import { cloneDeep, flattenDeep, isBoolean, set } from 'lodash';
 import { Popconfirm, Space } from 'antd';
 import { TermsType } from '@/pages/rule-engine/Scene/typings';
 import { FormModel } from '@/pages/rule-engine/Scene/Save';
@@ -236,8 +236,11 @@ export default (props: ItemProps) => {
             <AIcon type={typeIconMap[data!.device!.message!.messageType]} />
             <span style={{ paddingRight: 4 }}>{data?.options?.type}</span>
             <AIcon type={'icon-mubiao'} style={{ paddingRight: 2 }} />
-            {`${data?.options?.name} ${data?.options?.properties} ${
-              data?.options?.propertiesValue ? `为 ${data?.options?.propertiesValue}` : ''
+            {`${data?.options?.name} ${data?.options?.properties} 
+            ${
+              (isBoolean(data?.options?.propertiesValue) ? true : data?.options?.propertiesValue)
+                ? `为 ${data?.options?.propertiesValue}`
+                : ''
             }`}
           </div>
         );

+ 1 - 1
src/pages/system/Menu/Setting/baseMenu.ts

@@ -2463,7 +2463,7 @@ export default [
             name: '网关设备',
             owner: 'iot',
             sortIndex: 1,
-            url: '/iot/edge/Devic',
+            url: '/iot/edge/Device',
             icon: 'icon-bumenguanli',
             showPage: ['edge-operations'],
             permissions: [

+ 3 - 0
src/utils/menu/index.ts

@@ -89,6 +89,9 @@ const extraRouteObj = {
       { code: 'Save', name: '详情' },
     ],
   },
+  'edge/Device': {
+    children: [{ code: 'Remote', name: '远程控制' }],
+  },
 };
 //额外路由
 export const extraRouteArr = [

+ 1 - 0
src/utils/menu/router.ts

@@ -41,6 +41,7 @@ export enum MENUS_CODE {
   'DataCollect/Channel' = 'DataCollect/Channel',
   'DataCollect/Collector' = 'DataCollect/Collector',
   'edge/Device' = 'edge/Device',
+  'edge/Device/Remote' = 'edge/Device/Remote',
   'edge/Resource' = 'edge/Resource',
   'Log' = 'Log',
   'media/Cascade' = 'media/Cascade',