Skip to content

Commit 4d80f7c

Browse files
committed
add-audit
1 parent 00619af commit 4d80f7c

10 files changed

Lines changed: 271 additions & 92 deletions

File tree

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.codingapi.flow.workflow.Workflow;
1515
import lombok.AllArgsConstructor;
1616
import lombok.Getter;
17+
import org.springframework.util.StringUtils;
1718

1819
import java.util.List;
1920

@@ -60,6 +61,7 @@ public void verify(FlowForm form) {
6061

6162
public void verifySession(FlowSession session) {
6263
FlowAdvice flowAdvice = session.getAdvice();
64+
NodeStrategyManager nodeStrategyManager = session.getCurrentNode().strategyManager();
6365

6466
IFlowAction flowAction = flowAdvice.getAction();
6567
// 保存操作,不做检查
@@ -72,9 +74,33 @@ public void verifySession(FlowSession session) {
7274
return;
7375
}
7476

75-
// 保存操作,不做检查
76-
if (flowAction instanceof PassAction) {
77+
// 通过操作
78+
if (flowAction instanceof PassAction ) {
7779
session.getFormData().verify();
80+
81+
// 是否必须填写审批意见
82+
if (nodeStrategyManager.isAdviceRequired()) {
83+
if (!StringUtils.hasText(flowAdvice.getAdvice())) {
84+
throw FlowValidationException.required("advice");
85+
}
86+
}
87+
88+
// 是否必须签名
89+
if (nodeStrategyManager.isSignRequired()) {
90+
if (!StringUtils.hasText(flowAdvice.getSignKey())) {
91+
throw FlowValidationException.required("signKey");
92+
}
93+
}
94+
}
95+
96+
// 通过操作
97+
if (flowAction instanceof RejectAction ) {
98+
// 是否必须填写审批意见
99+
if (nodeStrategyManager.isAdviceRequired()) {
100+
if (!StringUtils.hasText(flowAdvice.getAdvice())) {
101+
throw FlowValidationException.required("advice");
102+
}
103+
}
78104
}
79105

80106
// 加签操作、转办操作、委托操作

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
package com.codingapi.flow.manager;
22

3-
import com.codingapi.flow.action.IFlowAction;
4-
import com.codingapi.flow.action.actions.PassAction;
5-
import com.codingapi.flow.action.actions.RejectAction;
63
import com.codingapi.flow.error.ErrorThrow;
7-
import com.codingapi.flow.exception.FlowValidationException;
84
import com.codingapi.flow.form.FlowForm;
9-
import com.codingapi.flow.session.FlowAdvice;
105
import com.codingapi.flow.session.FlowSession;
116
import com.codingapi.flow.strategy.node.*;
127
import lombok.Getter;
13-
import org.springframework.util.StringUtils;
148

159
import java.util.ArrayList;
1610
import java.util.List;
@@ -161,30 +155,6 @@ public OperatorManager loadOperators(FlowSession session) {
161155
}
162156

163157
public void verifySession(FlowSession session) {
164-
165-
FlowAdvice flowAdvice = session.getAdvice();
166-
IFlowAction flowAction = flowAdvice.getAction();
167-
168-
169-
// 通过操作
170-
if (flowAction instanceof PassAction || flowAction instanceof RejectAction) {
171-
172-
// 是否必须填写审批意见
173-
if (this.isAdviceRequired()) {
174-
if (!StringUtils.hasText(flowAdvice.getAdvice())) {
175-
throw FlowValidationException.required("advice");
176-
}
177-
}
178-
179-
// 是否必须签名
180-
if (this.isSignRequired()) {
181-
if (!StringUtils.hasText(flowAdvice.getSignKey())) {
182-
throw FlowValidationException.required("signKey");
183-
}
184-
}
185-
186-
}
187-
188158
for (INodeStrategy strategy : strategies) {
189159
strategy.verifySession(session);
190160
}
Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,69 @@
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 {AddAuditView} from "@/components/flow-approval/plugins/view/add-audit-view";
56

67
export const AddAuditAction: React.FC<FlowActionProps> = (props) => {
78

89
const action = props.action;
9-
const {context} = useApprovalContext()
10+
const {context} = useApprovalContext();
11+
const [form] = Form.useForm();
12+
1013
const actionPresenter = context.getPresenter().getFlowActionPresenter();
1114

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

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

Lines changed: 38 additions & 27 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 {Button, Form, Input, message, Modal} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
5+
import {SignKeyView} from "@/components/flow-approval/plugins/view/sign-key-view";
56

67
const {TextArea} = Input;
78

@@ -15,10 +16,12 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
1516

1617
const isStartNode = state.flow?.nodeType === 'START';
1718

19+
const currentOperator = state.flow?.currentOperator;
20+
1821
const [form] = Form.useForm();
1922

20-
const handleSubmit = (params?:any) => {
21-
actionPresenter.action(action.id,params).then((res) => {
23+
const handleSubmit = (params?: any) => {
24+
actionPresenter.action(action.id, params).then((res) => {
2225
if (res.success) {
2326
message.success("操作成功");
2427
setModalVisible(false);
@@ -27,27 +30,21 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
2730
});
2831
}
2932

30-
const adviceRules =state.flow?.adviceRequired? [
33+
const adviceRules = state.flow?.adviceRequired ? [
3134
{
3235
required: state.flow?.adviceRequired || false,
33-
message:'请输入审批意见'
34-
}
35-
]:[];
36-
37-
const signRules = state.flow?.signRequired ?[
38-
{
39-
required: state.flow?.signRequired || false,
40-
message:'请设置签名'
36+
message: '请输入审批意见'
4137
}
42-
]:[];
38+
] : [];
4339

4440
return (
4541
<>
4642
<Button
4743
onClick={() => {
48-
if(isStartNode) {
44+
if (isStartNode) {
4945
handleSubmit();
50-
}else {
46+
} else {
47+
form.resetFields();
5148
setModalVisible(true);
5249
}
5350
}}
@@ -56,20 +53,23 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
5653
</Button>
5754

5855
<Modal
59-
title={"流程审批"}
56+
title={"审批通过"}
6057
open={modalVisible}
61-
onCancel={()=>setModalVisible(false)}
62-
onOk={()=>{
58+
destroyOnHidden
59+
onCancel={() => setModalVisible(false)}
60+
onOk={() => {
6361
form.submit();
6462
}}
6563
>
6664
<Form
6765
form={form}
6866
layout="vertical"
69-
onFinish={(values)=>{
67+
onFinish={(values) => {
7068
handleSubmit(values);
7169
}}
7270
>
71+
72+
7373
<Form.Item
7474
name={"advice"}
7575
label={"审批意见"}
@@ -79,14 +79,25 @@ export const PassAction: React.FC<FlowActionProps> = (props) => {
7979
<TextArea placeholder={"请输入审批意见"}/>
8080
</Form.Item>
8181

82-
<Form.Item
83-
name={"signKey"}
84-
label={"签名"}
85-
required={state.flow?.signRequired}
86-
rules={signRules}
87-
>
88-
<TextArea placeholder={"请输入审批签名"}/>
89-
</Form.Item>
82+
83+
84+
{state.flow?.signRequired && currentOperator && (
85+
<Form.Item
86+
name={"signKey"}
87+
label={"审批签名"}
88+
required={state.flow?.signRequired}
89+
rules={[
90+
{
91+
required: true,
92+
message: '请设置审批签名'
93+
}
94+
]}
95+
>
96+
<SignKeyView
97+
current={currentOperator}
98+
/>
99+
</Form.Item>
100+
)}
90101
</Form>
91102

92103
</Modal>
Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,71 @@
11
import React from "react";
22
import {FlowActionProps} from "./type";
3-
import {Button, message} from "antd";
3+
import {Button, Form, message, Modal,Input} from "antd";
44
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
55

6+
const {TextArea} = Input;
7+
68
export const RejectAction: React.FC<FlowActionProps> = (props) => {
79

810
const action = props.action;
9-
const {context} = useApprovalContext()
11+
const {state,context} = useApprovalContext()
1012
const actionPresenter = context.getPresenter().getFlowActionPresenter();
13+
const [modalVisible, setModalVisible] = React.useState(false);
14+
const [form] = Form.useForm();
15+
16+
const handleSubmit = (params?: any) => {
17+
actionPresenter.action(action.id, params).then((res) => {
18+
if (res.success) {
19+
message.success("操作成功");
20+
setModalVisible(false);
21+
context.close();
22+
}
23+
});
24+
}
25+
26+
const adviceRules = state.flow?.adviceRequired ? [
27+
{
28+
required: state.flow?.adviceRequired || false,
29+
message: '请输入审批意见'
30+
}
31+
] : [];
1132

1233
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>
34+
<>
35+
<Button
36+
onClick={() => {
37+
form.resetFields();
38+
setModalVisible(true);
39+
}}
40+
>
41+
{action.title}
42+
</Button>
43+
44+
<Modal
45+
title={"审批拒绝"}
46+
open={modalVisible}
47+
onCancel={() => setModalVisible(false)}
48+
onOk={() => {
49+
form.submit();
50+
}}
51+
>
52+
<Form
53+
form={form}
54+
layout="vertical"
55+
onFinish={(values) => {
56+
handleSubmit(values);
57+
}}
58+
>
59+
<Form.Item
60+
name={"advice"}
61+
label={"拒绝意见"}
62+
required={state.flow?.adviceRequired}
63+
rules={adviceRules}
64+
>
65+
<TextArea placeholder={"请输入拒绝意见"}/>
66+
</Form.Item>
67+
</Form>
68+
</Modal>
69+
</>
2670
)
2771
}

0 commit comments

Comments
 (0)