ProcessPalette.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 setup lang="ts" name="MyProcessPalette">
  8. import { assign } from 'min-dash'
  9. const bpmnInstances = () => (window as any).bpmnInstances
  10. const addTask = (event, options: any = {}) => {
  11. const ElementFactory = bpmnInstances().elementFactory
  12. const create = bpmnInstances().modeler.get('create')
  13. console.log(ElementFactory, create)
  14. const shape = ElementFactory.createShape(assign({ type: 'bpmn:UserTask' }, options))
  15. if (options) {
  16. shape.businessObject.di.isExpanded = options.isExpanded
  17. }
  18. console.log(event, 'event')
  19. console.log(shape, 'shape')
  20. create.start(event, shape)
  21. }
  22. </script>
  23. <style scoped lang="scss">
  24. .my-process-palette {
  25. box-sizing: border-box;
  26. padding: 80px 20px 20px 20px;
  27. .test-button {
  28. box-sizing: border-box;
  29. padding: 8px 16px;
  30. border-radius: 4px;
  31. border: 1px solid rgba(24, 144, 255, 0.8);
  32. cursor: pointer;
  33. }
  34. }
  35. </style>