NodeHandler.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="node-handler-wrapper">
  3. <div class="node-handler" v-if="props.showAdd">
  4. <el-popover
  5. trigger="hover"
  6. v-model:visible="popoverShow"
  7. placement="right-start"
  8. width="auto"
  9. >
  10. <div class="handler-item-wrapper">
  11. <div class="handler-item" @click="addNode(NodeType.USER_TASK_NODE)">
  12. <div class="approve handler-item-icon">
  13. <span class="iconfont icon-approve icon-size"></span>
  14. </div>
  15. <div class="handler-item-text">审批人</div>
  16. </div>
  17. <div class="handler-item" @click="addNode(NodeType.COPY_TASK_NODE)">
  18. <div class="handler-item-icon copy">
  19. <span class="iconfont icon-size icon-copy"></span>
  20. </div>
  21. <div class="handler-item-text">抄送</div>
  22. </div>
  23. <div class="handler-item" @click="addNode(NodeType.CONDITION_BRANCH_NODE)">
  24. <div class="handler-item-icon condition">
  25. <span class="iconfont icon-size icon-exclusive"></span>
  26. </div>
  27. <div class="handler-item-text">条件分支</div>
  28. </div>
  29. <div class="handler-item" @click="addNode(NodeType.PARALLEL_BRANCH_NODE)">
  30. <div class="handler-item-icon condition">
  31. <span class="iconfont icon-size icon-parallel"></span>
  32. </div>
  33. <div class="handler-item-text">并行分支</div>
  34. </div>
  35. </div>
  36. <template #reference>
  37. <div class="add-icon"><Icon icon="ep:plus" /></div>
  38. </template>
  39. </el-popover>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup lang="ts">
  44. import {
  45. ApproveMethodType,
  46. AssignEmptyHandlerType,
  47. AssignStartUserHandlerType,
  48. NODE_DEFAULT_NAME,
  49. NodeType,
  50. RejectHandlerType,
  51. SimpleFlowNode
  52. } from './consts'
  53. import { generateUUID } from '@/utils'
  54. defineOptions({
  55. name: 'NodeHandler'
  56. })
  57. const popoverShow = ref(false)
  58. const props = defineProps({
  59. childNode: {
  60. type: Object as () => SimpleFlowNode,
  61. default: null
  62. },
  63. showAdd: {
  64. // 是否显示添加节点
  65. type: Boolean,
  66. default: true
  67. }
  68. })
  69. const emits = defineEmits(['update:childNode'])
  70. const addNode = (type: number) => {
  71. popoverShow.value = false
  72. if (type === NodeType.USER_TASK_NODE) {
  73. const id = 'Activity_' + generateUUID()
  74. const data: SimpleFlowNode = {
  75. id: id,
  76. name: NODE_DEFAULT_NAME.get(NodeType.USER_TASK_NODE) as string,
  77. showText: '',
  78. type: NodeType.USER_TASK_NODE,
  79. approveMethod: ApproveMethodType.SEQUENTIAL_APPROVE,
  80. // 超时处理
  81. rejectHandler: {
  82. type: RejectHandlerType.FINISH_PROCESS
  83. },
  84. timeoutHandler: {
  85. enable: false
  86. },
  87. assignEmptyHandler: {
  88. type: AssignEmptyHandlerType.APPROVE
  89. },
  90. assignStartUserHandlerType: AssignStartUserHandlerType.START_USER_AUDIT,
  91. childNode: props.childNode
  92. }
  93. emits('update:childNode', data)
  94. }
  95. if (type === NodeType.COPY_TASK_NODE) {
  96. const data: SimpleFlowNode = {
  97. id: 'Activity_' + generateUUID(),
  98. name: NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE) as string,
  99. showText: '',
  100. type: NodeType.COPY_TASK_NODE,
  101. childNode: props.childNode
  102. }
  103. emits('update:childNode', data)
  104. }
  105. if (type === NodeType.CONDITION_BRANCH_NODE) {
  106. const data: SimpleFlowNode = {
  107. name: '条件分支',
  108. type: NodeType.CONDITION_BRANCH_NODE,
  109. id: 'GateWay_' + generateUUID(),
  110. childNode: props.childNode,
  111. conditionNodes: [
  112. {
  113. id: 'Flow_' + generateUUID(),
  114. name: '条件1',
  115. showText: '',
  116. type: NodeType.CONDITION_NODE,
  117. childNode: undefined,
  118. attributes: {
  119. conditionType: 1,
  120. defaultFlow: false
  121. }
  122. },
  123. {
  124. id: 'Flow_' + generateUUID(),
  125. name: '其它情况',
  126. showText: '其它情况进入此流程',
  127. type: NodeType.CONDITION_NODE,
  128. childNode: undefined,
  129. attributes: {
  130. conditionType: undefined,
  131. defaultFlow: true
  132. }
  133. }
  134. ]
  135. }
  136. emits('update:childNode', data)
  137. }
  138. if (type === NodeType.PARALLEL_BRANCH_NODE) {
  139. const data: SimpleFlowNode = {
  140. name: '并行分支',
  141. type: NodeType.PARALLEL_BRANCH_NODE,
  142. id: 'GateWay_' + generateUUID(),
  143. childNode: props.childNode,
  144. conditionNodes: [
  145. {
  146. id: 'Flow_' + generateUUID(),
  147. name: '并行1',
  148. showText: '无需配置条件同时执行',
  149. type: NodeType.CONDITION_NODE,
  150. childNode: undefined
  151. },
  152. {
  153. id: 'Flow_' + generateUUID(),
  154. name: '并行2',
  155. showText: '无需配置条件同时执行',
  156. type: NodeType.CONDITION_NODE,
  157. childNode: undefined
  158. }
  159. ]
  160. }
  161. emits('update:childNode', data)
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped></style>