@@ -5,11 +5,14 @@ import {custom, postponed, recall, saveFlow, startFlow, submitFlow, transfer, tr
55import { message } from "antd" ;
66import { useDispatch , useSelector } from "react-redux" ;
77import {
8- clearUserSelect , closeUserSelect ,
8+ clearTriggerClick ,
9+ clearUserSelect ,
10+ closeUserSelect ,
911 FlowReduxState ,
1012 setUserSelectModal ,
1113 showPostponed ,
12- showResult
14+ showResult ,
15+ triggerClick
1316} from "@/components/Flow/store/FlowSlice" ;
1417import { FlowUser } from "@/components/Flow/flow/types" ;
1518
@@ -28,6 +31,8 @@ export const registerEvents = (id: string,
2831
2932 const selectUserType = useSelector ( ( state : FlowReduxState ) => state . flow . userSelectType ) ;
3033
34+ const triggerClickVisible = useSelector ( ( state : FlowReduxState ) => state . flow . triggerClickVisible ) ;
35+
3136 const dispatch = useDispatch ( ) ;
3237
3338 let recordId = id ;
@@ -126,7 +131,7 @@ export const registerEvents = (id: string,
126131 }
127132
128133 // 提交流程
129- const handleSubmitFlow = ( flowState : boolean , callback : ( res : any ) => void , operatorIds ?:any [ ] ) => {
134+ const handleSubmitFlow = ( flowState : boolean , callback : ( res : any ) => void , operatorIds ?: any [ ] ) => {
130135 const advice = adviceForm . getFieldValue ( 'advice' ) ;
131136 setRequestLoading ( true ) ;
132137
@@ -135,7 +140,7 @@ export const registerEvents = (id: string,
135140 const body = {
136141 recordId,
137142 advice : advice ,
138- operatorIds :operatorIds ,
143+ operatorIds : operatorIds ,
139144 success : flowState ,
140145 formData : {
141146 ...flowData ,
@@ -292,22 +297,25 @@ export const registerEvents = (id: string,
292297 handlerTransferFlow ( currentUser ) ;
293298 }
294299
295- if ( selectUserType === 'nextNodeUser' && selectUsers && selectUsers . length > 0 ) {
296- handleSubmitFlow ( true , ( res ) => {
300+ if ( selectUserType === 'nextNodeUser' && selectUsers && selectUsers . length > 0 ) {
301+ handleSubmitFlow ( true , ( res ) => {
297302 const flowSubmitResultBuilder = new FlowSubmitResultBuilder ( res . data ) ;
298303 dispatch ( closeUserSelect ( ) ) ;
299304 dispatch ( showResult ( {
300305 closeFlow : true ,
301306 result : flowSubmitResultBuilder . builder ( )
302307 } ) ) ;
303- } , selectUsers . map ( ( item :FlowUser ) => {
308+ } , selectUsers . map ( ( item : FlowUser ) => {
304309 return item . id ;
305310 } ) ) ;
306311 }
307312 } , [ selectUsers ] ) ;
308313
309314
310- return ( button : any ) => {
315+ return ( button : {
316+ type : string ,
317+ id ?: string
318+ } ) => {
311319 switch ( button . type ) {
312320 case 'SAVE' : {
313321 // 保存流程,如果没有创建流程先创建,若已经创建则保存
@@ -336,16 +344,16 @@ export const registerEvents = (id: string,
336344 } ) ;
337345 const approvalType = res . data . flowNode . approvalType ;
338346 dispatch ( setUserSelectModal ( {
339- mode : approvalType === 'SIGN' ? 'single' : 'multiple' ,
347+ mode : approvalType === 'SIGN' ? 'single' : 'multiple' ,
340348 type : 'nextNodeUser' ,
341349 visible : true ,
342350 specifyUserIds : userIds
343351 } ) ) ;
344352 } ) ;
345353 }
346- if ( recordId ) {
354+ if ( recordId ) {
347355 _trySubmitFlow ( ) ;
348- } else {
356+ } else {
349357 handlerStartFlow ( ( id ) => {
350358 recordId = id ;
351359 _trySubmitFlow ( ) ;
@@ -415,13 +423,24 @@ export const registerEvents = (id: string,
415423 break ;
416424 }
417425 case 'CUSTOM' : {
418- if ( recordId ) {
419- handleCustomFlow ( button . id ) ;
426+ if ( button . id ) {
427+ const buttonId = button . id ;
428+ if ( recordId ) {
429+ handleCustomFlow ( buttonId ) ;
430+ } else {
431+ handlerStartFlow ( ( id ) => {
432+ recordId = id ;
433+ handleCustomFlow ( buttonId ) ;
434+ } ) ;
435+ }
436+ }
437+ break ;
438+ }
439+ case 'VIEW' : {
440+ if ( triggerClickVisible ) {
441+ dispatch ( clearTriggerClick ( ) ) ;
420442 } else {
421- handlerStartFlow ( ( id ) => {
422- recordId = id ;
423- handleCustomFlow ( button . id ) ;
424- } ) ;
443+ dispatch ( triggerClick ( ) ) ;
425444 }
426445 break ;
427446 }
0 commit comments