Skip to content

Commit a38ac28

Browse files
committed
condition
1 parent 626bc1e commit a38ac28

3 files changed

Lines changed: 29 additions & 19 deletions

File tree

frontend/packages/flow-pc/flow-pc-design/src/components/script/components/condition/components/condition-relation/group.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Dropdown, Tag} from "antd";
22
import React from "react";
3-
import {ConditionRelationProps, LogicalRelation} from "@/components/script/components/condition/typings";
3+
import {ConditionRelationProps} from "@/components/script/components/condition/typings";
44
import {
55
useDropdownMenus
66
} from "@/components/script/components/condition/components/condition-relation/hooks/use-dropdown-menus";
@@ -9,17 +9,6 @@ import {RelationRender} from "@/components/script/components/condition/component
99
export const RelationGroup: React.FC<ConditionRelationProps> = (props) => {
1010
const items = useDropdownMenus(props);
1111

12-
const relations = React.useMemo(() => {
13-
const list: LogicalRelation[] = [];
14-
if (props.current.children) {
15-
list.push(...props.current.children);
16-
}
17-
list.push({
18-
type: 'action'
19-
})
20-
return list;
21-
}, [props.current.children]);
22-
2312
return (
2413
<>
2514
<Dropdown
@@ -30,7 +19,7 @@ export const RelationGroup: React.FC<ConditionRelationProps> = (props) => {
3019
}}
3120
></Tag>
3221
</Dropdown>
33-
{RelationRender.getInstance().renderList(relations)}
22+
{RelationRender.getInstance().renderList(props.current.children || [])}
3423
<Dropdown
3524
menu={{items}}>
3625
<Tag

frontend/packages/flow-pc/flow-pc-design/src/components/script/components/condition/components/condition-relation/hooks/menu-relation.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,23 @@ export class MenuRelation {
4545
this.menuList.push(this.createCondition());
4646
}
4747
}
48-
return;
4948
}
5049

51-
this.menuList.push(this.createRemove());
50+
if(currentType==='and' || currentType==='or') {
51+
this.menuList.push(this.createGroup());
52+
if (this.groups.length > 0) {
53+
this.menuList.push(this.createCondition());
54+
}
55+
}
56+
57+
if(currentType==='group' || currentType==='condition') {
58+
this.menuList.push(this.createAnd());
59+
this.menuList.push(this.createOr());
60+
}
61+
62+
if(this.current.id) {
63+
this.menuList.push(this.createRemove());
64+
}
5265
}
5366

5467

@@ -127,7 +140,12 @@ export class MenuRelation {
127140
type: 'group',
128141
id: IdUtils.generateId(),
129142
label: '括号',
130-
children: []
143+
children: [
144+
{
145+
id: IdUtils.generateId(),
146+
type: 'action'
147+
}
148+
]
131149
});
132150
}
133151
}

frontend/packages/flow-pc/flow-pc-design/src/components/script/components/condition/presenters/relation-presenter.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ConditionRelationPresenter {
1515
this.presenter.updateState(prevState => {
1616
return {
1717
...prevState,
18-
relations: [...this.removeRelations(id,prevState.relations)]
18+
relations: [...this.removeRelations(id, prevState.relations)]
1919
}
2020
})
2121
}
@@ -70,10 +70,13 @@ export class ConditionRelationPresenter {
7070
if (relation.children) {
7171
current = {
7272
...relation,
73-
children:this.appendRelations(sourceId, relation.children, target)
73+
children: this.appendRelations(sourceId, relation.children, target)
7474
}
7575
}
76-
list.push(current);
76+
if (current.type !== 'action') {
77+
list.push(current);
78+
}
79+
7780
if (relation.id === sourceId) {
7881
list.push(target);
7982
}

0 commit comments

Comments
 (0)