|
@@ -1,5 +1,5 @@
|
|
|
import type { FormInstance } from 'antd';
|
|
import type { FormInstance } from 'antd';
|
|
|
-import { Button, Col, Form, Row, Select } from 'antd';
|
|
|
|
|
|
|
+import { Button, Checkbox, Col, Form, Row, Select } from 'antd';
|
|
|
import { useCallback, useEffect, useState } from 'react';
|
|
import { useCallback, useEffect, useState } from 'react';
|
|
|
import { useRequest } from 'umi';
|
|
import { useRequest } from 'umi';
|
|
|
import {
|
|
import {
|
|
@@ -16,6 +16,7 @@ import FunctionCall from './device/functionCall';
|
|
|
import { InputNumber } from '../components';
|
|
import { InputNumber } from '../components';
|
|
|
import { DeleteOutlined } from '@ant-design/icons';
|
|
import { DeleteOutlined } from '@ant-design/icons';
|
|
|
import { observer } from '@formily/reactive-react';
|
|
import { observer } from '@formily/reactive-react';
|
|
|
|
|
+import ConditionalFiltering from './device/ConditionalFiltering';
|
|
|
|
|
|
|
|
interface ActionProps {
|
|
interface ActionProps {
|
|
|
restField: any;
|
|
restField: any;
|
|
@@ -26,6 +27,7 @@ interface ActionProps {
|
|
|
onRemove: () => void;
|
|
onRemove: () => void;
|
|
|
actionItemData?: any;
|
|
actionItemData?: any;
|
|
|
trigger?: any;
|
|
trigger?: any;
|
|
|
|
|
+ parallel?: boolean;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export default observer((props: ActionProps) => {
|
|
export default observer((props: ActionProps) => {
|
|
@@ -41,6 +43,8 @@ export default observer((props: ActionProps) => {
|
|
|
const [properties, setProperties] = useState([]); // 物模型-属性
|
|
const [properties, setProperties] = useState([]); // 物模型-属性
|
|
|
const [functionList, setFunctionList] = useState([]); // 物模型-功能
|
|
const [functionList, setFunctionList] = useState([]); // 物模型-功能
|
|
|
|
|
|
|
|
|
|
+ const [isFiltering, setIsFiltering] = useState(false);
|
|
|
|
|
+
|
|
|
const { data: messageType, run: queryMessageTypes } = useRequest(queryMessageType, {
|
|
const { data: messageType, run: queryMessageTypes } = useRequest(queryMessageType, {
|
|
|
manual: true,
|
|
manual: true,
|
|
|
formatResult: (res) => res.result,
|
|
formatResult: (res) => res.result,
|
|
@@ -200,6 +204,22 @@ export default observer((props: ActionProps) => {
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ const parallelNode = (
|
|
|
|
|
+ <Col span={2}>
|
|
|
|
|
+ {!props.parallel ? (
|
|
|
|
|
+ <Form.Item noStyle>
|
|
|
|
|
+ <Checkbox
|
|
|
|
|
+ onChange={(e) => {
|
|
|
|
|
+ setIsFiltering(e.target.checked);
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 条件过滤
|
|
|
|
|
+ </Checkbox>
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ ) : null}
|
|
|
|
|
+ </Col>
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (type1 === 'notify') {
|
|
if (type1 === 'notify') {
|
|
|
queryMessageTypes();
|
|
queryMessageTypes();
|
|
@@ -250,6 +270,7 @@ export default observer((props: ActionProps) => {
|
|
|
onMessageTypeChange={setDeviceMessageType}
|
|
onMessageTypeChange={setDeviceMessageType}
|
|
|
onFunctionChange={setFunctionList}
|
|
onFunctionChange={setFunctionList}
|
|
|
restField={props.restField}
|
|
restField={props.restField}
|
|
|
|
|
+ parallel={props.parallel}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
{type1 === 'delay' && (
|
|
{type1 === 'delay' && (
|
|
@@ -270,30 +291,49 @@ export default observer((props: ActionProps) => {
|
|
|
notifyType={notifyType}
|
|
notifyType={notifyType}
|
|
|
triggerType={props.triggerType}
|
|
triggerType={props.triggerType}
|
|
|
configId={configId}
|
|
configId={configId}
|
|
|
|
|
+ parallel={props.parallel}
|
|
|
/>
|
|
/>
|
|
|
) : null}
|
|
) : null}
|
|
|
{type1 === 'device' &&
|
|
{type1 === 'device' &&
|
|
|
deviceMessageType === MessageTypeEnum.WRITE_PROPERTY &&
|
|
deviceMessageType === MessageTypeEnum.WRITE_PROPERTY &&
|
|
|
properties.length ? (
|
|
properties.length ? (
|
|
|
- <Form.Item
|
|
|
|
|
- name={[name, 'device', 'message', 'properties']}
|
|
|
|
|
- rules={[
|
|
|
|
|
- {
|
|
|
|
|
- validator: async (_: any, value: any) => {
|
|
|
|
|
- if (value) {
|
|
|
|
|
- if (!Object.values(value)[0]) {
|
|
|
|
|
- return Promise.reject(new Error('请输入属性值'));
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- return Promise.reject(new Error('请选择属性'));
|
|
|
|
|
- }
|
|
|
|
|
- return Promise.resolve();
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- ]}
|
|
|
|
|
- >
|
|
|
|
|
- <WriteProperty properties={properties} type={props.triggerType} form={props.form} />
|
|
|
|
|
- </Form.Item>
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Row gutter={24}>
|
|
|
|
|
+ <Col span={18}>
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ name={[name, 'device', 'message', 'properties']}
|
|
|
|
|
+ rules={[
|
|
|
|
|
+ {
|
|
|
|
|
+ validator: async (_: any, value: any) => {
|
|
|
|
|
+ if (value) {
|
|
|
|
|
+ if (!Object.values(value)[0]) {
|
|
|
|
|
+ return Promise.reject(new Error('请输入属性值'));
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Promise.reject(new Error('请选择属性'));
|
|
|
|
|
+ }
|
|
|
|
|
+ return Promise.resolve();
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ ]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <WriteProperty
|
|
|
|
|
+ name={name}
|
|
|
|
|
+ properties={properties}
|
|
|
|
|
+ type={props.triggerType}
|
|
|
|
|
+ form={props.form}
|
|
|
|
|
+ parallel={props.parallel}
|
|
|
|
|
+ />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ </Col>
|
|
|
|
|
+ {parallelNode}
|
|
|
|
|
+ </Row>
|
|
|
|
|
+ {!props.parallel && isFiltering && (
|
|
|
|
|
+ <Row gutter={24}>
|
|
|
|
|
+ <ConditionalFiltering name={name} form={props.form} />
|
|
|
|
|
+ </Row>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </>
|
|
|
) : null}
|
|
) : null}
|
|
|
{type1 === 'device' &&
|
|
{type1 === 'device' &&
|
|
|
deviceMessageType === MessageTypeEnum.READ_PROPERTY &&
|
|
deviceMessageType === MessageTypeEnum.READ_PROPERTY &&
|
|
@@ -307,17 +347,29 @@ export default observer((props: ActionProps) => {
|
|
|
<ReadProperty properties={properties} />
|
|
<ReadProperty properties={properties} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
</Col>
|
|
</Col>
|
|
|
|
|
+ {parallelNode}
|
|
|
|
|
+ {!props.parallel && isFiltering && (
|
|
|
|
|
+ <Row gutter={24}>
|
|
|
|
|
+ <ConditionalFiltering name={name} form={props.form} />
|
|
|
|
|
+ </Row>
|
|
|
|
|
+ )}
|
|
|
</Row>
|
|
</Row>
|
|
|
) : null}
|
|
) : null}
|
|
|
{type1 === 'device' &&
|
|
{type1 === 'device' &&
|
|
|
deviceMessageType === MessageTypeEnum.INVOKE_FUNCTION &&
|
|
deviceMessageType === MessageTypeEnum.INVOKE_FUNCTION &&
|
|
|
functionList.length ? (
|
|
functionList.length ? (
|
|
|
- <Form.Item
|
|
|
|
|
- name={[name, 'device', 'message', 'inputs']}
|
|
|
|
|
- rules={[{ required: true, message: '请输入功能值' }]}
|
|
|
|
|
- >
|
|
|
|
|
- <FunctionCall functionData={functionList} />
|
|
|
|
|
- </Form.Item>
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ name={[name, 'device', 'message', 'inputs']}
|
|
|
|
|
+ rules={[{ required: true, message: '请输入功能值' }]}
|
|
|
|
|
+ >
|
|
|
|
|
+ <FunctionCall functionData={functionList} />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ <Row gutter={24}>
|
|
|
|
|
+ {parallelNode}
|
|
|
|
|
+ <ConditionalFiltering name={name} form={props.form} />
|
|
|
|
|
+ </Row>
|
|
|
|
|
+ </>
|
|
|
) : null}
|
|
) : null}
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|