Skip to content

Commit b58bdf8

Browse files
authored
Merge pull request #61 from codingapi/dev
Dev
2 parents 8a11e4a + af6af52 commit b58bdf8

File tree

56 files changed

+1918
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1918
-394
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pnpm run dev:app-mobile
291291
### 八层架构
292292

293293
1. **流程层** (Workflow Layer) - 流程定义层
294-
2. **节点层** (Node Layer) - 节点层(12种节点类型
294+
2. **节点层** (Node Layer) - 节点层(15种节点类型
295295
3. **动作层** (Action Layer) - 动作层(8种动作类型)
296296
4. **记录层** (Record Layer) - 记录层
297297
5. **会话层** (Session Layer) - 会话层

designs/view-plugin/DESIGN.md

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
# 界面拓展机制
2+
3+
支持流程组件对各类业务层面内容的界面拓展机制。
4+
5+
## 实现方式
6+
7+
```
8+
import {ViewBindPlugin} from "@flow-engine/flow-core";
9+
10+
// 界面视图
11+
const MyView:React.FC<FormViewProps> = (props)=>{
12+
return (
13+
<></>
14+
)
15+
}
16+
17+
// 注册,关键信息为key 和 界面ComponentType,传递的属性根据不同的界面对应查看
18+
ViewBindPlugin.getInstance().register('MyView',MyView)
19+
```
20+
21+
## 拓展界面
22+
23+
### 流程审核
24+
25+
* 表单渲染
26+
```
27+
export interface FormViewProps {
28+
/** 表单操控对象 */
29+
form: FormInstance;
30+
/** 表单数据更新事件 */
31+
onValuesChange?: (values: any) => void;
32+
/** 表单元数据对象 */
33+
meta: FlowForm;
34+
/** 是否预览模式 */
35+
review:boolean;
36+
}
37+
38+
```
39+
表单选择的key对应流程节点设置的view名称,流程引擎对default进行了模型的渲染支持。
40+
41+
* 流程操作 加签
42+
43+
```
44+
export const VIEW_KEY = 'AddAuditViewPlugin';
45+
46+
export interface AddAuditViewPlugin {
47+
/** 返回用户 */
48+
onChange?: (value: string|string[]) => void;
49+
/** 当前用户 */
50+
value?: string|string[];
51+
}
52+
```
53+
* 流程操作 委派
54+
```
55+
export const VIEW_KEY = 'DelegateViewPlugin';
56+
57+
export interface DelegateViewPlugin {
58+
/** 返回用户 */
59+
onChange?: (value: string|string[]) => void;
60+
/** 当前用户 */
61+
value?: string|string[];
62+
}
63+
```
64+
65+
* 流程操作 退回流程
66+
```
67+
export const VIEW_KEY = 'ReturnViewPlugin';
68+
69+
export interface ReturnViewPlugin {
70+
/** 返回用户 */
71+
onChange?: (value: string|string[]) => void;
72+
/** 当前用户 */
73+
value?: string|string[];
74+
}
75+
```
76+
77+
* 流程操作 提交时的获取签名界面
78+
```
79+
import {FlowOperator} from "@flow-engine/flow-types";
80+
81+
export const VIEW_KEY = 'SignKeyViewPlugin';
82+
83+
export interface SignKeyViewPlugin {
84+
/** 当前用户 */
85+
current: FlowOperator;
86+
/** 返回签名 */
87+
onChange?: (value: string) => void;
88+
/** 当前签名 */
89+
value?: string;
90+
}
91+
```
92+
93+
* 流程操作 转办操作
94+
```
95+
export const VIEW_KEY = 'TransferViewPlugin';
96+
97+
export interface TransferViewPlugin {
98+
/** 返回用户 */
99+
onChange?: (value: string|string[]) => void;
100+
/** 当前用户 */
101+
value?: string|string[];
102+
}
103+
```
104+
105+
### 流程设计-节点配置
106+
107+
* 流程条件控制界面
108+
```
109+
import {GroovyVariableMapping, ScriptType} from "@/components/script/typings";
110+
111+
export const VIEW_KEY = 'ConditionViewPlugin';
112+
113+
export interface ConditionViewPlugin {
114+
/** 脚本类型 */
115+
type: ScriptType;
116+
/** 当前脚本 */
117+
script: string;
118+
/** 变量映射列表 */
119+
variables: GroovyVariableMapping[];
120+
/** 确认回调 */
121+
onChange: (script: string) => void;
122+
}
123+
```
124+
125+
* 异常处理逻辑界面
126+
```
127+
import {GroovyVariableMapping, ScriptType} from "@/components/script/typings";
128+
129+
export const VIEW_KEY = 'ErrorTriggerViewPlugin';
130+
131+
export interface ErrorTriggerViewPlugin {
132+
/** 脚本类型 */
133+
type: ScriptType;
134+
/** 当前脚本 */
135+
script: string;
136+
/** 变量映射列表 */
137+
variables: GroovyVariableMapping[];
138+
/** 确认回调 */
139+
onChange: (script: string) => void;
140+
}
141+
```
142+
143+
* 自定义标题界面
144+
```
145+
import {GroovyVariableMapping, ScriptType} from "@/components/script/typings";
146+
147+
export const VIEW_KEY = 'NodeTitleViewPlugin';
148+
149+
export interface NodeTitleViewPlugin {
150+
/** 脚本类型 */
151+
type: ScriptType;
152+
/** 当前脚本 */
153+
script: string;
154+
/** 变量映射列表 */
155+
variables: GroovyVariableMapping[];
156+
/** 确认回调 */
157+
onChange: (script: string) => void;
158+
}
159+
```
160+
161+
* 设置发起人范围界面
162+
163+
```
164+
export const VIEW_KEY = 'OperatorCreateViewPlugin';
165+
166+
export interface OperatorCreateViewPlugin {
167+
/** 当前脚本 */
168+
script: string;
169+
/** 确认回调 */
170+
onChange: (script: string) => void;
171+
}
172+
```
173+
174+
* 节点人员选择界面
175+
176+
```
177+
export const VIEW_KEY = 'OperatorLoadViewPlugin';
178+
179+
export interface OperatorLoadViewPlugin {
180+
/** 当前脚本 */
181+
script: string;
182+
/** 确认回调 */
183+
onChange: (script: string) => void;
184+
}
185+
```
186+
* 路由配置界面
187+
188+
```
189+
import {GroovyVariableMapping, ScriptType} from "@/components/script/typings";
190+
191+
export const VIEW_KEY = 'RouterViewPlugin';
192+
193+
export interface RouterViewPlugin {
194+
/** 脚本类型 */
195+
type: ScriptType;
196+
/** 当前脚本 */
197+
script: string;
198+
/** 变量映射列表 */
199+
variables: GroovyVariableMapping[];
200+
/** 确认回调 */
201+
onChange: (script: string) => void;
202+
}
203+
```
204+
* 子流程配置界面
205+
```
206+
import {GroovyVariableMapping, ScriptType} from "@/components/script/typings";
207+
208+
export const VIEW_KEY = 'SubProcessViewPlugin';
209+
210+
export interface SubProcessViewPlugin {
211+
/** 脚本类型 */
212+
type: ScriptType;
213+
/** 当前脚本 */
214+
script: string;
215+
/** 变量映射列表 */
216+
variables: GroovyVariableMapping[];
217+
/** 确认回调 */
218+
onChange: (script: string) => void;
219+
}
220+
```
221+
* 触发流程界面
222+
```
223+
import {GroovyVariableMapping, ScriptType} from "@/components/script/typings";
224+
225+
export const VIEW_KEY = 'TriggerViewPlugin';
226+
227+
export interface TriggerViewPlugin {
228+
/** 脚本类型 */
229+
type: ScriptType;
230+
/** 当前脚本 */
231+
script: string;
232+
/** 变量映射列表 */
233+
variables: GroovyVariableMapping[];
234+
/** 确认回调 */
235+
onChange: (script: string) => void;
236+
}
237+
```
238+
239+
### 流程设计-动作配置
240+
241+
* 自定义按钮触发脚本界面
242+
```
243+
import {ActionSelectOption} from "@/components/script/typings";
244+
245+
export const VIEW_KEY = 'ConditionCustomViewPlugin';
246+
247+
export interface ConditionCustomViewPlugin {
248+
// 当前的脚本
249+
value?: string;
250+
// 脚本更改回掉
251+
onChange?: (value: string) => void;
252+
// 可选择的动作范围
253+
options:ActionSelectOption[];
254+
}
255+
```
256+
257+
* 拒绝动作界面
258+
```
259+
export const VIEW_KEY = 'ConditionRejectViewPlugin';
260+
261+
export interface ConditionRejectViewPlugin {
262+
// 当前节点id
263+
nodeId:string;
264+
// 当前的脚本
265+
value?: string;
266+
// 脚本更改回掉
267+
onChange?: (value: string) => void;
268+
}
269+
```
270+
271+
* 委派/转办/加签/界面 与(节点人员选择界面一致)
272+
```
273+
export const VIEW_KEY = 'OperatorLoadViewPlugin';
274+
275+
export interface OperatorLoadViewPlugin {
276+
/** 当前脚本 */
277+
script: string;
278+
/** 确认回调 */
279+
onChange: (script: string) => void;
280+
}
281+
```

flow-engine-framework/src/main/java/com/codingapi/flow/action/actions/CustomAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public CustomAction() {
3636
this.enable = true;
3737
this.type = ActionType.CUSTOM.name();
3838
this.display = new ActionDisplay(this.title);
39-
this.script = CustomScript.defaultCustomScript();
39+
this.script = CustomScript.defaultScript();
4040
}
4141

4242
@Override

flow-engine-framework/src/main/java/com/codingapi/flow/action/actions/RejectAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public RejectAction() {
3535
this.enable = true;
3636
this.type = ActionType.REJECT.name();
3737
this.display = new ActionDisplay(this.title);
38-
this.script = RejectActionScript.startScript();
38+
this.script = RejectActionScript.defaultScript();
3939
}
4040

4141
@Override

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());

flow-engine-framework/src/main/java/com/codingapi/flow/script/ScriptDefaultConstants.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@
55
*/
66
public class ScriptDefaultConstants {
77

8+
/**
9+
* 默认自定义动作脚本
10+
*/
11+
public static final String SCRIPT_DEFAULT_ACTION_CUSTOM = """
12+
// @SCRIPT_TITLE 默认条件 触发通过
13+
def run(request){
14+
return 'PASS';
15+
}
16+
""";
17+
18+
19+
/**
20+
* 默认拒绝动作脚本
21+
*/
22+
public static final String SCRIPT_DEFAULT_ACTION_REJECT = """
23+
// @SCRIPT_TITLE 返回开始节点
24+
// @SCRIPT_META {"type":"START"}
25+
def run(request){
26+
return request.getStartNode().getId();
27+
}
28+
""";
29+
830
/**
931
* 默认条件脚本
1032
*/

flow-engine-framework/src/main/java/com/codingapi/flow/script/action/CustomScript.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.codingapi.flow.script.action;
22

3+
import com.codingapi.flow.script.ScriptDefaultConstants;
34
import com.codingapi.flow.script.runtime.ScriptRuntimeContext;
45
import com.codingapi.flow.session.FlowSession;
56
import lombok.AllArgsConstructor;
@@ -11,8 +12,6 @@
1112
@AllArgsConstructor
1213
public class CustomScript {
1314

14-
public static final String SCRIPT_DEFAULT = "def run(session){return 'PASS'}";
15-
1615
@Getter
1716
private final String script;
1817

@@ -26,8 +25,8 @@ public String execute(FlowSession session) {
2625
/**
2726
* 默认节点脚本
2827
*/
29-
public static CustomScript defaultCustomScript() {
30-
return new CustomScript(SCRIPT_DEFAULT);
28+
public static CustomScript defaultScript() {
29+
return new CustomScript(ScriptDefaultConstants.SCRIPT_DEFAULT_ACTION_CUSTOM);
3130
}
3231

3332
}

0 commit comments

Comments
 (0)