Skip to content

Commit b14693c

Browse files
committed
add 新功能:2022-11-25
1 parent 1494325 commit b14693c

File tree

22 files changed

+310
-95
lines changed

22 files changed

+310
-95
lines changed

admin-ui/src/api/flow.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export async function submitFlow(body:any) {
5050
return post('/api/cmd/flowRecord/submitFlow', body);
5151
}
5252

53+
export async function trySubmitFlow(body:any) {
54+
return post('/api/cmd/flowRecord/trySubmitFlow', body);
55+
}
56+
57+
export async function custom(body:any) {
58+
return post('/api/cmd/flowRecord/custom', body);
59+
}
60+
5361
export async function recall(body:any) {
5462
return post('/api/cmd/flowRecord/recall', body);
5563
}

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

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import {Button, ColorPicker, Popconfirm, Space} from "antd";
1414
import FlowUtils from "@/components/Flow/utils";
1515
import ScriptModal from "@/components/Flow/panel/ScriptModal";
16-
import {EyeOutlined} from "@ant-design/icons";
16+
import {EyeOutlined, ReloadOutlined} from "@ant-design/icons";
1717

1818
interface ButtonPanelProps {
1919
id: string;
@@ -28,6 +28,10 @@ const buttonEventOptions = [
2828
label: "提交",
2929
value: "SUBMIT"
3030
},
31+
{
32+
label: "预提交",
33+
value: "TRY_SUBMIT"
34+
},
3135
{
3236
label: "指定人员提交",
3337
value: "SPECIFY_SUBMIT"
@@ -94,7 +98,7 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
9498
dataIndex: 'style',
9599
key: 'style',
96100
render: (_: any, record: any) => {
97-
return <ColorPicker value={record.style.color} disabled={true}/>;
101+
return <ColorPicker value={record.style?.background} disabled={true}/>;
98102
}
99103
},
100104
{
@@ -200,14 +204,27 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
200204

201205
<ProFormColorPicker
202206
name={"style"}
203-
label={"按钮颜色"}
207+
label={(
208+
<Space>
209+
按钮颜色
210+
<ReloadOutlined
211+
alt={"重置"}
212+
onClick={() => {
213+
form.setFieldsValue({'style': null});
214+
}}
215+
/>
216+
</Space>
217+
)}
204218
normalize={(value) => {
205-
return {
206-
color: value.toHexString()
207-
};
219+
if(value) {
220+
return {
221+
background: value.toHexString()
222+
};
223+
}
224+
return value;
208225
}}
209226
getValueProps={(value) => {
210-
const color = value?.color;
227+
const color = value?.background;
211228
if (color) {
212229
return {
213230
value: color
@@ -216,12 +233,6 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
216233
return value;
217234
}}
218235
placeholder={"请选择按钮颜色"}
219-
rules={[
220-
{
221-
required: true,
222-
message: '请选择按钮颜色'
223-
}
224-
]}
225236
/>
226237

227238
<ProFormSelect
@@ -252,7 +263,7 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
252263
}
253264
]}
254265
options={buttonEventOptions}
255-
onChange={(value:string)=>{
266+
onChange={(value: string) => {
256267
setType(value);
257268
}}
258269
/>

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

Lines changed: 111 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import {Button, Divider, Form, message, Modal, Row, Space, Tabs} from "antd";
3-
import {detail, postponed, recall, saveFlow, submitFlow, transfer} from "@/api/flow";
3+
import {custom, detail, postponed, recall, saveFlow, submitFlow, transfer, trySubmitFlow} from "@/api/flow";
44
import {
55
ModalForm,
66
ProDescriptions,
@@ -40,6 +40,67 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
4040

4141
const [transferForm] = Form.useForm();
4242

43+
const handlerTool = (key:string,buttonId:string) =>{
44+
switch (key) {
45+
case 'SAVE':
46+
handlerSaveFlow();
47+
break;
48+
case 'SUBMIT':
49+
handleSubmitFlow(true);
50+
break;
51+
case 'TRY_SUBMIT':
52+
handleTrySubmitFlow();
53+
break;
54+
case 'REJECT':
55+
handleSubmitFlow(false);
56+
break;
57+
case 'TRANSFER':
58+
setTransferVisible(true);
59+
break;
60+
case 'POSTPONED':
61+
setPostponedVisible(true);
62+
break;
63+
case 'RECALL':
64+
handleRecallFlow();
65+
break;
66+
case 'SPECIFY_SUBMIT':
67+
handleSubmitFlow(true);
68+
break;
69+
case 'CUSTOM':
70+
handleCustomFlow(buttonId);
71+
break;
72+
}
73+
}
74+
75+
const ToolButtons = () => {
76+
if(!data){
77+
return null;
78+
}
79+
return (
80+
<Space>
81+
{data.flowNode.buttons && data.flowNode.buttons.map((item:any)=>{
82+
const style = item.style && {
83+
...JSON.parse(item.style),
84+
color:"white",
85+
} || {};
86+
return (
87+
<Button
88+
key={item.id}
89+
onClick={()=>{
90+
handlerTool(item.type,item.id);
91+
}}
92+
style={{
93+
...style
94+
}}
95+
>
96+
{item.name}
97+
</Button>
98+
)
99+
})}
100+
</Space>
101+
)
102+
}
103+
43104
const handlerSaveFlow = () => {
44105
const advice = opinionForm.getFieldValue('advice');
45106
const recordId = props.id;
@@ -113,6 +174,54 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
113174
});
114175
}
115176

177+
const handleCustomFlow = (buttonId:string) => {
178+
const recordId = props.id;
179+
const advice = opinionForm.getFieldValue('advice');
180+
const binData = viewForm.getFieldsValue();
181+
const clazzName = data.flowRecord.bindClass;
182+
const body = {
183+
recordId,
184+
buttonId,
185+
advice: advice,
186+
formData: {
187+
...binData,
188+
clazzName
189+
}
190+
}
191+
custom(body).then(res => {
192+
if (res.success) {
193+
message.success(res.data).then();
194+
}
195+
})
196+
}
197+
198+
199+
const handleTrySubmitFlow = () => {
200+
const advice = opinionForm.getFieldValue('advice');
201+
const recordId = props.id;
202+
const binData = viewForm.getFieldsValue();
203+
const clazzName = data.flowRecord.bindClass;
204+
const body = {
205+
recordId,
206+
advice: advice,
207+
success: true,
208+
formData: {
209+
...binData,
210+
clazzName
211+
}
212+
}
213+
trySubmitFlow(body).then(res => {
214+
if (res.success) {
215+
const operators = res.data.operators;
216+
const usernames = operators.map((item:any)=>{
217+
return item.name;
218+
});
219+
const messageText = `下级节点:${res.data.flowNode.name},下一流程审批人:${usernames.join(',')}`;
220+
message.success(messageText).then();
221+
}
222+
})
223+
}
224+
116225
const handleSubmitFlow = (success: boolean) => {
117226
const advice = opinionForm.getFieldValue('advice');
118227
const recordId = props.id;
@@ -208,62 +317,9 @@ const FlowView: React.FC<FlowViewProps> = (props) => {
208317
>
209318
<Row justify="end">
210319
<Space>
211-
{!props.review && (
212-
<Button
213-
onClick={() => {
214-
handlerSaveFlow();
215-
}}
216-
>保存</Button>
217-
)}
218-
219-
220-
{!props.review && (
221-
<Button
222-
type={"primary"}
223-
onClick={() => {
224-
handleSubmitFlow(true);
225-
}}
226-
>同意</Button>
227-
)}
228-
229-
230-
{!props.review && (
231-
<Button
232-
type={"primary"}
233-
onClick={() => {
234-
handleSubmitFlow(false);
235-
}}
236-
danger={true}
237-
>拒绝</Button>
238-
)}
239320

240321
{!props.review && (
241-
<Button
242-
type={"primary"}
243-
onClick={()=>{
244-
setTransferVisible(true);
245-
}}
246-
>转办</Button>
247-
)}
248-
249-
{!props.review && (
250-
<Button
251-
type={"primary"}
252-
onClick={() => {
253-
setPostponedVisible(true);
254-
}}
255-
danger={true}
256-
>延期</Button>
257-
)}
258-
259-
{!props.review && (
260-
<Button
261-
type={"primary"}
262-
onClick={() => {
263-
handleRecallFlow();
264-
}}
265-
danger={true}
266-
>撤销</Button>
322+
<ToolButtons/>
267323
)}
268324

269325
<Button

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.16</version>
8+
<version>3.3.17</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-application/src/main/java/com/codingapi/example/command/FlowRecordCmdController.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.codingapi.example.domain.User;
44
import com.codingapi.example.pojo.cmd.FlowCmd;
55
import com.codingapi.example.repository.UserRepository;
6+
import com.codingapi.springboot.flow.pojo.FlowNodeResult;
67
import com.codingapi.springboot.flow.pojo.FlowResult;
7-
import com.codingapi.springboot.flow.record.FlowRecord;
88
import com.codingapi.springboot.flow.service.FlowService;
99
import com.codingapi.springboot.framework.dto.response.Response;
1010
import com.codingapi.springboot.framework.dto.response.SingleResponse;
@@ -31,21 +31,34 @@ public SingleResponse<FlowResult> startFlow(@RequestBody FlowCmd.StartFlow reque
3131
}
3232

3333

34+
@PostMapping("/trySubmitFlow")
35+
public SingleResponse<FlowNodeResult> trySubmitFlow(@RequestBody FlowCmd.SubmitFlow request) {
36+
User current = userRepository.getUserByUsername(request.getUserName());
37+
return SingleResponse.of(flowService.trySubmitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion()));
38+
}
39+
40+
3441
@PostMapping("/submitFlow")
3542
public SingleResponse<FlowResult> submitFlow(@RequestBody FlowCmd.SubmitFlow request) {
3643
User current = userRepository.getUserByUsername(request.getUserName());
37-
if(current.isFlowManager()){
44+
if (current.isFlowManager()) {
3845
return SingleResponse.of(flowService.interfere(request.getRecordId(), current, request.getBindData(), request.getOpinion()));
39-
}else {
46+
} else {
4047
return SingleResponse.of(flowService.submitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion()));
4148
}
4249
}
4350

51+
@PostMapping("/custom")
52+
public SingleResponse<String> customFlow(@RequestBody FlowCmd.CustomFlow request) {
53+
User current = userRepository.getUserByUsername(request.getUserName());
54+
return SingleResponse.of(flowService.customFlow(request.getRecordId(), current, request.getButtonId(), request.getBindData(), request.getOpinion()));
55+
}
56+
4457

4558
@PostMapping("/save")
4659
public Response save(@RequestBody FlowCmd.SaveFlow request) {
4760
User current = userRepository.getUserByUsername(request.getUserName());
48-
flowService.save(request.getRecordId(), current, request.getBindData(),request.getAdvice());
61+
flowService.save(request.getRecordId(), current, request.getBindData(), request.getAdvice());
4962
return Response.buildSuccess();
5063
}
5164

@@ -82,5 +95,4 @@ public Response urge(@RequestBody FlowCmd.UrgeFlow request) {
8295
}
8396

8497

85-
8698
}

example/example-application/src/main/java/com/codingapi/example/pojo/cmd/FlowCmd.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@ public String getUserName() {
2929
}
3030
}
3131

32+
@Setter
33+
@Getter
34+
public static class CustomFlow {
35+
36+
private long recordId;
37+
private String buttonId;
38+
private String advice;
39+
private boolean success;
40+
private JSONObject formData;
41+
42+
@SneakyThrows
43+
public IBindData getBindData() {
44+
String clazzName = formData.getString("clazzName");
45+
return (IBindData)formData.toJavaObject(Class.forName(clazzName));
46+
}
47+
48+
public String getUserName() {
49+
return TokenContext.current().getUsername();
50+
}
51+
52+
public Opinion getOpinion() {
53+
return new Opinion(advice, success ? Opinion.RESULT_PASS : Opinion.RESULT_REJECT, Opinion.TYPE_DEFAULT);
54+
}
55+
}
56+
3257

3358
@Setter
3459
@Getter

example/example-domain/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.16</version>
8+
<version>3.3.17</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
 (0)