Skip to content

Commit bff148c

Browse files
committed
update 3.3.20
1 parent aa6c1a9 commit bff148c

File tree

23 files changed

+344
-177
lines changed

23 files changed

+344
-177
lines changed

admin-ui/src/components/Flow/components/ResultFormView.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,10 @@ const ResultFormView: React.FC<ResultFormProps> = (props) => {
4848
>
4949
<ProDescriptions.Item
5050
span={2}
51-
label={item.title.label}
51+
label={item.label}
5252
valueType="text"
5353
>
54-
{item.title.value}
55-
</ProDescriptions.Item>
56-
57-
<ProDescriptions.Item
58-
span={1}
59-
label={item.message.label}
60-
valueType="text"
61-
>
62-
{item.message.value}
54+
{item.value}
6355
</ProDescriptions.Item>
6456
</ProDescriptions>
6557
)

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

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,40 @@ export class FlowWorkData {
2828
}
2929

3030

31-
export class FlowSubmitResultBuilder extends FlowWorkData {
31+
export class FlowSubmitResultBuilder {
32+
33+
private readonly data: any;
34+
35+
constructor(data: any) {
36+
this.data = data;
37+
}
38+
39+
builder() {
40+
const operators = this.data.operators;
41+
const usernames = operators.map((item: any) => {
42+
return item.name;
43+
});
44+
const flowResult = {
45+
title: '下级节点提示',
46+
items: [
47+
{
48+
label: '下级审批节点',
49+
value: this.data.flowNode.name
50+
},
51+
{
52+
label: '下级审批人',
53+
value: usernames.join(',')
54+
}
55+
]
56+
}
57+
58+
return flowResult as FlowResultMessage;
59+
}
60+
61+
}
62+
63+
64+
export class FlowTrySubmitResultBuilder extends FlowWorkData {
3265

3366
constructor(data: any) {
3467
super(data);
@@ -39,17 +72,15 @@ export class FlowSubmitResultBuilder extends FlowWorkData {
3972
const resultItems = [];
4073
for (const record of records) {
4174
const node = this.getNode(record.nodeCode);
42-
const resultItem = {
43-
title: {
44-
label: '下级审批节点',
45-
value: node.name
46-
},
47-
message: {
48-
label: '下级审批人',
49-
value: record.currentOperator.name
50-
}
51-
}
52-
resultItems.push(resultItem);
75+
resultItems.push({
76+
label: '下级审批节点',
77+
value: node.name
78+
});
79+
80+
resultItems.push({
81+
label: '下级审批人',
82+
value: record.currentOperator.name
83+
});
5384
}
5485
return {
5586
title: '流程审批完成',

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

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {useDispatch, useSelector} from "react-redux";
77
import {
88
clearUserSelect,
99
FlowReduxState,
10-
setUserSelectModal, showPostponed,
10+
setUserSelectModal,
11+
showPostponed,
1112
showResult
1213
} from "@/components/Flow/store/FlowSlice";
1314
import {FlowUser} from "@/components/Flow/flow/types";
@@ -29,7 +30,7 @@ export const registerEvents = (id: string,
2930

3031
const dispatch = useDispatch();
3132

32-
const recordId = id;
33+
let recordId = id;
3334
// 保存流程
3435
const handlerSaveFlow = () => {
3536
const advice = adviceForm.getFieldValue('advice');
@@ -54,7 +55,7 @@ export const registerEvents = (id: string,
5455
}
5556

5657
// 发起流程
57-
const handlerStartFlow = (callback: () => void) => {
58+
const handlerStartFlow = (callback: (recordId: string) => void) => {
5859
const formData = form.getFieldsValue();
5960
const advice = adviceForm.getFieldValue('advice');
6061
const flowData = data.getFlowData();
@@ -70,8 +71,9 @@ export const registerEvents = (id: string,
7071
setRequestLoading(true)
7172
startFlow(body).then(res => {
7273
if (res.success) {
73-
setId(res.data.records[0].id);
74-
callback();
74+
const newRecordId = res.data.records[0].id;
75+
setId(newRecordId);
76+
callback(newRecordId);
7577
}
7678
}).finally(() => {
7779
setRequestLoading(false)
@@ -170,7 +172,11 @@ export const registerEvents = (id: string,
170172
}
171173
custom(body).then(res => {
172174
if (res.success) {
173-
message.success(res.data).then();
175+
const flowResult = res.data;
176+
dispatch(showResult({
177+
closeFlow: flowResult.closeable,
178+
result: flowResult
179+
}));
174180
}
175181
})
176182
}
@@ -327,15 +333,15 @@ export const registerEvents = (id: string,
327333
handleSubmitFlow(true, (res) => {
328334
const flowSubmitResultBuilder = new FlowSubmitResultBuilder(res.data);
329335
dispatch(showResult({
330-
closeFlow:true,
336+
closeFlow: true,
331337
result: flowSubmitResultBuilder.builder()
332338
}));
333339
});
334340
} else {
335341
handlerStartAndSubmitFlow((res) => {
336342
const flowSubmitResultBuilder = new FlowSubmitResultBuilder(res.data);
337343
dispatch(showResult({
338-
closeFlow:true,
344+
closeFlow: true,
339345
result: flowSubmitResultBuilder.builder()
340346
}));
341347
});
@@ -346,36 +352,18 @@ export const registerEvents = (id: string,
346352
handleSubmitFlow(false, (res) => {
347353
const flowSubmitResultBuilder = new FlowSubmitResultBuilder(res.data);
348354
dispatch(showResult({
349-
closeFlow:true,
355+
closeFlow: true,
350356
result: flowSubmitResultBuilder.builder()
351357
}));
352358
});
353359
break;
354360
}
355361
case 'TRY_SUBMIT': {
356362
handleTrySubmitFlow((res) => {
357-
const operators = res.data.operators;
358-
const usernames = operators.map((item: any) => {
359-
return item.name;
360-
});
361-
const flowResult = {
362-
title: '下级节点提示',
363-
items: [
364-
{
365-
title: {
366-
label: '下级审批节点',
367-
value: res.data.flowNode.name
368-
},
369-
message: {
370-
label: '下级审批人',
371-
value: usernames.join(',')
372-
}
373-
}
374-
]
375-
}
363+
const flowSubmitResultBuilder = new FlowSubmitResultBuilder(res.data);
376364
dispatch(showResult({
377-
closeFlow:false,
378-
result: flowResult
365+
closeFlow: false,
366+
result: flowSubmitResultBuilder.builder()
379367
}));
380368
});
381369
break;
@@ -402,7 +390,14 @@ export const registerEvents = (id: string,
402390
break;
403391
}
404392
case 'CUSTOM': {
405-
handleCustomFlow(button.id);
393+
if (recordId) {
394+
handleCustomFlow(button.id);
395+
} else {
396+
handlerStartFlow((id) => {
397+
recordId = id;
398+
handleCustomFlow(button.id);
399+
});
400+
}
406401
break;
407402
}
408403
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,8 @@ export interface FlowResultMessage {
4848
}
4949

5050
export interface FlowResultItem {
51-
title: {
52-
label: string,
53-
value: string
54-
},
55-
message: {
56-
label: string,
57-
value: string
58-
},
51+
label: string,
52+
value: string
5953
}
6054

6155
// 结果表单 【拓展视图】

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
253253
<EyeOutlined
254254
onClick={() => {
255255
groovyForm.resetFields();
256-
const script = form.getFieldValue('groovy') || 'def run(content){\n // 你的代码\n \n}';
256+
const script = form.getFieldValue('groovy') || 'def run(content){\n //你的代码 \n return content.createMessageResult(\'我是自定义标题\');\n}';
257257
groovyForm.setFieldsValue({
258258
'script': script
259259
});

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

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const ScriptModal:React.FC<ScriptModalProps> = (props)=>{
4040
hidden={true}
4141
/>
4242

43+
<a onClick={() => {
44+
setShow(!show);
45+
}}><EyeOutlined/> 查看帮助</a>
46+
4347
{show && (
4448
<div>
4549
<pre>
@@ -84,7 +88,47 @@ def run(content){
8488
`
8589
def run(content){
8690
// 你的代码
87-
return return content.getCreateOperator().getName() + '-' + content.getFlowWork().getTitle() + '-' + content.getFlowNode().getName();}
91+
return content.getCreateOperator().getName() + '-' + content.getFlowWork().getTitle() + '-' + content.getFlowNode().getName();
92+
}
93+
`
94+
}
95+
</code>
96+
在自定义按钮事件时,返回createMessageResult函数:
97+
<code>
98+
{
99+
`
100+
def run(content){
101+
// 你的代码
102+
// 自定义返回标题
103+
// return content.createMessageResult('我是自定义标题');
104+
// 自定义返回标题并且关闭流程
105+
// return content.createMessageResult('我是自定义标题', true);
106+
// 自定义返回标题并添加现实内容
107+
return content.createMessageResult('我是自定义标题', true).addMessage('我是标题1','我是内容2').addMessage('我是标题2','我是内容2');
108+
}
109+
`
110+
}
111+
</code>
112+
在自定义按钮事件时,操作流程:
113+
<code>
114+
{
115+
`
116+
def run(content){
117+
// 你的代码
118+
// 自定义返回标题
119+
// return content.createMessageResult('我是自定义标题');
120+
// 自定义返回标题并且关闭流程
121+
// return content.createMessageResult('我是自定义标题', true);
122+
// 提交流程
123+
// content.submitFlow();
124+
// 催办流程
125+
// content.urgeFlow();
126+
// 保存流程
127+
// content.saveFlow();
128+
// 撤回流程
129+
// content.recallFlow();
130+
// 自定义返回标题并添加现实内容
131+
return content.createMessageResult('我是自定义标题', true).addMessage('我是标题1','我是内容2').addMessage('我是标题2','我是内容2');
88132
}
89133
`
90134
}
@@ -95,10 +139,6 @@ def run(content){
95139
</div>
96140
)}
97141

98-
<a onClick={()=>{
99-
setShow(!show);
100-
}}><EyeOutlined/> 查看帮助</a>
101-
102142

103143
<ProFormCode
104144
name={"script"}

admin-ui/src/pages/flow/leave/default.tsx renamed to admin-ui/src/pages/flow/leave/LeaveForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {ProForm, ProFormDigit, ProFormText, ProFormTextArea} from "@ant-design/p
33
import {FlowFormViewProps} from "@/components/Flow/flow/types";
44

55

6-
const DefaultFlowView: React.FC<FlowFormViewProps> = (props) => {
6+
const LeaveForm: React.FC<FlowFormViewProps> = (props) => {
77

88
useEffect(() => {
99
props.form.setFieldsValue(props.data);
@@ -49,4 +49,4 @@ const DefaultFlowView: React.FC<FlowFormViewProps> = (props) => {
4949
)
5050
}
5151

52-
export default DefaultFlowView;
52+
export default LeaveForm;

0 commit comments

Comments
 (0)