wzyyy 3 лет назад
Родитель
Сommit
a700d2275f

+ 33 - 0
src/pages/rule-engine/Scene/Save/action/DeviceOutput/actions/ReadProperty.tsx

@@ -0,0 +1,33 @@
+import { Select } from 'antd';
+
+interface ReadPropertyProps {
+  properties: any[];
+  value?: any;
+  onChange?: (value?: any) => void;
+  propertiesChange?: (value?: string) => void;
+  id?: string;
+}
+
+export default (props: ReadPropertyProps) => {
+  return (
+    <Select
+      id={props.id}
+      value={props.value ? props.value[0] : undefined}
+      options={props.properties?.filter((item) => {
+        if (item.expands && item.expands.type) {
+          return item.expands.type.includes('read');
+        }
+        return false;
+      })}
+      fieldNames={{ label: 'name', value: 'id' }}
+      style={{ width: '100%' }}
+      onSelect={(key: any) => {
+        if (props.onChange) {
+          props.onChange([key]);
+          props.propertiesChange?.(key);
+        }
+      }}
+      placeholder={'请选择属性'}
+    ></Select>
+  );
+};

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

@@ -1,10 +1,10 @@
 import { observer } from '@formily/reactive-react';
 import { Form, Select } from 'antd';
 import { useEffect, useState } from 'react';
-import ReadProperty from '../../device/readProperty';
 import TopCard from '../device/TopCard';
 import DeviceModel from '../model';
 import FunctionCall from './functionCall';
+import ReadProperty from './ReadProperty';
 import WriteProperty from './WriteProperty';
 
 interface Props {

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

@@ -323,6 +323,7 @@ export default observer((props: Props) => {
             <SearchComponent
               field={columns}
               model={'simple'}
+              bodyStyle={{ padding: 0, paddingBottom: 16 }}
               enableSave={false}
               onSearch={async (data) => {
                 actionRef.current?.reset?.();

+ 2 - 6
src/pages/rule-engine/Scene/Save/action/DeviceOutput/product/index.tsx

@@ -210,18 +210,14 @@ export default observer((props: Props) => {
         field={columns}
         model={'simple'}
         enableSave={false}
+        bodyStyle={{ padding: 0, paddingBottom: 16 }}
         onSearch={async (data) => {
           actionRef.current?.reset?.();
           setSearchParam(data);
         }}
         target="department-assets-product"
       />
-      <div
-        style={{
-          height: 'calc(100vh - 440px)',
-          overflowY: 'auto',
-        }}
-      >
+      <div>
         <ProTableCard<ProductItem>
           noPadding
           cardScrollY={460}