ProcessPalette.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div class="my-process-palette">
  3. <div class="test-button" @click="addTask" @mousedown="addTask">测试任务</div>
  4. <div class="test-container" id="palette-container">1</div>
  5. </div>
  6. </template>
  7. <script lang="ts" setup>
  8. import { assign } from 'min-dash'
  9. defineOptions({ name: 'MyProcessPalette' })
  10. const bpmnInstances = () => (window as any).bpmnInstances
  11. const addTask = (event, options: any = {}) => {
  12. const ElementFactory = bpmnInstances().elementFactory
  13. const create = bpmnInstances().modeler.get('create')
  14. console.log(ElementFactory, create)
  15. const shape = ElementFactory.createShape(assign({ type: 'bpmn:UserTask' }, options))
  16. if (options) {
  17. shape.businessObject.di.isExpanded = options.isExpanded
  18. }
  19. console.log(event, 'event')
  20. console.log(shape, 'shape')
  21. create.start(event, shape)
  22. }
  23. </script>
  24. <style scoped lang="scss">
  25. .my-process-palette {
  26. box-sizing: border-box;
  27. padding: 80px 20px 20px;
  28. .test-button {
  29. box-sizing: border-box;
  30. padding: 8px 16px;
  31. border-radius: 4px;
  32. border: 1px solid rgb(24 144 255 / 80%);
  33. cursor: pointer;
  34. }
  35. }
  36. </style>