Skip to content

Commit 9c1345e

Browse files
committed
update custom
1 parent 989924d commit 9c1345e

3 files changed

Lines changed: 40 additions & 21 deletions

File tree

  • flow-engine-framework/src/main/java/com/codingapi/flow/pojo/response
  • frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval

flow-engine-framework/src/main/java/com/codingapi/flow/pojo/response/FlowContent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class FlowContent {
8787
/**
8888
* 流程按钮
8989
*/
90-
private List<IFlowAction> actions;
90+
private List<Map<String,Object>> actions;
9191

9292
/**
9393
* 是否可合并
@@ -128,7 +128,7 @@ public class FlowContent {
128128
public void pushCurrentNode(IFlowNode currentNode) {
129129
ActionManager actionManager = currentNode.actionManager();
130130
NodeStrategyManager strategyManager = currentNode.strategyManager();
131-
this.actions = actionManager.getActions();
131+
this.actions = actionManager.getActions().stream().map(IFlowAction::toMap).toList();
132132
this.adviceRequired = strategyManager.isAdviceRequired();
133133
this.signRequired = strategyManager.isSignRequired();
134134
this.nodeId = currentNode.getId();

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from "react";
22
import {FlowActionProps} from "./type";
33
import {Button, message} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
5+
import {GroovyScriptConvertorUtil} from "@flow-engine/flow-core";
6+
import {ActionFactory} from "@/components/flow-approval/components/action/factory";
57

68
/**
79
* 自定义
@@ -14,6 +16,20 @@ export const CustomAction: React.FC<FlowActionProps> = (props) => {
1416
const {context} = useApprovalContext()
1517
const actionPresenter = context.getPresenter().getFlowActionPresenter();
1618

19+
const script = action.script || '';
20+
const returnData = GroovyScriptConvertorUtil.getReturnScript(script);
21+
const triggerType = returnData.replaceAll('\'', '');
22+
23+
24+
const ActionView = ActionFactory.getInstance().render({
25+
...props.action,
26+
type: triggerType,
27+
});
28+
29+
if (ActionView) {
30+
return ActionView
31+
}
32+
1733
return (
1834
<Button
1935
onClick={() => {
Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {FlowApprovalApi, State} from "@/components/flow-approval/typings";
22
import {FormActionContext} from "@flow-engine/flow-types";
3+
import {GroovyScriptConvertorUtil} from "@flow-engine/flow-core";
34

45
export class FlowActionPresenter {
56

67
private readonly api: FlowApprovalApi;
7-
private readonly formActionContext:FormActionContext;
8+
private readonly formActionContext: FormActionContext;
89
private state: State;
910

1011
constructor(state: State,
1112
api: FlowApprovalApi,
12-
formActionContext:FormActionContext) {
13+
formActionContext: FormActionContext) {
1314
this.state = state;
1415
this.api = api;
1516
this.formActionContext = formActionContext;
@@ -19,7 +20,7 @@ export class FlowActionPresenter {
1920
this.state = state;
2021
}
2122

22-
public async processNodes(){
23+
public async processNodes() {
2324
const formData = this.formActionContext.save();
2425
const id = this.state.flow?.recordId || this.state.flow?.workId || '';
2526
return await this.api.processNodes({
@@ -34,38 +35,40 @@ export class FlowActionPresenter {
3435
* @param actionId
3536
* @private
3637
*/
37-
private isPassAction(actionId:string){
38+
private isPassAction(actionId: string) {
3839
const actions = this.state.flow?.actions || [];
39-
for(const action of actions){
40-
if(action.id === actionId){
41-
if(action.type ==='PASS'){
40+
for (const action of actions) {
41+
if (action.id === actionId) {
42+
if (action.type === 'PASS') {
4243
return true;
4344
}
44-
if(action.type === 'CUSTOM'){
45+
if (action.type === 'CUSTOM') {
4546
const script = action.script || '';
46-
47-
47+
const returnData = GroovyScriptConvertorUtil.getReturnScript(script);
48+
if (returnData.includes('PASS')) {
49+
return true;
50+
}
4851
}
4952
}
5053
}
5154
return false;
5255
}
5356

5457

55-
private async submitAction(actionId:string,formData:any,params?:any){
58+
private async submitAction(actionId: string, formData: any, params?: any) {
5659
const recordId = this.state.flow?.recordId;
5760
const workId = this.state.flow?.workId;
58-
if(recordId){
61+
if (recordId) {
5962
const request = {
6063
formData,
6164
recordId,
62-
advice:{
65+
advice: {
6366
actionId,
6467
...params
6568
}
6669
}
6770
return await this.api.action(request);
68-
}else {
71+
} else {
6972
const createRequest = {
7073
workId,
7174
formData,
@@ -75,7 +78,7 @@ export class FlowActionPresenter {
7578
const actionRequest = {
7679
formData,
7780
recordId,
78-
advice:{
81+
advice: {
7982
actionId,
8083
...params
8184
}
@@ -85,14 +88,14 @@ export class FlowActionPresenter {
8588
}
8689

8790

88-
public async action(actionId:string,params?:any) {
91+
public async action(actionId: string, params?: any) {
8992
let formData;
90-
if(this.isPassAction(actionId)){
93+
if (this.isPassAction(actionId)) {
9194
formData = await this.formActionContext.validate();
92-
}else {
95+
} else {
9396
formData = this.formActionContext.save();
9497
}
95-
return await this.submitAction(actionId, formData,params);
98+
return await this.submitAction(actionId, formData, params);
9699
}
97100

98101
}

0 commit comments

Comments
 (0)