gaoluyang
2026-06-24 bfdc0e0e6d5e47aa501f9b6fadd143d9c97cf00a
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<script lang="ts" setup>
import type { Component } from 'vue';
 
import { ref, watch } from 'vue';
 
import { CustomConfigMap } from './data';
 
defineOptions({ name: 'ElementCustomConfig' });
 
const props = defineProps({
  id: {
    type: String,
    default: '',
  },
  type: {
    type: String,
    default: '',
  },
  businessObject: {
    type: Object as () => BusinessObject,
    default: () => ({}),
  },
});
 
interface BusinessObject {
  eventDefinitions?: Array<{ $type: string }>;
  [key: string]: any;
}
 
// const bpmnInstances = () => (window as any)?.bpmnInstances;
const customConfigComponent = ref<Component | null>(null);
 
watch(
  () => props.businessObject,
  () => {
    if (props.type && props.businessObject) {
      let val = props.type;
      if (props.businessObject.eventDefinitions) {
        val +=
          props.businessObject.eventDefinitions[0]?.$type.split(':')[1] || '';
      }
      // @ts-expect-error: async component registry is indexed dynamically
      customConfigComponent.value = (
        CustomConfigMap as Record<string, { component: Component }>
      )[val]?.component;
    }
  },
  { immediate: true },
);
</script>
 
<template>
  <div class="panel-tab__content">
    <component :is="customConfigComponent" v-bind="$props" />
  </div>
</template>
 
<style lang="scss" scoped></style>