xieyonghong 3 лет назад
Родитель
Сommit
47a9a4727e

+ 1 - 0
src/components/GeoPoint/AMap.tsx

@@ -46,6 +46,7 @@ export default (props: Props) => {
       visible
       title="地理位置"
       width={'55vw'}
+      zIndex={1050}
       onCancel={() => props.close()}
       onOk={() => {
         props.ok(value);

+ 1 - 2
src/pages/device/Instance/Detail/EdgeMap/mapTree/index.tsx

@@ -49,11 +49,10 @@ const MapTree = (props: Props) => {
   };
 
   const save = async () => {
-    // console.log(list,'list')
     const params: any[] = [];
     // const metadataId = metaData.map((item: any) => item.metadataId);
     list.forEach((item: any) => {
-      const array = item.points.map((element: any) => ({
+      const array = item.points?.map((element: any) => ({
         channelId: item.parentId,
         collectorId: element.collectorId,
         pointId: element.id,

+ 1 - 0
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/ObjModel.tsx

@@ -31,6 +31,7 @@ export default (props: Props) => {
       visible
       title="编辑"
       width={700}
+      zIndex={1050}
       onCancel={() => props.close()}
       onOk={() => {
         props.ok(value);

+ 27 - 14
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/TypeModel.tsx

@@ -19,6 +19,9 @@ interface Props {
   name?: any;
   source?: string;
   format?: any;
+  onColumns?: (col: any) => void;
+  thenName: number;
+  branchGroup?: number;
 }
 
 export default (props: Props) => {
@@ -54,8 +57,13 @@ export default (props: Props) => {
   };
 
   const sourceChangeEvent = async () => {
-    const params = props?.name - 1 >= 0 ? { action: props?.name - 1 } : undefined;
-    queryBuiltInParams(FormModel.current, params).then((res: any) => {
+    // const params = props?.name - 1 >= 0 ? { action: props?.name - 1 } : undefined;
+    const _params = {
+      branch: props.thenName,
+      branchGroup: props.branchGroup,
+      action: props.name,
+    };
+    queryBuiltInParams(FormModel.current, _params).then((res: any) => {
       if (res.status === 200) {
         const _data = BuiltInParamsHandleTreeData(res.result);
         const filterData = filterParamsData(props.type, _data);
@@ -190,17 +198,17 @@ export default (props: Props) => {
             }}
           />
         );
-      case 'password':
-        return (
-          <Input.Password
-            value={value}
-            style={{ width: '100%', textAlign: 'left' }}
-            placeholder={'请输入'}
-            onChange={(e) => {
-              onChange(e.target.value);
-            }}
-          />
-        );
+      // case 'password':
+      //   return (
+      //     <Input.Password
+      //       value={value}
+      //       style={{ width: '100%', textAlign: 'left' }}
+      //       placeholder={'请输入'}
+      //       onChange={(e) => {
+      //         onChange(e.target.value);
+      //       }}
+      //     />
+      //   );
       default:
         return (
           <Input
@@ -235,7 +243,12 @@ export default (props: Props) => {
             defaultExpandAll
             fieldNames={{ title: 'name', key: 'id' }}
             onSelect={(selectedKeys, e) => {
-              // console.log(e.node);
+              console.log('e.node', e.node);
+              if (e.node.metadata) {
+                if (props.onColumns) {
+                  props.onColumns(e.node.column);
+                }
+              }
               setDateOpen(false);
               setLabelValue(e.node.description);
               setValue(selectedKeys[0]);

+ 11 - 8
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/WriteProperty.tsx

@@ -10,15 +10,11 @@ interface Props {
   onChange?: (value?: any, text?: any) => void;
   propertiesChange?: (value?: string) => void;
   name?: any;
+  onColumns?: (col: any) => void;
+  thenName: number;
+  branchGroup?: number;
 }
 
-// const item = {
-//   a1: {
-//     "value": 10,
-//     "source": "fixed",
-//   }
-// }
-
 export default (props: Props) => {
   const [propertiesId, setPropertiesId] = useState<string | undefined>(undefined);
   const [propertiesValue, setPropertiesValue] = useState(undefined);
@@ -29,7 +25,7 @@ export default (props: Props) => {
   const [enumList, setEnumList] = useState<any>([]);
 
   useEffect(() => {
-    console.log(props.value);
+    // console.log(props.value);
     if (props.value) {
       if (props.properties && props.properties.length) {
         if (0 in props.value) {
@@ -97,9 +93,16 @@ export default (props: Props) => {
             value={propertiesValue}
             type={propertiesType}
             name={props.name}
+            branchGroup={props.branchGroup}
+            thenName={props.thenName}
             source={source}
             format={format}
             elements={enumList}
+            onColumns={(col) => {
+              if (props.onColumns) {
+                props.onColumns(col);
+              }
+            }}
             onChange={(value, sources) => {
               // console.log(value, sources);
               setPropertiesValue(value);

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

@@ -10,6 +10,8 @@ import WriteProperty from './WriteProperty';
 interface Props {
   get: (data: any) => void;
   name: number;
+  thenName: number;
+  branchGroup?: number;
 }
 
 export default observer((props: Props) => {
@@ -172,10 +174,14 @@ export default observer((props: Props) => {
             <WriteProperty
               properties={properties}
               name={props.name}
+              branchGroup={props.branchGroup}
+              thenName={props.thenName}
+              onColumns={(col) => {
+                // console.log('col',col,[col])
+                DeviceModel.columns = [col];
+              }}
               onChange={(value, text) => {
-                console.log(Object.keys(value));
                 const item = value[Object.keys(value)?.[0]]?.value;
-                console.log(item);
                 DeviceModel.propertiesName = text;
                 DeviceModel.propertiesValue = item;
               }}

+ 14 - 3
src/pages/rule-engine/Scene/Save/action/DeviceOutput/device/index.tsx

@@ -25,6 +25,8 @@ import Tag from './Tag';
 interface Props {
   name: number;
   parallel: boolean;
+  thenName: number;
+  branchGroup?: number;
 }
 
 export default observer((props: Props) => {
@@ -274,8 +276,13 @@ export default observer((props: Props) => {
   };
 
   const sourceChangeEvent = async () => {
-    const params = props.name - 1 >= 0 ? { action: props.name - 1 } : undefined;
-    queryBuiltInParams(FormModel.current, params).then((res: any) => {
+    // const params = props.name - 1 >= 0 ? { action: props.name - 1 } : undefined;
+    const _params = {
+      branch: props.thenName,
+      branchGroup: props.branchGroup,
+      action: props.name,
+    };
+    queryBuiltInParams(FormModel.current, _params).then((res: any) => {
       if (res.status === 200) {
         const _data = BuiltInParamsHandleTreeData(res.result);
         const array = filterTree(_data);
@@ -457,7 +464,7 @@ export default observer((props: Props) => {
       form.setFieldsValue({ selector: DeviceModel.selector });
     }
     sourceChangeEvent();
-    console.log('-----deviceid-----', DeviceModel.deviceId);
+    // console.log('-----deviceid-----', DeviceModel.deviceId);
     if (DeviceModel.deviceId) {
       service.detail(DeviceModel.deviceId).then((res) => {
         if (res.status === 200) {
@@ -467,6 +474,10 @@ export default observer((props: Props) => {
     }
   }, []);
 
+  // useEffect(()=>{
+  //   console.log('----------------',props.branchGroup,props.thenName,props.name)
+  // },[props.branchGroup,props.thenName])
+
   useEffect(() => {
     if (DeviceModel.productDetail) {
       const metadata = JSON.parse(DeviceModel.productDetail?.metadata || '{}');

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

@@ -17,6 +17,8 @@ interface Props {
   save: (data: any, _options?: any) => void;
   cancel: () => void;
   name: number;
+  thenName: number;
+  branchGroup?: number;
   parallel: boolean;
 }
 
@@ -32,7 +34,14 @@ export default observer((props: Props) => {
     {
       key: 'device',
       title: '选择设备',
-      content: <Device name={props.name} parallel={props.parallel} />,
+      content: (
+        <Device
+          name={props.name}
+          parallel={props.parallel}
+          branchGroup={props.branchGroup}
+          thenName={props.thenName}
+        />
+      ),
     },
     {
       key: 'action',
@@ -40,6 +49,8 @@ export default observer((props: Props) => {
       content: (
         <Action
           name={props.name}
+          branchGroup={props.branchGroup}
+          thenName={props.thenName}
           get={(item: any) => {
             formRef.current = item;
           }}
@@ -93,6 +104,7 @@ export default observer((props: Props) => {
       productName: DeviceModel.productDetail.name,
       relationName: DeviceModel.relationName,
       taglist: [],
+      columns: [],
     };
     _options.name = DeviceModel.deviceDetail?.name;
     const _type = value.message.messageType;
@@ -111,6 +123,7 @@ export default observer((props: Props) => {
       // _options.properties = Object.keys(value.message.properties)?.[0];
       _options.properties = DeviceModel.propertiesName;
       _options.propertiesValue = DeviceModel.propertiesValue;
+      _options.columns = DeviceModel.columns;
     }
     if (_options.selector === 'tag') {
       _options.taglist = DeviceModel.selectorValues?.[0]?.value.map((it: any) => ({

+ 2 - 0
src/pages/rule-engine/Scene/Save/action/DeviceOutput/model.ts

@@ -24,6 +24,7 @@ type ModelType = {
   message: any;
   propertiesName: string;
   propertiesValue: string;
+  columns: string[];
 };
 
 const DeviceModel = model<ModelType>({
@@ -43,6 +44,7 @@ const DeviceModel = model<ModelType>({
   message: {},
   propertiesName: '',
   propertiesValue: '',
+  columns: [],
 });
 
 export default DeviceModel;

+ 4 - 0
src/pages/rule-engine/Scene/Save/action/ListItem/Item.tsx

@@ -387,6 +387,8 @@ export default (props: ItemProps) => {
       {visible && (
         <Modal
           name={props.name}
+          branchGroup={props.branchGroup}
+          thenName={props.thenName}
           data={props.data}
           close={() => {
             setVisible(false);
@@ -408,6 +410,8 @@ export default (props: ItemProps) => {
       )}
       <ActionTypeComponent
         name={props.name}
+        branchGroup={props.branchGroup}
+        thenName={props.thenName}
         data={props.data}
         type={actionType}
         close={() => {

+ 3 - 1
src/pages/rule-engine/Scene/Save/action/ListItem/List.tsx

@@ -58,7 +58,9 @@ export default (props: ListProps) => {
         <Modal
           // type={props.type}
           parallel={props.parallel}
-          name={props.actions.length + 1}
+          name={props.actions.length}
+          branchGroup={props.parallel ? 1 : 0}
+          thenName={props.thenName}
           data={{
             key: `${props.type}_${props.actions.length}`,
           }}

+ 6 - 0
src/pages/rule-engine/Scene/Save/action/Modal/add.tsx

@@ -13,6 +13,8 @@ interface ActionTypeProps {
   data: Partial<ActionsType>;
   close: () => void;
   parallel: boolean;
+  thenName: number;
+  branchGroup?: number;
 }
 
 export const ActionTypeComponent = (props: ActionTypeProps) => {
@@ -36,6 +38,8 @@ export const ActionTypeComponent = (props: ActionTypeProps) => {
             );
           }}
           name={props.name}
+          branchGroup={props.branchGroup}
+          thenName={props.thenName}
           cancel={() => {
             props.close();
           }}
@@ -95,6 +99,8 @@ interface Props {
   save: (data: any, options?: any) => void;
   data: Partial<ActionsType>;
   name: number;
+  thenName: number;
+  branchGroup?: number;
   // type: ParallelType;
   parallel: boolean;
 }