Skip to content

Commit 2492e15

Browse files
committed
custom control opinionEditorVisible
1 parent 0ad954f commit 2492e15

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, {useEffect} from "react";
22
import {Divider, Result} from "antd";
33
import {ProForm, ProFormTextArea} from "@ant-design/pro-components";
44
import {CustomButtonType, FlowFormView, FlowFormViewProps} from "@/components/Flow/flow/types";
@@ -10,12 +10,13 @@ import {
1010
hideOpinionEditor,
1111
showOpinionEditor
1212
} from "@/components/Flow/store/FlowSlice";
13+
import {FormInstance} from "antd/es/form/hooks/useForm";
1314

1415
interface FlowDetailProps {
1516
view: React.ComponentType<FlowFormViewProps> | FlowFormView;
1617
visible: boolean;
1718
form: any;
18-
adviceForm: any;
19+
adviceForm: FormInstance<any>;
1920
review?: boolean;
2021
flowData: FlowData;
2122
// 流程交互操作
@@ -39,6 +40,15 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
3940
// flow store redux
4041
const dispatch = useDispatch();
4142

43+
useEffect(() => {
44+
if(props.visible){
45+
const advice = flowData.getOpinionAdvice();
46+
props.adviceForm.setFieldsValue({
47+
advice: advice
48+
});
49+
}
50+
}, [props.visible]);
51+
4252
return (
4353
<>
4454
<div className="flowApprovalViewBox">
@@ -51,6 +61,7 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
5161
form={props.form}
5262
flowData={flowData}
5363
visible={props.visible}
64+
opinions={flowData.getOpinions()}
5465
editable={!flowData.isDone() && flowData.getFlowNodeEditable()}
5566
compare={!flowData.isStartFlow()}
5667
triggerClickVisible={triggerClickVisible}
@@ -90,7 +101,6 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
90101
>
91102
<ProFormTextArea
92103
disabled={props.review}
93-
label={""}
94104
placeholder={'请输入审批意见'}
95105
name={"advice"}
96106
/>

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,22 @@ export class FlowData extends FlowWorkData {
217217
return this.data.flowRecord;
218218
}
219219

220+
// 获取审批意见
221+
getOpinionAdvice = () => {
222+
if(this.data.flowRecord){
223+
if(this.data.flowRecord.opinion){
224+
return this.data.flowRecord.opinion.advice;
225+
}
226+
}
227+
return null;
228+
}
229+
230+
231+
// 获取历史审批意见
232+
getOpinions() {
233+
return this.data.opinions;
234+
}
235+
220236
// 获取历史记录
221237
getHistoryRecords = () => {
222238
return this.data.historyRecords;
@@ -250,5 +266,6 @@ export class FlowData extends FlowWorkData {
250266
showOpinion() {
251267
return this.canHandle() && !this.isStartFlow();
252268
}
269+
253270
}
254271

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ const $FlowView: React.FC<FlowViewProps> = (props) => {
9090
if (props.id) {
9191
detail(props.id, null).then(res => {
9292
if (res.success) {
93+
adviceForm.resetFields();
9394
setData(res.data);
9495
}
9596
});
9697
}
9798
if (props.workCode) {
9899
detail(null, props.workCode).then(res => {
99100
if (res.success) {
101+
adviceForm.resetFields();
100102
setData(res.data);
101103
}
102104
});

springboot-starter-flow/src/main/java/com/codingapi/springboot/flow/content/FlowSession.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ public Object getBean(String beanName) {
6565
return provider.getBean(beanName);
6666
}
6767

68+
69+
/**
70+
* 获取审批意见
71+
*/
72+
public String getAdvice() {
73+
if (opinion != null) {
74+
return opinion.getAdvice();
75+
} else {
76+
return null;
77+
}
78+
}
79+
6880
/**
6981
* 创建节点结果
7082
*

0 commit comments

Comments
 (0)