Skip to content

Commit 8bd31be

Browse files
authored
Merge pull request #88 from codingapi/dev
Dev
2 parents 6099570 + 6962922 commit 8bd31be

File tree

182 files changed

+10520
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+10520
-131
lines changed

admin-ui/src/api/flow.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ export async function startFlow(body:any) {
4242
return post('/api/cmd/flowRecord/startFlow', body);
4343
}
4444

45+
export async function getFlowStep(body:any) {
46+
return post('/api/cmd/flowRecord/getFlowStep', body);
47+
}
48+
49+
export async function removeFlow(body:any) {
50+
return post('/api/cmd/flowRecord/remove', body);
51+
}
52+
53+
4554
export async function detail(id?:any,workCode?:any) {
4655
return get('/api/query/flowRecord/detail', {id,workCode});
4756
}
@@ -92,6 +101,17 @@ export async function flowRecordList(params: any,
92101
}
93102

94103

104+
export async function findAllByOperatorId(params: any,
105+
sort: any,
106+
filter: any,
107+
match: {
108+
key: string,
109+
type: string
110+
}[]) {
111+
return page('/api/query/flowRecord/findAllByOperatorId', params, sort, filter, match);
112+
}
113+
114+
95115
export async function findTodoByOperatorId(params: any,
96116
sort: any,
97117
filter: any,

admin-ui/src/components/Flow/flow/FlowDetail.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
102102
<ProFormTextArea
103103
disabled={props.review}
104104
placeholder={'请输入审批意见'}
105+
rules={[
106+
{
107+
required: true,
108+
message: '请输入审批意见'
109+
}
110+
]}
105111
name={"advice"}
106112
/>
107113
</ProForm>

admin-ui/src/components/Flow/flow/data.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,22 @@ export class FlowTrySubmitResultBuilder {
9191

9292
export class FlowData extends FlowWorkData {
9393
private readonly formParams?: FlowFormParams;
94+
private recordId:string;
9495

95-
constructor(data: any, formParams?: FlowFormParams) {
96+
constructor(recordId:string,data: any, formParams?: FlowFormParams) {
9697
super(data);
98+
this.recordId = recordId;
9799
this.formParams = formParams;
98100
}
99101

102+
setRecordId = (recordId:string)=>{
103+
this.recordId = recordId;
104+
}
105+
106+
getRecordId = ()=>{
107+
return this.recordId;
108+
}
109+
100110
// 是否可以审批
101111
canHandle = () => {
102112
return this.data.canHandle;

admin-ui/src/components/Flow/flow/events.tsx

Lines changed: 78 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import {useEffect} from "react";
22
import {FormInstance} from "antd/es/form/hooks/useForm";
33
import {FlowData, FlowSubmitResultBuilder, FlowTrySubmitResultBuilder} from "@/components/Flow/flow/data";
4-
import {custom, postponed, recall, saveFlow, startFlow, submitFlow, transfer, trySubmitFlow, urge} from "@/api/flow";
4+
import {
5+
custom,
6+
postponed,
7+
recall,
8+
removeFlow,
9+
saveFlow,
10+
startFlow,
11+
submitFlow,
12+
transfer,
13+
trySubmitFlow,
14+
urge
15+
} from "@/api/flow";
516
import {message} from "antd";
617
import {useDispatch, useSelector} from "react-redux";
718
import {
@@ -132,59 +143,62 @@ export const registerEvents = (id: string,
132143

133144
// 提交流程
134145
const handleSubmitFlow = (flowState: boolean, callback: (res: any) => void, operatorIds?: any[]) => {
135-
const advice = adviceForm.getFieldValue('advice');
136-
setRequestLoading(true);
146+
adviceForm.validateFields().then((adviceData)=>{
147+
const advice = adviceData.advice;
148+
setRequestLoading(true);
149+
form.validateFields().then((formData) => {
150+
const flowData = data.getFlowData();
151+
const body = {
152+
recordId,
153+
advice: advice,
154+
operatorIds: operatorIds,
155+
success: flowState,
156+
formData: {
157+
...flowData,
158+
...formData,
159+
}
160+
}
137161

138-
form.validateFields().then((formData) => {
162+
submitFlow(body).then(res => {
163+
if (res.success) {
164+
message.success('流程已提交').then();
165+
callback(res);
166+
}
167+
}).finally(() => {
168+
setRequestLoading(false)
169+
})
170+
}).catch(e => {
171+
console.log(e);
172+
setRequestLoading(false);
173+
})
174+
}).catch((e)=>{});
175+
}
176+
177+
// 自定义流程
178+
const handleCustomFlow = (buttonId: string) => {
179+
adviceForm.validateFields().then((adviceData)=> {
180+
const advice = adviceData.advice;
181+
const formData = form.getFieldsValue();
139182
const flowData = data.getFlowData();
140183
const body = {
141184
recordId,
185+
buttonId,
142186
advice: advice,
143-
operatorIds: operatorIds,
144-
success: flowState,
145187
formData: {
146188
...flowData,
147189
...formData,
148190
}
149191
}
150-
151-
submitFlow(body).then(res => {
192+
custom(body).then(res => {
152193
if (res.success) {
153-
message.success('流程已提交').then();
154-
callback(res);
194+
const flowResult = res.data;
195+
dispatch(showResult({
196+
closeFlow: flowResult.closeable,
197+
result: flowResult
198+
}));
155199
}
156-
}).finally(() => {
157-
setRequestLoading(false)
158-
})
159-
}).catch(e => {
160-
console.log(e);
161-
setRequestLoading(false);
162-
})
163-
}
164-
165-
// 自定义流程
166-
const handleCustomFlow = (buttonId: string) => {
167-
const advice = adviceForm.getFieldValue('advice');
168-
const formData = form.getFieldsValue();
169-
const flowData = data.getFlowData();
170-
const body = {
171-
recordId,
172-
buttonId,
173-
advice: advice,
174-
formData: {
175-
...flowData,
176-
...formData,
177-
}
178-
}
179-
custom(body).then(res => {
180-
if (res.success) {
181-
const flowResult = res.data;
182-
dispatch(showResult({
183-
closeFlow: flowResult.closeable,
184-
result: flowResult
185-
}));
186-
}
187-
})
200+
});
201+
}).catch((e)=>{});
188202
}
189203

190204
// 预提交
@@ -231,6 +245,24 @@ export const registerEvents = (id: string,
231245
})
232246
}
233247

248+
249+
// 删除流程
250+
const handleRemoveFlow = () => {
251+
const body = {
252+
recordId,
253+
}
254+
setRequestLoading(true);
255+
removeFlow(body).then(res => {
256+
if (res.success) {
257+
message.success('流程已删除').then();
258+
closeFlow();
259+
}
260+
}).finally(() => {
261+
setRequestLoading(false)
262+
})
263+
}
264+
265+
234266
// 延期流程
235267
const handlePostponedFlow = () => {
236268
const body = {
@@ -418,6 +450,10 @@ export const registerEvents = (id: string,
418450
handleRecallFlow();
419451
break;
420452
}
453+
case 'REMOVE': {
454+
handleRemoveFlow();
455+
break;
456+
}
421457
case 'URGE': {
422458
handlerUrgeFlow();
423459
break;

admin-ui/src/components/Flow/flow/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,14 @@ const $FlowView: React.FC<FlowViewProps> = (props) => {
158158
}, [flowViewVisible]);
159159

160160

161+
// 流程数据
162+
const flowData = new FlowData(props.id,data, props.formParams);
163+
161164
// 注册事件
162165
const handlerClicks = registerEvents(
163166
recordId,
164167
setRecordId,
165-
new FlowData(data, props.formParams),
168+
flowData,
166169
viewForm,
167170
adviceForm,
168171
setRequestLoading,
@@ -172,10 +175,19 @@ const $FlowView: React.FC<FlowViewProps> = (props) => {
172175
}
173176
);
174177

178+
179+
useEffect(() => {
180+
if(recordId){
181+
flowData.setRecordId(recordId);
182+
}
183+
}, [recordId]);
184+
185+
175186
if (!props.visible) {
176187
return null;
177188
}
178189

190+
179191
// 延期表单视图
180192
const PostponedFormView = getComponent(PostponedFormViewKey) as React.ComponentType<PostponedFormProps>;
181193

@@ -185,8 +197,7 @@ const $FlowView: React.FC<FlowViewProps> = (props) => {
185197
// 用户选人视图
186198
const UserSelectView = getComponent(UserSelectViewKey) as React.ComponentType<UserSelectProps>;
187199

188-
// 流程数据
189-
const flowData = new FlowData(data, props.formParams);
200+
190201

191202
return (
192203
<Modal

admin-ui/src/components/Flow/flow/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export type CustomButtonType =
1616
| 'POSTPONED'
1717
| 'URGE'
1818
| 'CUSTOM'
19-
| 'VIEW';
19+
| 'VIEW'
20+
| 'REMOVE';
2021

2122
// 流程图中线的类型
2223
export type EdgeType = 'line' | 'polyline' | 'bezier';

admin-ui/src/components/Flow/panel/ButtonPanel.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ const buttonEventOptions = [
6969
label: "自定义事件",
7070
value: "VIEW"
7171
},
72+
{
73+
label: "删除",
74+
value: "REMOVE"
75+
},
7276
] as {
7377
label: string;
7478
value: CustomButtonType;
@@ -231,15 +235,15 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
231235
/>
232236
</Space>
233237
)}
234-
normalize={(value) => {
238+
normalize={(value:any) => {
235239
if (value) {
236240
return {
237241
background: value.toHexString()
238242
};
239243
}
240244
return value;
241245
}}
242-
getValueProps={(value) => {
246+
getValueProps={(value:any) => {
243247
const color = value?.background;
244248
if (color) {
245249
return {

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,32 @@ const LeaveForm: React.FC<FlowFormViewProps> = (props) => {
3131
const [visible, setVisible] = React.useState(false);
3232

3333
useEffect(() => {
34-
if (eventKey ==='test') {
34+
if (eventKey === 'test') {
3535
console.log("点击了自定义事件", eventKey);
3636
setVisible(true);
3737
}
3838

3939
// 当流程审批反馈结果关闭时,重新加载数据
40-
if (eventKey==EVENT_CLOSE_RESULT_VIEW && props.flowData?.getNodeCode() ==='start') {
40+
if (eventKey == EVENT_CLOSE_RESULT_VIEW && props.flowData?.getNodeCode() === 'start') {
4141
// 重新加载数据
4242
console.log("重新加载数据");
4343
props.handlerClick && props.handlerClick({type: "RELOAD"});
4444
}
4545

46-
if (eventKey==EVENT_RELOAD_DATA) {
46+
if (eventKey == EVENT_RELOAD_DATA) {
4747
props.form.resetFields();
4848
props.form.setFieldsValue(props.data);
4949
}
5050
}, [eventKey]);
5151

5252

53+
useEffect(() => {
54+
setTimeout(() => {
55+
console.log('flowData recordId', props.flowData?.getRecordId());
56+
}, 100)
57+
}, [props.flowData]);
58+
59+
5360
return (
5461
<ProForm
5562
form={props.form}
@@ -111,6 +118,14 @@ const LeaveForm: React.FC<FlowFormViewProps> = (props) => {
111118
>点击了自定义事件</Button>
112119
)}
113120

121+
<Button
122+
onClick={() => {
123+
const recordId = props.flowData?.getRecordId();
124+
alert(recordId);
125+
}}
126+
>getRecordId</Button>
127+
128+
114129
</ProForm>
115130
)
116131
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, {useEffect} from "react";
22
import {ActionType, PageContainer, ProTable} from "@ant-design/pro-components";
33
import {
4+
findAllByOperatorId,
45
findDoneByOperatorId,
56
findInitiatedByOperatorId,
67
findPostponedTodoByOperatorId,
78
findTimeoutTodoByOperatorId,
89
findTodoByOperatorId,
9-
flowRecordList,
1010
urge
1111
} from "@/api/flow";
1212
import moment from "moment";
@@ -302,7 +302,7 @@ const FlowRecordPage = () => {
302302
return record.read?"record-read":"record-unread";
303303
}}
304304
request={async (params, sort, filter) => {
305-
return flowRecordList(params, sort, filter, []);
305+
return findAllByOperatorId(params, sort, filter, []);
306306
}}
307307
/>
308308
)

example/example-application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.55</version>
8+
<version>3.3.65</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
 (0)