Skip to content

Commit 8a11e4a

Browse files
authored
Merge pull request #60 from codingapi/dev
Dev
2 parents b4b3e1c + 16ee3ae commit 8a11e4a

19 files changed

Lines changed: 1046 additions & 205 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/manager/FlowNodeState.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ public String getName() {
6666
}
6767

6868
public List<IFlowNode> getFirstBlocks() {
69-
List<IFlowNode> blocks = this.node.blocks().stream().sorted(Comparator.comparingInt(IFlowNode::getOrder)).toList();
70-
if (!blocks.isEmpty()) {
71-
return Stream.of(blocks.get(0)).toList();
69+
List<IFlowNode> blocks = this.node.blocks();
70+
if (blocks!=null && !blocks.isEmpty()) {
71+
List<IFlowNode> sortList = blocks.stream().sorted(Comparator.comparingInt(IFlowNode::getOrder)).toList();
72+
return Stream.of(sortList.get(0)).toList();
7273
}
7374
return new ArrayList<>();
7475
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import {Button} from "antd";
2+
import React from "react";
3+
import {DisplayStyle, FlowActionDisplay} from "@flow-engine/flow-types";
4+
import {Icon} from "@flow-engine/flow-pc-ui";
5+
6+
interface ActionButtonProps {
7+
onClick: () => void;
8+
title: string;
9+
display: FlowActionDisplay;
10+
}
11+
12+
export const ActionButton: React.FC<ActionButtonProps> = (props) => {
13+
14+
const display = props.display;
15+
const title = display.title || props.title;
16+
17+
const style = React.useMemo(() => {
18+
if (display) {
19+
const data = JSON.parse(display.style) as DisplayStyle | undefined;
20+
if (data) {
21+
let style = {}
22+
if (data.backgroundColor) {
23+
style = Object.assign(data, {backgroundColor: `#${data.backgroundColor}`});
24+
}
25+
if (data.borderColor) {
26+
style = Object.assign(data, {borderColor: `#${data.borderColor}`});
27+
}
28+
if (data.borderRadius) {
29+
style = Object.assign(data, {borderRadius: Number.parseInt(data.borderRadius)});
30+
}
31+
if (data.borderSize) {
32+
style = Object.assign(data, {borderWidth: Number.parseInt(data.borderSize)});
33+
}
34+
return style;
35+
}
36+
}
37+
return {}
38+
}, [display]);
39+
40+
41+
return (
42+
<Button
43+
onClick={props.onClick}
44+
style={style}
45+
icon={<Icon type={display.icon} />}
46+
>
47+
{title}
48+
</Button>
49+
)
50+
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, Form, message, Modal} from "antd";
3+
import {Form, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55
import {AddAuditView} from "@/components/flow-approval/plugins/view/add-audit-view";
6+
import {ActionButton} from "@/components/flow-approval/components/action-button";
67

78
/**
89
* 加签
@@ -30,14 +31,14 @@ export const AddAuditAction: React.FC<FlowActionProps> = (props) => {
3031
}
3132
return (
3233
<>
33-
<Button
34+
<ActionButton
35+
display={props.action.display}
3436
onClick={() => {
3537
form.resetFields();
3638
setModalVisible(true);
3739
}}
38-
>
39-
{action.title}
40-
</Button>
40+
title={action.title}
41+
/>
4142

4243
<Modal
4344
title={"加签审批"}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, message} from "antd";
3+
import {message} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55
import {GroovyScriptConvertorUtil} from "@flow-engine/flow-core";
66
import {ActionFactory} from "@/components/flow-approval/components/action/factory";
7+
import {ActionButton} from "@/components/flow-approval/components/action-button";
78

89
/**
910
* 自定义
@@ -31,7 +32,8 @@ export const CustomAction: React.FC<FlowActionProps> = (props) => {
3132
}
3233

3334
return (
34-
<Button
35+
<ActionButton
36+
display={props.action.display}
3537
onClick={() => {
3638
actionPresenter.action(action.id).then((res) => {
3739
if (res.success) {
@@ -40,8 +42,7 @@ export const CustomAction: React.FC<FlowActionProps> = (props) => {
4042
}
4143
});
4244
}}
43-
>
44-
{action.title}
45-
</Button>
45+
title={action.title}
46+
/>
4647
)
4748
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, Form, message, Modal} from "antd";
3+
import {Form, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55
import {DelegateView} from "@/components/flow-approval/plugins/view/delegate-view";
6+
import {ActionButton} from "@/components/flow-approval/components/action-button";
67

78
/**
89
* 委派
@@ -30,14 +31,14 @@ export const DelegateAction: React.FC<FlowActionProps> = (props) => {
3031
}
3132
return (
3233
<>
33-
<Button
34+
<ActionButton
35+
display={props.action.display}
3436
onClick={() => {
3537
form.resetFields();
3638
setModalVisible(true);
3739
}}
38-
>
39-
{action.title}
40-
</Button>
40+
title={action.title}
41+
/>
4142

4243
<Modal
4344
title={"委派审批"}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, Form, Input, message, Modal} from "antd";
3+
import {Form, Input, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55
import {SignKeyView} from "@/components/flow-approval/plugins/view/sign-key-view";
6+
import {ActionButton} from "@/components/flow-approval/components/action-button";
67

78
const {TextArea} = Input;
89

@@ -44,7 +45,8 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
4445

4546
return (
4647
<>
47-
<Button
48+
<ActionButton
49+
display={props.action.display}
4850
onClick={() => {
4951
if (isStartNode) {
5052
handleSubmit();
@@ -53,9 +55,8 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
5355
setModalVisible(true);
5456
}
5557
}}
56-
>
57-
{action.title}
58-
</Button>
58+
title={action.title}
59+
/>
5960

6061
<Modal
6162
title={"审批通过"}
@@ -85,7 +86,6 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
8586
</Form.Item>
8687

8788

88-
8989
{state.flow?.signRequired && currentOperator && (
9090
<Form.Item
9191
name={"signKey"}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, Form, message, Modal,Input} from "antd";
3+
import {Form, Input, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
5+
import {ActionButton} from "@/components/flow-approval/components/action-button";
56

67
const {TextArea} = Input;
78

@@ -13,7 +14,7 @@ const {TextArea} = Input;
1314
export const RejectAction: React.FC<FlowActionProps> = (props) => {
1415

1516
const action = props.action;
16-
const {state,context} = useApprovalContext()
17+
const {state, context} = useApprovalContext()
1718
const actionPresenter = context.getPresenter().getFlowActionPresenter();
1819
const [modalVisible, setModalVisible] = React.useState(false);
1920
const [form] = Form.useForm();
@@ -37,14 +38,14 @@ export const RejectAction: React.FC<FlowActionProps> = (props) => {
3738

3839
return (
3940
<>
40-
<Button
41+
<ActionButton
42+
display={props.action.display}
4143
onClick={() => {
4244
form.resetFields();
4345
setModalVisible(true);
4446
}}
45-
>
46-
{action.title}
47-
</Button>
47+
title={action.title}
48+
/>
4849

4950
<Modal
5051
title={"审批拒绝"}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {FlowActionProps} from "./type";
33
import {Button, Form, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55
import {ReturnView} from "@/components/flow-approval/plugins/view/return-view";
6+
import {ActionButton} from "@/components/flow-approval/components/action-button";
67

78
/**
89
* 退回
@@ -30,14 +31,14 @@ export const ReturnAction: React.FC<FlowActionProps> = (props) => {
3031
}
3132
return (
3233
<>
33-
<Button
34+
<ActionButton
35+
display={props.action.display}
3436
onClick={() => {
3537
form.resetFields();
3638
setModalVisible(true);
3739
}}
38-
>
39-
{action.title}
40-
</Button>
40+
title={action.title}
41+
/>
4142

4243
<Modal
4344
title={"退回审批"}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, message} from "antd";
3+
import {message} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
5+
import {ActionButton} from "@/components/flow-approval/components/action-button";
56

67
/**
78
* 保存
@@ -15,16 +16,16 @@ export const SaveAction: React.FC<FlowActionProps> = (props) => {
1516
const actionPresenter = context.getPresenter().getFlowActionPresenter();
1617

1718
return (
18-
<Button
19+
<ActionButton
20+
display={props.action.display}
1921
onClick={() => {
2022
actionPresenter.action(action.id).then((res) => {
2123
if (res.success) {
2224
message.success("流程数据已保存");
2325
}
2426
});
2527
}}
26-
>
27-
{action.title}
28-
</Button>
28+
title={action.title}
29+
/>
2930
)
3031
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, Form, message, Modal} from "antd";
3+
import {Form, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55
import {TransferView} from "@/components/flow-approval/plugins/view/transfer-view";
6+
import {ActionButton} from "@/components/flow-approval/components/action-button";
67

78
/**
89
* 转办
@@ -30,14 +31,14 @@ export const TransferAction: React.FC<FlowActionProps> = (props) => {
3031
}
3132
return (
3233
<>
33-
<Button
34+
<ActionButton
35+
display={props.action.display}
3436
onClick={() => {
3537
form.resetFields();
3638
setModalVisible(true);
3739
}}
38-
>
39-
{action.title}
40-
</Button>
40+
title={action.title}
41+
/>
4142

4243
<Modal
4344
title={"转办审批"}

0 commit comments

Comments
 (0)