NodeHandler.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="node-handler-wrapper">
  3. <div class="node-handler">
  4. <el-popover
  5. trigger="hover"
  6. v-model:visible="popoverShow"
  7. placement="right-start"
  8. width="auto"
  9. v-if="!readonly"
  10. >
  11. <div class="handler-item-wrapper">
  12. <div class="handler-item" @click="addNode(NodeType.USER_TASK_NODE)">
  13. <div class="approve handler-item-icon">
  14. <span class="iconfont icon-approve icon-size"></span>
  15. </div>
  16. <div class="handler-item-text">审批人</div>
  17. </div>
  18. <div class="handler-item" @click="addNode(NodeType.TRANSACTOR_NODE)">
  19. <div class="transactor handler-item-icon">
  20. <span class="iconfont icon-transactor icon-size"></span>
  21. </div>
  22. <div class="handler-item-text">办理人</div>
  23. </div>
  24. <div class="handler-item" @click="addNode(NodeType.COPY_TASK_NODE)">
  25. <div class="handler-item-icon copy">
  26. <span class="iconfont icon-size icon-copy"></span>
  27. </div>
  28. <div class="handler-item-text">抄送</div>
  29. </div>
  30. <div class="handler-item" @click="addNode(NodeType.CONDITION_BRANCH_NODE)">
  31. <div class="handler-item-icon condition">
  32. <span class="iconfont icon-size icon-exclusive"></span>
  33. </div>
  34. <div class="handler-item-text">条件分支</div>
  35. </div>
  36. <div class="handler-item" @click="addNode(NodeType.PARALLEL_BRANCH_NODE)">
  37. <div class="handler-item-icon parallel">
  38. <span class="iconfont icon-size icon-parallel"></span>
  39. </div>
  40. <div class="handler-item-text">并行分支</div>
  41. </div>
  42. <div class="handler-item" @click="addNode(NodeType.INCLUSIVE_BRANCH_NODE)">
  43. <div class="handler-item-icon inclusive">
  44. <span class="iconfont icon-size icon-inclusive"></span>
  45. </div>
  46. <div class="handler-item-text">包容分支</div>
  47. </div>
  48. <div class="handler-item" @click="addNode(NodeType.DELAY_TIMER_NODE)">
  49. <div class="handler-item-icon delay">
  50. <span class="iconfont icon-size icon-delay"></span>
  51. </div>
  52. <div class="handler-item-text">延迟器</div>
  53. </div>
  54. <div class="handler-item" @click="addNode(NodeType.ROUTER_BRANCH_NODE)">
  55. <div class="handler-item-icon router">
  56. <span class="iconfont icon-size icon-router"></span>
  57. </div>
  58. <div class="handler-item-text">路由分支</div>
  59. </div>
  60. <div class="handler-item" @click="addNode(NodeType.TRIGGER_NODE)">
  61. <div class="handler-item-icon trigger">
  62. <span class="iconfont icon-size icon-trigger"></span>
  63. </div>
  64. <div class="handler-item-text">触发器</div>
  65. </div>
  66. <div class="handler-item" @click="addNode(NodeType.CHILD_PROCESS_NODE)">
  67. <div class="handler-item-icon child-process">
  68. <span class="iconfont icon-size icon-child-process"></span>
  69. </div>
  70. <div class="handler-item-text">子流程</div>
  71. </div>
  72. </div>
  73. <template #reference>
  74. <div class="add-icon"><Icon icon="ep:plus" /></div>
  75. </template>
  76. </el-popover>
  77. </div>
  78. </div>
  79. </template>
  80. <script setup lang="ts">
  81. import {
  82. ApproveMethodType,
  83. AssignEmptyHandlerType,
  84. AssignStartUserHandlerType,
  85. ConditionType,
  86. NODE_DEFAULT_NAME,
  87. NodeType,
  88. RejectHandlerType,
  89. SimpleFlowNode,
  90. DEFAULT_CONDITION_GROUP_VALUE
  91. } from './consts'
  92. import { generateUUID } from '@/utils'
  93. import { cloneDeep } from 'lodash-es'
  94. defineOptions({
  95. name: 'NodeHandler'
  96. })
  97. const popoverShow = ref(false)
  98. const props = defineProps({
  99. childNode: {
  100. type: Object as () => SimpleFlowNode,
  101. default: null
  102. },
  103. currentNode: {
  104. type: Object as () => SimpleFlowNode,
  105. required: true
  106. }
  107. })
  108. const emits = defineEmits(['update:childNode'])
  109. const readonly = inject<Boolean>('readonly') // 是否只读
  110. const addNode = (type: number) => {
  111. popoverShow.value = false
  112. if (type === NodeType.USER_TASK_NODE || type === NodeType.TRANSACTOR_NODE) {
  113. const id = 'Activity_' + generateUUID()
  114. const data: SimpleFlowNode = {
  115. id: id,
  116. name: NODE_DEFAULT_NAME.get(type) as string,
  117. showText: '',
  118. type: type,
  119. approveMethod: ApproveMethodType.SEQUENTIAL_APPROVE,
  120. // 超时处理
  121. rejectHandler: {
  122. type: RejectHandlerType.FINISH_PROCESS
  123. },
  124. timeoutHandler: {
  125. enable: false
  126. },
  127. assignEmptyHandler: {
  128. type: AssignEmptyHandlerType.APPROVE
  129. },
  130. assignStartUserHandlerType: AssignStartUserHandlerType.START_USER_AUDIT,
  131. childNode: props.childNode,
  132. taskCreateListener: {
  133. enable: false
  134. },
  135. taskAssignListener: {
  136. enable: false
  137. },
  138. taskCompleteListener: {
  139. enable: false
  140. }
  141. }
  142. emits('update:childNode', data)
  143. }
  144. if (type === NodeType.COPY_TASK_NODE) {
  145. const data: SimpleFlowNode = {
  146. id: 'Activity_' + generateUUID(),
  147. name: NODE_DEFAULT_NAME.get(NodeType.COPY_TASK_NODE) as string,
  148. showText: '',
  149. type: NodeType.COPY_TASK_NODE,
  150. childNode: props.childNode
  151. }
  152. emits('update:childNode', data)
  153. }
  154. if (type === NodeType.CONDITION_BRANCH_NODE) {
  155. const data: SimpleFlowNode = {
  156. name: '条件分支',
  157. type: NodeType.CONDITION_BRANCH_NODE,
  158. id: 'GateWay_' + generateUUID(),
  159. childNode: props.childNode,
  160. conditionNodes: [
  161. {
  162. id: 'Flow_' + generateUUID(),
  163. name: '条件1',
  164. showText: '',
  165. type: NodeType.CONDITION_NODE,
  166. childNode: undefined,
  167. conditionSetting: {
  168. defaultFlow: false,
  169. conditionType: ConditionType.RULE,
  170. conditionGroups: cloneDeep(DEFAULT_CONDITION_GROUP_VALUE)
  171. }
  172. },
  173. {
  174. id: 'Flow_' + generateUUID(),
  175. name: '其它情况',
  176. showText: '未满足其它条件时,将进入此分支',
  177. type: NodeType.CONDITION_NODE,
  178. childNode: undefined,
  179. conditionSetting: {
  180. defaultFlow: true
  181. }
  182. }
  183. ]
  184. }
  185. emits('update:childNode', data)
  186. }
  187. if (type === NodeType.PARALLEL_BRANCH_NODE) {
  188. const data: SimpleFlowNode = {
  189. name: '并行分支',
  190. type: NodeType.PARALLEL_BRANCH_NODE,
  191. id: 'GateWay_' + generateUUID(),
  192. childNode: props.childNode,
  193. conditionNodes: [
  194. {
  195. id: 'Flow_' + generateUUID(),
  196. name: '并行1',
  197. showText: '无需配置条件同时执行',
  198. type: NodeType.CONDITION_NODE,
  199. childNode: undefined
  200. },
  201. {
  202. id: 'Flow_' + generateUUID(),
  203. name: '并行2',
  204. showText: '无需配置条件同时执行',
  205. type: NodeType.CONDITION_NODE,
  206. childNode: undefined
  207. }
  208. ]
  209. }
  210. emits('update:childNode', data)
  211. }
  212. if (type === NodeType.INCLUSIVE_BRANCH_NODE) {
  213. const data: SimpleFlowNode = {
  214. name: '包容分支',
  215. type: NodeType.INCLUSIVE_BRANCH_NODE,
  216. id: 'GateWay_' + generateUUID(),
  217. childNode: props.childNode,
  218. conditionNodes: [
  219. {
  220. id: 'Flow_' + generateUUID(),
  221. name: '包容条件1',
  222. showText: '',
  223. type: NodeType.CONDITION_NODE,
  224. childNode: undefined,
  225. conditionSetting: {
  226. defaultFlow: false,
  227. conditionType: ConditionType.RULE,
  228. conditionGroups: cloneDeep(DEFAULT_CONDITION_GROUP_VALUE)
  229. }
  230. },
  231. {
  232. id: 'Flow_' + generateUUID(),
  233. name: '其它情况',
  234. showText: '未满足其它条件时,将进入此分支',
  235. type: NodeType.CONDITION_NODE,
  236. childNode: undefined,
  237. conditionSetting: {
  238. defaultFlow: true
  239. }
  240. }
  241. ]
  242. }
  243. emits('update:childNode', data)
  244. }
  245. if (type === NodeType.DELAY_TIMER_NODE) {
  246. const data: SimpleFlowNode = {
  247. id: 'Activity_' + generateUUID(),
  248. name: NODE_DEFAULT_NAME.get(NodeType.DELAY_TIMER_NODE) as string,
  249. showText: '',
  250. type: NodeType.DELAY_TIMER_NODE,
  251. childNode: props.childNode
  252. }
  253. emits('update:childNode', data)
  254. }
  255. if (type === NodeType.ROUTER_BRANCH_NODE) {
  256. const data: SimpleFlowNode = {
  257. id: 'GateWay_' + generateUUID(),
  258. name: NODE_DEFAULT_NAME.get(NodeType.ROUTER_BRANCH_NODE) as string,
  259. showText: '',
  260. type: NodeType.ROUTER_BRANCH_NODE,
  261. childNode: props.childNode
  262. }
  263. emits('update:childNode', data)
  264. }
  265. if (type === NodeType.TRIGGER_NODE) {
  266. const data: SimpleFlowNode = {
  267. id: 'Activity_' + generateUUID(),
  268. name: NODE_DEFAULT_NAME.get(NodeType.TRIGGER_NODE) as string,
  269. showText: '',
  270. type: NodeType.TRIGGER_NODE,
  271. childNode: props.childNode
  272. }
  273. emits('update:childNode', data)
  274. }
  275. if (type === NodeType.CHILD_PROCESS_NODE) {
  276. const data: SimpleFlowNode = {
  277. id: 'Activity_' + generateUUID(),
  278. name: NODE_DEFAULT_NAME.get(NodeType.CHILD_PROCESS_NODE) as string,
  279. showText: '',
  280. type: NodeType.CHILD_PROCESS_NODE,
  281. childNode: props.childNode,
  282. childProcessSetting: {
  283. calledProcessDefinitionKey: '',
  284. calledProcessDefinitionName: '',
  285. async: false,
  286. skipStartUserNode: false,
  287. startUserSetting: {
  288. type: 1
  289. },
  290. timeoutSetting: {
  291. enable: false
  292. },
  293. multiInstanceSetting: {
  294. enable: false
  295. }
  296. }
  297. }
  298. emits('update:childNode', data)
  299. }
  300. }
  301. </script>
  302. <style lang="scss" scoped></style>