11import React from "react" ;
2- import { useApprovalContext } from "@/components/flow-approval/hooks/use-approval-context" ;
3- import { Col , Form , Row } from "antd" ;
4- import { ViewPlugin } from "@/plugins/view" ;
5-
6- interface FormViewComponentProps {
7- onValuesChange ?:( values :any ) => void ;
8- }
9-
10- const FormViewComponent : React . FC < FormViewComponentProps > = ( props ) => {
11- const { state, context} = useApprovalContext ( ) ;
12- const ViewComponent = ViewPlugin . getInstance ( ) . get ( state . flow ?. view || 'default' ) ;
13- // 是否可合并审批
14- const mergeable = state . flow ?. mergeable || false ;
15- const todos = state . flow ?. todos || [ ] ;
16- const viewForms = todos . length > 0 ?todos . map ( item => {
17- return {
18- instance : Form . useForm ( ) [ 0 ] ,
19- data : item . data ,
20- }
21- } ) :[
22- {
23- instance : Form . useForm ( ) [ 0 ] ,
24- data : undefined ,
25- }
26- ]
27-
28- React . useEffect ( ( ) => {
29- viewForms . forEach ( item => {
30- const formInstance = item . instance ;
31- const data = item . data ;
32- context . getPresenter ( ) . getFormActionContext ( ) . addAction ( {
33- save ( ) : any {
34- return formInstance . getFieldsValue ( ) ;
35- } ,
36- key ( ) : string {
37- return 'view-form'
38- }
39- } ) ;
40- formInstance . setFieldsValue ( data ) ;
41- } ) ;
42- } , [ ] ) ;
43-
44- if ( ViewComponent ) {
45- if ( mergeable ) {
46- return (
47- < div >
48- < h3 > 合并审批</ h3 >
49- </ div >
50- )
51- }
52- return (
53- < >
54- { viewForms . map ( ( item , index ) => (
55- < ViewComponent
56- key = { index }
57- form = { item . instance }
58- onValuesChange = { props . onValuesChange }
59- />
60- ) ) }
61- </ >
62- )
63- }
64- }
2+ import { Col , Row } from "antd" ;
3+ import { FormViewComponent } from "@/components/flow-approval/components/form-view-component" ;
4+ import { FlowNodeHistory , FlowNodeHistoryAction } from "@/components/flow-approval/components/flow-node-history" ;
655
666export const Body = ( ) => {
67-
68- const { state, context} = useApprovalContext ( ) ;
7+ const flowNodeHistoryAction = React . useRef < FlowNodeHistoryAction > ( null ) ;
698
709 const handleValuesChange = ( values :any ) => {
71- context . getPresenter ( ) . processNodes ( ) . then ( nodes => {
72- console . log ( '流程节点:' , nodes ) ;
73- } ) ;
10+ flowNodeHistoryAction . current ?. refresh ( ) ;
7411 }
7512
7613 return (
@@ -82,7 +19,7 @@ export const Body = () => {
8219 />
8320 </ Col >
8421 < Col span = { 6 } >
85- 流转历史
22+ < FlowNodeHistory actionRef = { flowNodeHistoryAction } />
8623 </ Col >
8724 </ Row >
8825 )
0 commit comments