AuditFlow.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import React, { useMemo } from 'react';
  2. import { Steps } from 'antd';
  3. import styles from './Index.less';
  4. import { queryDDProcessesForecast } from '@/services/boom';
  5. const { Step } = Steps;
  6. const ACTOR_TYPE = {
  7. approver: '审批人',
  8. notifier: '抄送人',
  9. audit: '办理人',
  10. };
  11. const APPROVAL_TYPE = {
  12. MANUAL: '人工审批',
  13. AUTO_AGREE: '自动通过',
  14. AUTO_REFUSE: '自动拒绝',
  15. };
  16. const APPROVAL_METHOD = {
  17. ONE_BY_ONE: '依次审批',
  18. AND: '会签审批',
  19. OR: '或签审批',
  20. };
  21. const ACTIVITY_TYPE = {
  22. target_select: '自选审批人',
  23. target_approval: '指定审批人',
  24. };
  25. let timer = {
  26. id: '',
  27. status: false,
  28. };
  29. function AuditFlow(props) {
  30. const {
  31. processCode,
  32. deptId = '14169890',
  33. userId = '16569001414345099',
  34. formComponentValues,
  35. activityId,
  36. direction,
  37. } = props;
  38. const flow = {
  39. workflowActivityRules: [
  40. {
  41. activityId: 'xi0m_sJzp',
  42. prevActivityId: 'sid-startevent',
  43. workflowActor: {
  44. actorType: 'approver',
  45. approvalType: 'MANUAL',
  46. actorActivateType: 'ONE_BY_ONE',
  47. approvalMethod: 'ONE_BY_ONE',
  48. allowedMulti: true,
  49. actorSelectionRange: {},
  50. required: false,
  51. },
  52. isTargetSelect: false,
  53. activityName: '连续多级主管',
  54. activityType: 'target_approval',
  55. },
  56. {
  57. activityId: 'a890_1358',
  58. prevActivityId: 'xi0m_sJzp',
  59. workflowActor: {
  60. actorType: 'approver',
  61. approvalType: 'MANUAL',
  62. actorActivateType: 'ONE_BY_ONE',
  63. approvalMethod: 'ONE_BY_ONE',
  64. allowedMulti: true,
  65. actorSelectionRange: {},
  66. required: false,
  67. },
  68. isTargetSelect: false,
  69. activityName: '审批人',
  70. activityType: 'target_approval',
  71. },
  72. ],
  73. workflowForecastNodes: [
  74. {
  75. activityId: 'sid-startevent',
  76. outId: 'line-random-sid-startevent-xi0m_sJzp',
  77. },
  78. {
  79. activityId: 'xi0m_sJzp',
  80. outId: 'line-random-xi0m_sJzp-a890_1358',
  81. },
  82. {
  83. activityId: 'a890_1358',
  84. outId: 'line-random-a890_1358-endId',
  85. },
  86. {
  87. activityId: 'endId',
  88. },
  89. ],
  90. processId: 64338972901,
  91. processCode: 'PROC-F2AD61A8-25CF-47AB-96EA-E0D0850BBE35',
  92. isForecastSuccess: true,
  93. userId: '16569001414345099',
  94. isStaticWorkflow: true,
  95. };
  96. const current = useMemo(() => {
  97. if (!activityId) {
  98. return flow.workflowActivityRules.length;
  99. } else {
  100. return flow.workflowActivityRules.findIndex(item => item.activityId == activityId);
  101. }
  102. }, [activityId]);
  103. const renderDesc = item => {
  104. return <></>;
  105. };
  106. const customDot = (dot, { status, index }) => {
  107. let item = flow.workflowActivityRules[index];
  108. return (
  109. <Popover
  110. content={
  111. <div>
  112. 节点类型:{ACTIVITY_TYPE[item.activityType]}
  113. <br />
  114. 操作人类型:{ACTOR_TYPE[item.workflowActor?.actorType]}
  115. <br />
  116. 审批类型:{APPROVAL_TYPE[item.workflowActor?.approvalType]}
  117. <br />
  118. 审批方式:{APPROVAL_METHOD[item.workflowActor?.approvalMethod]}
  119. </div>
  120. }
  121. >
  122. {dot}
  123. </Popover>
  124. );
  125. };
  126. const getDetail = async () => {
  127. if (!timer.status) {
  128. // 上锁
  129. timer.status = true;
  130. let flow = await queryDDProcessesForecast({
  131. processCode,
  132. deptId,
  133. userId,
  134. formComponentValues,
  135. });
  136. // 解锁
  137. timer.status = false;
  138. } else {
  139. clearTimeout(timer.id);
  140. // 延迟调用
  141. timer.id = setTimeout(() => {
  142. getDetail();
  143. }, 2000);
  144. }
  145. };
  146. useEffect(() => {
  147. getDetail();
  148. }, [processCode, formComponentValues]);
  149. return (
  150. <div className={styles.top}>
  151. <Steps current={current} progressDot={customDot} direction={direction}>
  152. {flow.workflowActivityRules.map(item => (
  153. <Step key={item.activityId} title={item?.activityName} />
  154. ))}
  155. {/* <Step key={item.activityId} title={item?.activityName} description={renderDesc(item)} /> */}
  156. </Steps>
  157. </div>
  158. );
  159. }
  160. export default AuditFlow;