ElementTask.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div class="panel-tab__content">
  3. <el-form size="small" label-width="90px">
  4. <!-- add by 芋艿:由于「异步延续」暂时用不到,所以这里 display 为 none -->
  5. <el-form-item label="异步延续" style="display: none">
  6. <el-checkbox
  7. v-model="taskConfigForm.asyncBefore"
  8. label="异步前"
  9. value="异步前"
  10. @change="changeTaskAsync"
  11. />
  12. <el-checkbox
  13. v-model="taskConfigForm.asyncAfter"
  14. label="异步后"
  15. value="异步后"
  16. @change="changeTaskAsync"
  17. />
  18. <el-checkbox
  19. v-model="taskConfigForm.exclusive"
  20. v-if="taskConfigForm.asyncAfter || taskConfigForm.asyncBefore"
  21. label="排除"
  22. value="排除"
  23. @change="changeTaskAsync"
  24. />
  25. </el-form-item>
  26. <component :is="witchTaskComponent" v-bind="$props" />
  27. </el-form>
  28. </div>
  29. </template>
  30. <script lang="ts" setup>
  31. import { installedComponent } from './data'
  32. defineOptions({ name: 'ElementTaskConfig' })
  33. const props = defineProps({
  34. id: String,
  35. type: String
  36. })
  37. const taskConfigForm = ref({
  38. asyncAfter: false,
  39. asyncBefore: false,
  40. exclusive: false
  41. })
  42. const witchTaskComponent = ref()
  43. const bpmnElement = ref()
  44. const bpmnInstances = () => (window as any).bpmnInstances
  45. const changeTaskAsync = () => {
  46. if (!taskConfigForm.value.asyncBefore && !taskConfigForm.value.asyncAfter) {
  47. taskConfigForm.value.exclusive = false
  48. }
  49. bpmnInstances().modeling.updateProperties(bpmnInstances().bpmnElement, {
  50. ...taskConfigForm.value
  51. })
  52. }
  53. watch(
  54. () => props.id,
  55. () => {
  56. bpmnElement.value = bpmnInstances().bpmnElement
  57. taskConfigForm.value.asyncBefore = bpmnElement.value?.businessObject?.asyncBefore
  58. taskConfigForm.value.asyncAfter = bpmnElement.value?.businessObject?.asyncAfter
  59. taskConfigForm.value.exclusive = bpmnElement.value?.businessObject?.exclusive
  60. },
  61. { immediate: true }
  62. )
  63. watch(
  64. () => props.type,
  65. () => {
  66. if (props.type) {
  67. witchTaskComponent.value = installedComponent[props.type].component
  68. }
  69. },
  70. { immediate: true }
  71. )
  72. </script>