wzyyy 3 jaren geleden
bovenliggende
commit
44a7454498

+ 44 - 4
src/components/FRuleEditor/Debug/index.tsx

@@ -1,7 +1,7 @@
 import styles from './index.less';
 import { createSchemaField, observer } from '@formily/react';
 import { ArrayTable, Form, FormItem, Input, Select } from '@formily/antd';
-import { useMemo, useRef, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
 import type { Field } from '@formily/core';
 import { createForm } from '@formily/core';
 import type { ISchema } from '@formily/json-schema';
@@ -46,6 +46,7 @@ const Debug = observer((props: Props) => {
   const getProperty = async () => DB.getDB().table('properties').toArray();
   const virtualIdRef = useRef(new Date().getTime());
   const ws = useRef<any>();
+  const wsAgain = useRef<any>();
   const [isBeginning, setIsBeginning] = useState<any>(true);
 
   const schema: ISchema = {
@@ -151,6 +152,9 @@ const Debug = observer((props: Props) => {
       const _item = propertiesList.find((i) => i.id === item.id);
       return { ...item, type: _item?.valueType?.type };
     });
+    if (ws.current) {
+      ws.current.unsubscribe();
+    }
     ws.current = subscribeTopic?.(
       `virtual-property-debug-${State.property}-${new Date().getTime()}`,
       '/virtual-property-debug',
@@ -167,6 +171,40 @@ const Debug = observer((props: Props) => {
       setIsBeginning(true);
     });
   };
+  const runScriptAgain = async () => {
+    if (wsAgain.current) {
+      wsAgain.current.unsubscribe();
+    }
+    const propertiesList = await DB.getDB().table('properties').toArray();
+    const _properties = form.values?.properties.map((item: any) => {
+      const _item = propertiesList.find((i) => i.id === item.id);
+      return { ...item, type: _item?.valueType?.type };
+    });
+    wsAgain.current = subscribeTopic?.(
+      `virtual-property-debug-${State.property}-${new Date().getTime()}`,
+      '/virtual-property-debug',
+      {
+        virtualId: `${virtualIdRef.current}-virtual-id`,
+        property: State.property,
+        virtualRule: {
+          ...props.virtualRule,
+        },
+        properties: _properties || [],
+      },
+    )?.subscribe(() => {
+      setIsBeginning(true);
+    });
+  };
+  useEffect(() => {
+    return () => {
+      if (ws.current) {
+        ws.current.unsubscribe();
+      }
+      if (wsAgain.current) {
+        wsAgain.current.unsubscribe();
+      }
+    };
+  }, []);
   return (
     <div className={styles.container}>
       <div className={styles.left}>
@@ -180,10 +218,10 @@ const Debug = observer((props: Props) => {
               <div
                 className={styles.action}
                 onClick={() => {
-                  runScript();
+                  runScriptAgain();
                 }}
               >
-                <a>发送数据</a>
+                <a style={{ marginLeft: 90 }}>发送数据</a>
               </div>
             )}
           </div>
@@ -213,7 +251,9 @@ const Debug = observer((props: Props) => {
                 <a
                   onClick={() => {
                     setIsBeginning(true);
-                    // ws.current && ws.current.unsubscribe();
+                    if (ws.current) {
+                      ws.current.unsubscribe();
+                    }
                   }}
                 >
                   停止运行

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

@@ -29,7 +29,7 @@ interface Props {
 const FRuleEditor = observer((props: Props) => {
   const { value, onChange, property, virtualRule } = props;
   useEffect(() => {
-    console.log(virtualRule, 111111111);
+    // console.log(virtualRule, 111111111);
     State.property = property;
     const subscription = Store.subscribe('rule-editor-value', onChange);
     State.code = value;

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

@@ -115,7 +115,7 @@ export default (props: DeviceCardProps) => {
       status={props.state?.value}
       statusText={props.state?.text}
       statusNames={{
-        online: StatusColorEnum.processing,
+        online: StatusColorEnum.success,
         offline: StatusColorEnum.error,
         notActive: StatusColorEnum.warning,
       }}

File diff suppressed because it is too large
+ 1 - 13
src/pages/device/Instance/Detail/Parsing/index.tsx


+ 17 - 8
src/pages/device/components/Metadata/Base/Edit/index.tsx

@@ -84,6 +84,15 @@ const Edit = observer((props: Props) => {
               (field as any).disabled = true;
             }
           });
+          onFieldReact('expands.virtualRule.windowType', (field, form1) => {
+            // console.log(field.value,111111111)
+            const value = (field as Field).value;
+            if (value) {
+              form1.setFieldState('expands.virtualRule.type', (state) => {
+                state.value = 'window';
+              });
+            }
+          });
           onFieldReact('expands.metrics.*.*', (field, form1) => {
             const type = field.query('valueType.type').take() as Field;
             const componentMap = {
@@ -489,14 +498,14 @@ const Edit = observer((props: Props) => {
             'x-component': 'Input',
             'x-decorator': 'FormItem',
             'x-hidden': true,
-            'x-reactions': {
-              dependencies: ['..virtualRule.windowType'],
-              fulfill: {
-                state: {
-                  value: "{{ $self.value?'window':'script'}}",
-                },
-              },
-            },
+            // 'x-reactions': {
+            //   dependencies: ['..virtualRule.windowType'],
+            //   fulfill: {
+            //     state: {
+            //       value: "{{ $self.value?'window':'script'}}",
+            //     },
+            //   },
+            // },
           },
           'virtualRule.script': {
             type: 'string',

+ 8 - 1
src/pages/media/Device/index.tsx

@@ -20,6 +20,7 @@ import MediaDevice from '@/components/ProTableCard/CardItems/mediaDevice';
 import { getMenuPathByCode, getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 import Service from './service';
 import { onlyMessage } from '@/utils/util';
+import encodeQuery from '@/utils/encodeQuery';
 
 export const service = new Service('media/device');
 
@@ -136,7 +137,13 @@ const Device = () => {
       valueType: 'select',
       hideInTable: false,
       request: async () => {
-        const res = await service.getProductList();
+        const res = await service.getProductList(
+          encodeQuery({
+            terms: {
+              messageProtocol$in: ['gb28181-2016', 'fixed-media'],
+            },
+          }),
+        );
         if (res.status === 200) {
           return res.result.map((pItem: any) => ({ label: pItem.name, value: pItem.id }));
         }

+ 2 - 1
src/pages/rule-engine/Scene/Save/action/VariableItems/builtIn.tsx

@@ -103,10 +103,11 @@ export default (props: BuiltInProps) => {
 
   useEffect(() => {
     // console.log(props.value,11111)
+    // console.log(props.form.getFieldsValue(),2222)
     setSource(props.value?.source);
     setValue(props.value?.value);
     setUpperKey(props.value?.upperKey);
-  }, []);
+  }, [props.value]);
 
   const itemOnChange = useCallback(
     (_value: any) => {

+ 1 - 1
src/pages/rule-engine/Scene/Save/action/device/ConditionalFiltering.tsx

@@ -206,7 +206,7 @@ export default (props: ConditionalFilteringProps) => {
         noStyle
         dependencies={[props.name, 'terms', 0, 'column']}
         shouldUpdate={(prevValues, curValues) => {
-          console.log(['actions', `${props.name}`, 'terms', '0', 'column']);
+          // console.log(['actions', `${props.name}`, 'terms', '0', 'column']);
           const pValue = getFormValueByName(
             ['actions', `${props.name}`, 'terms', '0', 'column'],
             prevValues,

+ 25 - 2
src/pages/system/Platforms/Api/basePage.tsx

@@ -20,6 +20,7 @@ export default (props: TableProps) => {
   const [selectKeys, setSelectKeys] = useState<string[]>([]);
   const [dataSource, setDataSource] = useState<any[]>([]);
   const [loading, setLoading] = useState(false);
+  const [GrantKeys, setGrantKeys] = useState<string[] | undefined>(undefined);
 
   const grantCache = useRef<string[]>([]);
 
@@ -32,12 +33,32 @@ export default (props: TableProps) => {
     );
   };
 
+  const getApiGrant = useCallback(() => {
+    const param = new URLSearchParams(location.search);
+    const code = param.get('code');
+
+    if (props.isOpenGranted === false) {
+      service.apiOperations().then((resp: any) => {
+        if (resp.status === 200) {
+          setGrantKeys(resp.result);
+        }
+      });
+    } else {
+      service.getApiGranted(code!).then((resp: any) => {
+        if (resp.status === 200) {
+          setGrantKeys(resp.result);
+        }
+      });
+    }
+  }, [location, props.isOpenGranted]);
+
   /**
    * 获取已授权的接口ID
    */
   useEffect(() => {
     grantCache.current = props.grantKeys || [];
     setSelectKeys(props.grantKeys || []);
+    setGrantKeys(props.grantKeys);
   }, [props.grantKeys]);
 
   useEffect(() => {
@@ -107,12 +128,14 @@ export default (props: TableProps) => {
       const resp2 = removeGrant.length ? await service.apiOperationsRemove(removeGrant) : {};
       const resp = await service.apiOperationsAdd(addGrant);
       if (resp.status === 200 || resp2.status === 200) {
+        getApiGrant();
         onlyMessage('操作成功');
       }
     } else {
-      const resp = await service.addApiGrant(code!, { operations: addOperations });
       const resp2 = await service.removeApiGrant(code!, { operations: removeOperations });
+      const resp = await service.addApiGrant(code!, { operations: addOperations });
       if (resp.status === 200 || resp2.status === 200) {
+        getApiGrant();
         onlyMessage('操作成功');
       }
     }
@@ -171,7 +194,7 @@ export default (props: TableProps) => {
                       selectedRows
                         .filter((item) => !!item)
                         .map((item) => item.operationId)
-                        .concat(props.grantKeys),
+                        .concat(GrantKeys),
                     );
                   } else {
                     setSelectKeys([]);