multiInstance.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="多实例配置"
  5. :visible.sync="dialogVisible"
  6. width="500px"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. :show-close="false"
  10. :modal = "false"
  11. class="muti-instance"
  12. @closed="$emit('close')"
  13. >
  14. <el-alert
  15. type="info"
  16. :closable="false"
  17. show-icon
  18. style="margin-bottom: 20px"
  19. >
  20. <template #title>
  21. 按照BPMN2.0规范的要求,用于为每个实例创建执行的父执行,会提供下列变量:<br>
  22. nrOfInstances:实例总数。<br>
  23. nrOfActiveInstances:当前活动的(即未完成的),实例数量。对于顺序多实例,这个值总为1。<br>
  24. nrOfCompletedInstances:已完成的实例数量。<br>
  25. loopCounter:给定实例在for-each循环中的index。<br>
  26. </template>
  27. </el-alert>
  28. <x-form ref="xForm" v-model="formData" :config="formConfig" />
  29. </el-dialog>
  30. </div>
  31. </template>
  32. <script>
  33. import mixinPanel from '../../../common/mixinPanel'
  34. import { formatJsonKeyValue } from '../../../common/parseElement'
  35. export default {
  36. mixins: [mixinPanel],
  37. data() {
  38. return {
  39. dialogVisible: true,
  40. formData: {}
  41. }
  42. },
  43. computed: {
  44. formConfig() {
  45. const _this = this
  46. return {
  47. inline: false,
  48. item: [
  49. {
  50. xType: 'input',
  51. name: 'collection',
  52. label: '集合',
  53. tooltip: '属性会作为表达式进行解析。如果表达式解析为字符串而不是一个集合,<br />不论是因为本身配置的就是静态字符串值,还是表达式计算结果为字符串,<br />这个字符串都会被当做变量名,并从流程变量中用于获取实际的集合。'
  54. },
  55. {
  56. xType: 'input',
  57. name: 'elementVariable',
  58. label: '元素变量',
  59. tooltip: '每创建一个用户任务前,先以该元素变量为label,集合中的一项为value,<br />创建(局部)流程变量,该局部流程变量被用于指派用户任务。<br />一般来说,该字符串应与指定人员变量相同。'
  60. },
  61. {
  62. xType: 'radio',
  63. name: 'isSequential',
  64. label: '执行方式',
  65. dic: [{ label: '串行', value: true }, { label: '并行', value: false }]
  66. },
  67. {
  68. xType: 'input',
  69. name: 'completionCondition',
  70. label: '完成条件',
  71. tooltip: '多实例活动在所有实例都完成时结束,然而也可以指定一个表达式,在每个实例<br />结束时进行计算。当表达式计算为true时,将销毁所有剩余的实例,并结束多实例<br />活动,继续执行流程。例如 ${nrOfCompletedInstances/nrOfInstances >= 0.6 },<br />表示当任务完成60%时,该节点就算完成'
  72. }
  73. ],
  74. operate: [
  75. { text: '确定', show: true, click: _this.save },
  76. { text: '清空', show: true, click: () => { _this.formData = {} } }
  77. ]
  78. }
  79. }
  80. },
  81. mounted() {
  82. const cache = JSON.parse(JSON.stringify(this.element.businessObject.loopCharacteristics ?? {}))
  83. cache.completionCondition = cache.completionCondition?.body
  84. this.formData = formatJsonKeyValue(cache)
  85. },
  86. methods: {
  87. updateElement() {
  88. if (this.formData.isSequential !== null && this.formData.isSequential !== undefined) {
  89. let loopCharacteristics = this.element.businessObject.get('loopCharacteristics')
  90. if (!loopCharacteristics) {
  91. loopCharacteristics = this.modeler.get('moddle').create('bpmn:MultiInstanceLoopCharacteristics')
  92. }
  93. loopCharacteristics['isSequential'] = this.formData.isSequential
  94. loopCharacteristics['collection'] = this.formData.collection
  95. loopCharacteristics['elementVariable'] = this.formData.elementVariable
  96. if (this.formData.completionCondition) {
  97. const completionCondition = this.modeler.get('moddle').create('bpmn:Expression', { body: this.formData.completionCondition })
  98. loopCharacteristics['completionCondition'] = completionCondition
  99. }
  100. this.updateProperties({ loopCharacteristics: loopCharacteristics })
  101. } else {
  102. delete this.element.businessObject.loopCharacteristics
  103. }
  104. },
  105. save() {
  106. this.updateElement()
  107. this.dialogVisible = false
  108. }
  109. }
  110. }
  111. </script>
  112. <style>
  113. .muti-instance .el-form-item {
  114. margin-bottom: 22px;
  115. }
  116. </style>