Skip to content

Commit ed1e2e2

Browse files
committed
1 parent be09a04 commit ed1e2e2

File tree

6 files changed

+131
-25
lines changed

6 files changed

+131
-25
lines changed

admin-ui/src/api/flow.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ export async function submitFlow(body:any) {
4646
return post('/api/cmd/flowRecord/submitFlow', body);
4747
}
4848

49+
export async function recall(body:any) {
50+
return post('/api/cmd/flowRecord/recall', body);
51+
}
52+
53+
export async function postponed(body:any) {
54+
return post('/api/cmd/flowRecord/postponed', body);
55+
}
56+
57+
4958
// 待办中心控制
5059

5160
export async function flowRecordList(params: any,

admin-ui/src/components/Flow/view/FlowView.tsx

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import {Button, Divider, Form, message, Modal, Row, Space, Tabs} from "antd";
3-
import {detail, saveFlow, submitFlow} from "@/api/flow";
4-
import {ProDescriptions, ProForm, ProFormTextArea} from "@ant-design/pro-components";
3+
import {detail, postponed, recall, saveFlow, submitFlow} from "@/api/flow";
4+
import {ModalForm, ProDescriptions, ProForm, ProFormDigit, ProFormTextArea} from "@ant-design/pro-components";
55
import moment from "moment";
66

77

@@ -23,6 +23,8 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
2323

2424
const [data, setData] = React.useState<any>(null);
2525

26+
const [postponedVisible, setPostponedVisible] = React.useState(false);
27+
2628
const [viewForm] = Form.useForm();
2729

2830
const [opinionForm] = Form.useForm();
@@ -48,6 +50,35 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
4850
})
4951
}
5052

53+
54+
const handleRecallFlow = () => {
55+
const recordId = props.id;
56+
const body = {
57+
recordId,
58+
}
59+
recall(body).then(res => {
60+
if (res.success) {
61+
message.success('流程已撤回').then();
62+
props.setVisible(false);
63+
}
64+
})
65+
}
66+
67+
68+
const handlePostponedFlow = (values: any) => {
69+
const recordId = props.id;
70+
const body = {
71+
recordId,
72+
timeOut: values.hours * 1000 * 60 * 60
73+
}
74+
postponed(body).then(res => {
75+
if (res.success) {
76+
message.success('已经延期').then();
77+
setPostponedVisible(false)
78+
}
79+
})
80+
}
81+
5182
const handleSubmitFlow = (success: boolean) => {
5283
const advice = opinionForm.getFieldValue('advice');
5384
const recordId = props.id;
@@ -188,13 +219,19 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
188219
{!props.review && (
189220
<Button
190221
type={"primary"}
222+
onClick={() => {
223+
setPostponedVisible(true);
224+
}}
191225
danger={true}
192226
>延期</Button>
193227
)}
194228

195229
{!props.review && (
196230
<Button
197231
type={"primary"}
232+
onClick={() => {
233+
handleRecallFlow();
234+
}}
198235
danger={true}
199236
>撤销</Button>
200237
)}
@@ -373,6 +410,35 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
373410
)}
374411

375412

413+
<ModalForm
414+
title={"延期调整"}
415+
open={postponedVisible}
416+
modalProps={{
417+
onCancel: () => {
418+
setPostponedVisible(false);
419+
},
420+
onClose: () => {
421+
setPostponedVisible(false);
422+
}
423+
}}
424+
onFinish={async (values) => {
425+
handlePostponedFlow(values);
426+
}}
427+
428+
>
429+
<ProFormDigit
430+
name={"hours"}
431+
label={"延期时间"}
432+
rules={[
433+
{
434+
required: true,
435+
message: "请输入延期时间"
436+
}
437+
]}
438+
/>
439+
</ModalForm>
440+
441+
376442
</Modal>
377443
)
378444
}

admin-ui/src/pages/flow/leave/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const LeavePage = () => {
4747
const handleStartFlow = async (values: any) => {
4848
const res = await startLeave(values);
4949
if (res.success) {
50-
message.success("发起成功");
50+
message.success("发起成功,请到待办中心");
5151
setVisible(false);
5252
actionRef.current?.reload();
5353
}

admin-ui/src/pages/flow/record/index.tsx

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, {useEffect} from "react";
2-
import {ActionType, PageContainer, ProTable} from "@ant-design/pro-components";
2+
import {ActionType, ModalForm, PageContainer, ProFormDigit, ProFormText, ProTable} from "@ant-design/pro-components";
33
import {
44
findDoneByOperatorId,
5-
findInitiatedByOperatorId, findPostponedTodoByOperatorId,
5+
findInitiatedByOperatorId,
6+
findPostponedTodoByOperatorId,
67
findTimeoutTodoByOperatorId,
78
findTodoByOperatorId,
89
flowRecordList
@@ -19,9 +20,14 @@ const FlowRecordPage = () => {
1920
const [currentId, setCurrentId] = React.useState<number>(0);
2021
const [reviewVisible, setReviewVisible] = React.useState(false);
2122

22-
const [key, setKey] = React.useState('todo');
23-
const actionRef = React.useRef<ActionType>();
2423

24+
const [key, setKey] = React.useState('todo');
25+
const todoActionRef = React.useRef<ActionType>();
26+
const doneActionRef = React.useRef<ActionType>();
27+
const initiatedActionRef = React.useRef<ActionType>();
28+
const timeoutTodoActionRef = React.useRef<ActionType>();
29+
const postponedTodoActionRef = React.useRef<ActionType>();
30+
const allTodoActionRef = React.useRef<ActionType>();
2531
const columns = [
2632
{
2733
title: '编号',
@@ -116,15 +122,15 @@ const FlowRecordPage = () => {
116122
return [
117123
<a
118124
key={"detail"}
119-
onClick={()=>{
125+
onClick={() => {
120126
setCurrentId(record.id);
121127
setReviewVisible(true);
122128
setFlowViewVisible(true);
123129
}}
124130
>详情</a>,
125131
<a
126132
key={"submit"}
127-
onClick={()=>{
133+
onClick={() => {
128134
setCurrentId(record.id);
129135
setReviewVisible(false);
130136
setFlowViewVisible(true);
@@ -139,10 +145,25 @@ const FlowRecordPage = () => {
139145

140146

141147
useEffect(() => {
142-
if(!flowViewVisible){
143-
actionRef.current?.reload();
148+
if (key === 'todo') {
149+
todoActionRef.current?.reload();
150+
}
151+
if (key === 'done') {
152+
doneActionRef.current?.reload();
153+
}
154+
if (key === 'initiated') {
155+
initiatedActionRef.current?.reload();
144156
}
145-
}, [flowViewVisible,key]);
157+
if (key === 'timeoutTodo') {
158+
timeoutTodoActionRef.current?.reload();
159+
}
160+
if (key === 'postponedTodo') {
161+
postponedTodoActionRef.current?.reload();
162+
}
163+
if (key === 'all') {
164+
allTodoActionRef.current?.reload();
165+
}
166+
}, [flowViewVisible, key]);
146167

147168
return (
148169
<PageContainer>
@@ -157,7 +178,7 @@ const FlowRecordPage = () => {
157178
key: 'todo',
158179
children: (
159180
<ProTable
160-
actionRef={actionRef}
181+
actionRef={todoActionRef}
161182
search={false}
162183
columns={columns}
163184
request={async (params, sort, filter) => {
@@ -171,7 +192,7 @@ const FlowRecordPage = () => {
171192
key: 'done',
172193
children: (
173194
<ProTable
174-
actionRef={actionRef}
195+
actionRef={doneActionRef}
175196
search={false}
176197
columns={columns}
177198
request={async (params, sort, filter) => {
@@ -185,7 +206,7 @@ const FlowRecordPage = () => {
185206
key: 'initiated',
186207
children: (
187208
<ProTable
188-
actionRef={actionRef}
209+
actionRef={initiatedActionRef}
189210
search={false}
190211
columns={columns}
191212
request={async (params, sort, filter) => {
@@ -199,7 +220,7 @@ const FlowRecordPage = () => {
199220
key: 'timeoutTodo',
200221
children: (
201222
<ProTable
202-
actionRef={actionRef}
223+
actionRef={timeoutTodoActionRef}
203224
search={false}
204225
columns={columns}
205226
request={async (params, sort, filter) => {
@@ -214,7 +235,7 @@ const FlowRecordPage = () => {
214235
key: 'postponedTodo',
215236
children: (
216237
<ProTable
217-
actionRef={actionRef}
238+
actionRef={postponedTodoActionRef}
218239
search={false}
219240
columns={columns}
220241
request={async (params, sort, filter) => {
@@ -228,7 +249,7 @@ const FlowRecordPage = () => {
228249
key: 'all',
229250
children: (
230251
<ProTable
231-
actionRef={actionRef}
252+
actionRef={allTodoActionRef}
232253
search={false}
233254
columns={columns}
234255
request={async (params, sort, filter) => {
@@ -246,10 +267,11 @@ const FlowRecordPage = () => {
246267
review={reviewVisible}
247268
setVisible={setFlowViewVisible}
248269
view={{
249-
'default':DefaultFlowView
270+
'default': DefaultFlowView
250271
}}
251272
/>
252273

274+
253275
</PageContainer>
254276
)
255277
}

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/service/FlowService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,13 @@ public void submitFlow(long recordId, IFlowOperator currentOperator, IBindData b
420420
snapshot = flowBindDataRepository.getBindDataSnapshotById(flowRecord.getSnapshotId());
421421
}
422422

423+
// 提交流程
424+
flowRecord.submitRecord(currentOperator, snapshot, opinion, flowNextStep);
425+
flowRecordRepository.update(flowRecord);
423426

424427
// 与当前流程同级的流程记录
425428
List<FlowRecord> historyRecords = flowRecordRepository.findFlowRecordByPreId(flowRecord.getPreId());
426429

427-
// 提交流程
428-
flowRecord.submitRecord(currentOperator, snapshot, opinion, flowNextStep);
429-
flowRecordRepository.update(flowRecord);
430430

431431
// 会签处理流程
432432
if (flowNode.isSign()) {
@@ -566,6 +566,10 @@ public void recall(long recordId, IFlowOperator currentOperator) {
566566
throw new IllegalArgumentException("flow node not found");
567567
}
568568

569+
if (flowRecord.isFinish()) {
570+
throw new IllegalArgumentException("flow record is finish");
571+
}
572+
569573
if (flowRecord.isTodo()) {
570574
throw new IllegalArgumentException("flow record is todo");
571575
}

springboot-starter-flow/src/test/java/com/codingapi/springboot/flow/test/FlowTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void entrustTest() {
135135
/**
136136
* 同意再拒绝
137137
*/
138+
@Test
138139
void passAndRejectTest() {
139140
PageRequest pageRequest = PageRequest.of(0, 1000);
140141

@@ -145,7 +146,7 @@ void passAndRejectTest() {
145146
.title("请假流程")
146147
.nodes()
147148
.node("开始节点", "start", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
148-
.node("总经理审批", "manager", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
149+
.node("总经理审批", "manager", "default", ApprovalType.SIGN, OperatorMatcher.anyOperatorMatcher())
149150
.node("结束节点", "over", "default", ApprovalType.UN_SIGN, OperatorMatcher.creatorOperatorMatcher())
150151
.relations()
151152
.relation("开始节点", "start", "manager")
@@ -169,12 +170,16 @@ void passAndRejectTest() {
169170

170171
// 查看所有流程
171172
List<FlowRecord> records = flowRecordRepository.findAll(pageRequest).getContent();
172-
assertEquals(2, records.size());
173+
assertEquals(1, records.size());
174+
175+
176+
FlowRecord userTodo = userTodos.get(0);
177+
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意"));
173178

174179
userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
175180
assertEquals(1, userTodos.size());
176181

177-
FlowRecord userTodo = userTodos.get(0);
182+
userTodo = userTodos.get(0);
178183
flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意"));
179184

180185
userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();

0 commit comments

Comments
 (0)