Skip to content

Commit e082cce

Browse files
committed
add approval action
1 parent 7a4e902 commit e082cce

20 files changed

Lines changed: 416 additions & 64 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ public class FlowContent {
119119
*/
120120
private List<History> histories;
121121

122+
/**
123+
* 所有节点
124+
*/
125+
private List<NodeOption> nodes;
126+
122127

123128
public void pushCurrentNode(IFlowNode currentNode) {
124129
ActionManager actionManager = currentNode.actionManager();
@@ -137,6 +142,7 @@ public void pushWorkflow(Workflow workflow) {
137142
this.form = workflow.getForm();
138143
this.workCode = workflow.getCode();
139144
this.workId = workflow.getId();
145+
this.nodes = workflow.getNodes().stream().map(NodeOption::new).toList();
140146
}
141147

142148
public void pushRecords(FlowRecord record, List<FlowRecord> mergeRecords) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.codingapi.flow.pojo.response;
2+
3+
import com.codingapi.flow.node.IDisplayNode;
4+
import com.codingapi.flow.node.IFlowNode;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Getter;
7+
8+
@Getter
9+
@AllArgsConstructor
10+
public class NodeOption {
11+
12+
private String id;
13+
private String name;
14+
private String type;
15+
private boolean display;
16+
17+
public NodeOption(IFlowNode node) {
18+
this.id = node.getId();
19+
this.name = node.getName();
20+
this.type = node.getType();
21+
this.display = node instanceof IDisplayNode;
22+
}
23+
}

flow-engine-starter-api/src/main/java/com/codingapi/flow/api/controller/FlowRecordController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public MultiResponse<ProcessNode> processNodes(@RequestBody FlowProcessNodeReque
3737
return MultiResponse.of(flowService.processNodes(request));
3838
}
3939

40-
4140
@PostMapping("/create")
4241
public SingleResponse<Long> create(@RequestBody FlowCreateRequest request) {
4342
IFlowOperator current = (IFlowOperator) UserContext.getInstance().current();

flow-engine-starter-api/src/main/java/com/codingapi/flow/api/pojo/SelectOption.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import {Button, 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";
66

7+
/**
8+
* 加签
9+
* @param props
10+
* @constructor
11+
*/
712
export const AddAuditAction: React.FC<FlowActionProps> = (props) => {
813

914
const action = props.action;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import {FlowActionProps} from "./type";
33
import {Button, message} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55

6+
/**
7+
* 自定义
8+
* @param props
9+
* @constructor
10+
*/
611
export const CustomAction: React.FC<FlowActionProps> = (props) => {
712

813
const action = props.action;
Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,74 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, message} from "antd";
3+
import {Button, Form, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
5+
import {DelegateView} from "@/components/flow-approval/plugins/view/delegate-view";
56

7+
/**
8+
* 委派
9+
* @param props
10+
* @constructor
11+
*/
612
export const DelegateAction: React.FC<FlowActionProps> = (props) => {
713

814
const action = props.action;
9-
const {context} = useApprovalContext()
15+
const {context} = useApprovalContext();
16+
const [form] = Form.useForm();
17+
1018
const actionPresenter = context.getPresenter().getFlowActionPresenter();
1119

20+
const [modalVisible, setModalVisible] = React.useState(false);
21+
22+
const handleSubmit = (params?: any) => {
23+
actionPresenter.action(action.id, params).then((res) => {
24+
if (res.success) {
25+
message.success("操作成功");
26+
setModalVisible(false);
27+
context.close();
28+
}
29+
});
30+
}
1231
return (
13-
<Button
14-
danger={action.type === 'REJECT'}
15-
onClick={() => {
16-
actionPresenter.action(action.id).then((res) => {
17-
if (res.success) {
18-
message.success("操作成功");
19-
context.close();
20-
}
21-
});
22-
}}
23-
>
24-
{action.title}
25-
</Button>
32+
<>
33+
<Button
34+
onClick={() => {
35+
form.resetFields();
36+
setModalVisible(true);
37+
}}
38+
>
39+
{action.title}
40+
</Button>
41+
42+
<Modal
43+
title={"委派审批"}
44+
open={modalVisible}
45+
onCancel={() => setModalVisible(false)}
46+
onOk={() => {
47+
form.submit();
48+
}}
49+
>
50+
<Form
51+
form={form}
52+
layout="vertical"
53+
onFinish={(values) => {
54+
handleSubmit(values);
55+
}}
56+
>
57+
<Form.Item
58+
name={"forwardOperatorIds"}
59+
label={"委派人员"}
60+
required={true}
61+
rules={[
62+
{
63+
required: true,
64+
message:'委派人员不能为空'
65+
}
66+
]}
67+
>
68+
<DelegateView/>
69+
</Form.Item>
70+
</Form>
71+
</Modal>
72+
</>
2673
)
2774
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import {SignKeyView} from "@/components/flow-approval/plugins/view/sign-key-view
66

77
const {TextArea} = Input;
88

9+
/**
10+
* 通过
11+
* @param props
12+
* @constructor
13+
*/
914
export const PassAction: React.FC<FlowActionProps> = (props) => {
1015

1116
const action = props.action;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-
55

66
const {TextArea} = Input;
77

8+
/**
9+
* 拒绝
10+
* @param props
11+
* @constructor
12+
*/
813
export const RejectAction: React.FC<FlowActionProps> = (props) => {
914

1015
const action = props.action;
Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,74 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, message} from "antd";
3+
import {Button, Form, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
5+
import {ReturnView} from "@/components/flow-approval/plugins/view/return-view";
56

7+
/**
8+
* 退回
9+
* @param props
10+
* @constructor
11+
*/
612
export const ReturnAction: React.FC<FlowActionProps> = (props) => {
713

814
const action = props.action;
9-
const {context} = useApprovalContext()
15+
const {context} = useApprovalContext();
16+
const [form] = Form.useForm();
17+
1018
const actionPresenter = context.getPresenter().getFlowActionPresenter();
1119

20+
const [modalVisible, setModalVisible] = React.useState(false);
21+
22+
const handleSubmit = (params?: any) => {
23+
actionPresenter.action(action.id, params).then((res) => {
24+
if (res.success) {
25+
message.success("操作成功");
26+
setModalVisible(false);
27+
context.close();
28+
}
29+
});
30+
}
1231
return (
13-
<Button
14-
danger={action.type === 'REJECT'}
15-
onClick={() => {
16-
actionPresenter.action(action.id).then((res) => {
17-
if (res.success) {
18-
message.success("操作成功");
19-
context.close();
20-
}
21-
});
22-
}}
23-
>
24-
{action.title}
25-
</Button>
32+
<>
33+
<Button
34+
onClick={() => {
35+
form.resetFields();
36+
setModalVisible(true);
37+
}}
38+
>
39+
{action.title}
40+
</Button>
41+
42+
<Modal
43+
title={"退回审批"}
44+
open={modalVisible}
45+
onCancel={() => setModalVisible(false)}
46+
onOk={() => {
47+
form.submit();
48+
}}
49+
>
50+
<Form
51+
form={form}
52+
layout="vertical"
53+
onFinish={(values) => {
54+
handleSubmit(values);
55+
}}
56+
>
57+
<Form.Item
58+
name={"backNodeId"}
59+
label={"退回节点"}
60+
required={true}
61+
rules={[
62+
{
63+
required: true,
64+
message: '退回节点不能为空'
65+
}
66+
]}
67+
>
68+
<ReturnView/>
69+
</Form.Item>
70+
</Form>
71+
</Modal>
72+
</>
2673
)
2774
}

0 commit comments

Comments
 (0)