gaoluyang
昨天 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<script lang="ts" setup>
import { Button } from 'ant-design-vue';
 
defineOptions({ name: 'MyProcessPalette' });
 
const bpmnInstances = () =>
  (window as typeof window & { bpmnInstances?: any }).bpmnInstances;
const addTask = (event: MouseEvent, options: any = {}) => {
  const ElementFactory = bpmnInstances().elementFactory;
  const create = bpmnInstances().modeler.get('create');
 
  const shape = ElementFactory.createShape(
    Object.assign({ type: 'bpmn:UserTask' }, options),
  );
 
  if (options) {
    shape.businessObject.di.isExpanded = options.isExpanded;
  }
  create.start(event, shape);
};
</script>
 
<template>
  <div class="my-process-palette p-20 pt-80">
    <Button type="primary" @click="addTask" @mousedown="addTask">
      测试任务
    </Button>
    <div class="mt-4" id="palette-container">1</div>
  </div>
</template>