Skip to content

Commit 66ee50a

Browse files
committed
add action plugin
1 parent 54324c7 commit 66ee50a

17 files changed

Lines changed: 330 additions & 227 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/node/BaseFlowNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public Map<String, Object> toMap() {
147147
map.put("id", id);
148148
map.put("name", name);
149149
map.put("type", getType());
150+
map.put("display",this instanceof IDisplayNode);
150151
map.put("order", String.valueOf(order));
151152
if (this.blocks != null && !this.blocks.isEmpty()) {
152153
map.put("blocks", blocks.stream().map(IFlowNode::toMap).toList());

frontend/packages/flow-pc/flow-pc-design/src/components/design-panel/types.ts

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,63 @@
11
// Tab布局类型
2-
import {FlowForm,NodeType} from "@flow-engine/flow-types";
2+
import {FlowForm,NodeType,FlowAction} from "@flow-engine/flow-types";
33

44
export type TabPanelType = 'base' | 'form' | 'flow' | 'setting';
55

66
// 布局顶部高度
77
export const LayoutHeaderHeight = 50;
88

99

10-
1110
export interface DesignPanelProps {
1211
// 流程编码
1312
id?:string
13+
// 是否开启
1414
open: boolean;
15+
// 关闭
1516
onClose?: () => void;
1617
}
1718

1819

1920
// 流程配置
2021
export interface Workflow {
22+
// 设计id
2123
id: string;
24+
// 流程名称
2225
title: string;
26+
// 流程编码
2327
code: string;
28+
// 流程表单
2429
form: FlowForm;
2530
// 流程创建人脚本
2631
operatorCreateScript:string;
32+
// 流程策略
2733
strategies?:any[];
34+
// 流程节点
2835
nodes?:FlowNode[];
29-
edges?:FlowEdge[];
30-
}
31-
32-
// 节点关系
33-
export interface FlowEdge {
34-
from:string;
35-
to:string;
3636
}
3737

38-
// 动作展示
39-
export interface ActionDisplay{
40-
title:string;
41-
style:any;
42-
icon:string;
43-
}
44-
45-
// 节点动作
46-
export interface FlowAction{
47-
id:string;
48-
type:string;
49-
title:string;
50-
display:ActionDisplay;
51-
}
5238

5339
// 流程节点
5440
export interface FlowNode{
41+
// 节点id
5542
id:string;
43+
// 节点名称
5644
name:string;
45+
// 节点类型
5746
type:NodeType;
47+
// 节点优先级
5848
order:number;
49+
// 节点动作
5950
actions:FlowAction[];
51+
// 节点策略
6052
strategies:any[];
53+
// 节点条件块
6154
blocks?:FlowNode[];
55+
// 节点表达式
6256
script?:string;
57+
// 节点视图
6358
view?:string;
59+
// 流程展示节点
60+
display?:boolean;
6461
}
6562

6663
// 全局状态
Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
11
import React from "react";
22
import {ActionFormProps} from "@/components/script/typings";
3-
import { Row } from "antd";
3+
import {Col, Form, Row} from "antd";
4+
import {OperatorLoadPluginView} from "@/components/script/plugins/view/operator-load-view";
45

56

7+
interface AddAuditInputProps{
8+
value?:string;
9+
onChange?:(value:string) => void;
10+
}
11+
12+
const AddAuditInput:React.FC<AddAuditInputProps> = (props)=>{
13+
14+
const script = props.value || '';
15+
16+
const handleChange = (value:string)=>{
17+
props.onChange && props.onChange(value);
18+
}
19+
20+
return (
21+
<OperatorLoadPluginView
22+
script={script}
23+
onChange={handleChange}
24+
/>
25+
)
26+
}
27+
628
export const AddAuditActionForm:React.FC<ActionFormProps> = (props)=>{
729

830
return (
931
<Row>
10-
add audit
32+
<Col span={24}>
33+
<Form.Item
34+
name={"script"}
35+
label={"加签人员范围"}
36+
help={"加签人员范围为空时,即为全部人员"}
37+
>
38+
<AddAuditInput/>
39+
</Form.Item>
40+
</Col>
1141
</Row>
1242
)
1343
}

frontend/packages/flow-pc/flow-pc-design/src/components/script/components/action/components/custom.tsx

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,7 @@
11
import React from "react";
2-
import {ActionFormProps, ActionSelectOption} from "@/components/script/typings";
3-
import {Col, Form, Row, Select} from "antd";
4-
import {GroovyCodeEditor} from "@/components/groovy-code";
5-
import {ActionCustomScriptUtils} from "@/components/script/services/action-custom";
6-
7-
interface CustomScriptProps {
8-
value?: string;
9-
onChange?: (value: string) => void;
10-
options:ActionSelectOption[];
11-
}
12-
13-
const CustomScript: React.FC<CustomScriptProps> = (props) => {
14-
15-
const trigger = React.useMemo(() => {
16-
if (props.value) {
17-
return ActionCustomScriptUtils.getTrigger(props.value);
18-
}
19-
return undefined;
20-
}, [props.value]);
21-
22-
const handleChangeNodeType = (value: string) => {
23-
const script = props.value;
24-
if (script) {
25-
const groovy = ActionCustomScriptUtils.update(value, script);
26-
props.onChange?.(groovy);
27-
}
28-
}
29-
30-
return (
31-
<div
32-
style={{
33-
marginTop: "8px",
34-
padding: "8px",
35-
}}
36-
>
37-
<div style={{
38-
display: "flex",
39-
justifyContent: "start",
40-
alignItems: "center",
41-
marginBottom: "8px",
42-
}}>
43-
<span>触发动作:</span>
44-
<Select
45-
size={"small"}
46-
style={{
47-
width: '200px',
48-
marginLeft: "10px",
49-
}}
50-
value={trigger}
51-
placeholder={"请选择触发动作类型"}
52-
onChange={handleChangeNodeType}
53-
options={[
54-
{
55-
label: '通过',
56-
value: 'pass'
57-
},
58-
{
59-
label: '拒绝',
60-
value: 'reject'
61-
}
62-
]}
63-
/>
64-
</div>
65-
66-
<GroovyCodeEditor
67-
value={props.value}
68-
onChange={props.onChange}
69-
placeholder={"请输入自定义脚本"}
70-
options={{
71-
minHeight: 200
72-
}}
73-
/>
74-
</div>
75-
)
76-
}
2+
import {ActionFormProps} from "@/components/script/typings";
3+
import {Col, Form, Row} from "antd";
4+
import {ConditionCustomView} from "@/components/script/plugins/view/action-custom-view";
775

786
export const CustomActionForm: React.FC<ActionFormProps> = (props) => {
797

@@ -94,7 +22,7 @@ export const CustomActionForm: React.FC<ActionFormProps> = (props) => {
9422
}
9523
]}
9624
>
97-
<CustomScript
25+
<ConditionCustomView
9826
options={actionOptionTypes}
9927
/>
10028
</Form.Item>
Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
import React from "react";
22
import {ActionFormProps} from "@/components/script/typings";
3+
import {OperatorLoadPluginView} from "@/components/script/plugins/view/operator-load-view";
4+
import {Col, Form, Row } from "antd";
35

46

7+
8+
interface DelegateInputProps{
9+
value?:string;
10+
onChange?:(value:string) => void;
11+
}
12+
13+
const DelegateInput:React.FC<DelegateInputProps> = (props)=>{
14+
15+
const script = props.value || '';
16+
17+
const handleChange = (value:string)=>{
18+
props.onChange && props.onChange(value);
19+
}
20+
21+
return (
22+
<OperatorLoadPluginView
23+
script={script}
24+
onChange={handleChange}
25+
/>
26+
)
27+
}
28+
529
export const DelegateActionForm:React.FC<ActionFormProps> = (props)=>{
630

731
return (
8-
<>
9-
delegate
10-
</>
32+
<Row>
33+
<Col span={24}>
34+
<Form.Item
35+
name={"script"}
36+
label={"委派人员范围"}
37+
help={"委派人员范围为空时,即为全部人员"}
38+
>
39+
<DelegateInput/>
40+
</Form.Item>
41+
</Col>
42+
</Row>
1143
)
1244
}

frontend/packages/flow-pc/flow-pc-design/src/components/script/components/action/components/factory.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {CustomActionForm} from "@/components/script/components/action/components
55
import {AddAuditActionForm} from "@/components/script/components/action/components/add-audit";
66
import {DelegateActionForm} from "@/components/script/components/action/components/delegate";
77
import {RejectActionForm} from "@/components/script/components/action/components/reject";
8-
import {ReturnActionForm} from "@/components/script/components/action/components/return";
98
import {TransferActionForm} from "@/components/script/components/action/components/transfer";
109

1110
export class ActionFactory{
@@ -22,7 +21,6 @@ export class ActionFactory{
2221
this.actions.set('CUSTOM',CustomActionForm);
2322
this.actions.set('DELEGATE',DelegateActionForm);
2423
this.actions.set('REJECT',RejectActionForm);
25-
this.actions.set('RETURN',ReturnActionForm);
2624
this.actions.set('TRANSFER',TransferActionForm);
2725

2826
}
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
import React from "react";
22
import {ActionFormProps} from "@/components/script/typings";
3+
import {Col, Form, Row} from "antd";
4+
import {ConditionRejectView} from "@/components/script/plugins/view/action-reject-view";
35

46

57
export const RejectActionForm:React.FC<ActionFormProps> = (props)=>{
68

9+
710
return (
8-
<>
9-
reject
10-
</>
11+
<Row>
12+
<Col span={24}>
13+
<Form.Item
14+
name={"script"}
15+
label={"拒绝策略"}
16+
>
17+
<ConditionRejectView/>
18+
</Form.Item>
19+
</Col>
20+
</Row>
1121
)
1222
}

frontend/packages/flow-pc/flow-pc-design/src/components/script/components/action/components/return.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,45 @@
11
import React from "react";
22
import {ActionFormProps} from "@/components/script/typings";
3+
import {OperatorLoadPluginView} from "@/components/script/plugins/view/operator-load-view";
4+
import {Col, Form, Row } from "antd";
5+
6+
7+
8+
interface TransferInputProps{
9+
value?:string;
10+
onChange?:(value:string) => void;
11+
}
12+
13+
const TransferInput:React.FC<TransferInputProps> = (props)=>{
14+
15+
const script = props.value || '';
16+
17+
const handleChange = (value:string)=>{
18+
props.onChange && props.onChange(value);
19+
}
20+
21+
return (
22+
<OperatorLoadPluginView
23+
script={script}
24+
onChange={handleChange}
25+
/>
26+
)
27+
}
328

429

530
export const TransferActionForm:React.FC<ActionFormProps> = (props)=>{
631

732
return (
8-
<>
9-
transfer
10-
</>
33+
<Row>
34+
<Col span={24}>
35+
<Form.Item
36+
name={"script"}
37+
label={"转办人员范围"}
38+
help={"转办人员范围为空时,即为全部人员"}
39+
>
40+
<TransferInput/>
41+
</Form.Item>
42+
</Col>
43+
</Row>
1144
)
1245
}

frontend/packages/flow-pc/flow-pc-design/src/components/script/modal/action-config-modal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export const ActionConfigModal: React.FC<ActionModalProps> = (props) => {
1212
title={"编辑按钮"}
1313
width={"65%"}
1414
destroyOnHidden={true}
15+
onOk={()=>{
16+
props.form.submit();
17+
}}
1518
>
1619
<ActionForm
1720
form={props.form}

0 commit comments

Comments
 (0)