2025-09-05 15:38:09 +08:00
|
|
|
|
<script lang="ts" setup>
|
2025-09-10 15:39:32 +08:00
|
|
|
|
import { nextTick, onBeforeUnmount, ref, toRaw, watch } from 'vue';
|
|
|
|
|
|
|
|
|
|
|
|
import { Input } from 'ant-design-vue';
|
|
|
|
|
|
|
2025-09-05 15:38:09 +08:00
|
|
|
|
defineOptions({ name: 'ElementOtherConfig' });
|
2025-09-10 15:39:32 +08:00
|
|
|
|
|
2025-09-05 15:38:09 +08:00
|
|
|
|
const props = defineProps({
|
2025-09-10 15:39:32 +08:00
|
|
|
|
id: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: '',
|
|
|
|
|
|
},
|
2025-09-05 15:38:09 +08:00
|
|
|
|
});
|
2025-09-10 15:39:32 +08:00
|
|
|
|
|
|
|
|
|
|
const { Textarea } = Input;
|
|
|
|
|
|
|
2025-09-05 15:38:09 +08:00
|
|
|
|
const documentation = ref('');
|
|
|
|
|
|
const bpmnElement = ref();
|
2025-09-10 15:39:32 +08:00
|
|
|
|
|
2025-09-05 15:38:09 +08:00
|
|
|
|
const bpmnInstances = () => (window as any).bpmnInstances;
|
2025-09-10 15:39:32 +08:00
|
|
|
|
|
2025-09-05 15:38:09 +08:00
|
|
|
|
const updateDocumentation = () => {
|
|
|
|
|
|
(bpmnElement.value && bpmnElement.value.id === props.id) ||
|
|
|
|
|
|
(bpmnElement.value = bpmnInstances().elementRegistry.get(props.id));
|
|
|
|
|
|
const documentations = bpmnInstances().bpmnFactory.create(
|
|
|
|
|
|
'bpmn:Documentation',
|
|
|
|
|
|
{
|
|
|
|
|
|
text: documentation.value,
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
|
|
|
|
|
|
documentation: [documentations],
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2025-09-10 15:39:32 +08:00
|
|
|
|
|
2025-09-05 15:38:09 +08:00
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
bpmnElement.value = null;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
|
() => props.id,
|
|
|
|
|
|
(id) => {
|
2025-09-10 15:39:32 +08:00
|
|
|
|
if (id && id.length > 0) {
|
2025-09-05 15:38:09 +08:00
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
const documentations =
|
|
|
|
|
|
bpmnInstances().bpmnElement.businessObject?.documentation;
|
|
|
|
|
|
documentation.value =
|
2025-09-10 15:39:32 +08:00
|
|
|
|
documentations && documentations.length > 0
|
|
|
|
|
|
? documentations[0].text
|
|
|
|
|
|
: '';
|
2025-09-05 15:38:09 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
documentation.value = '';
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
|
);
|
|
|
|
|
|
</script>
|
2025-09-10 15:39:32 +08:00
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="panel-tab__content">
|
|
|
|
|
|
<div class="element-property input-property">
|
|
|
|
|
|
<div class="element-property__label">元素文档:</div>
|
|
|
|
|
|
<div class="element-property__value">
|
|
|
|
|
|
<Textarea
|
|
|
|
|
|
v-model:value="documentation"
|
|
|
|
|
|
:auto-size="{ minRows: 2, maxRows: 4 }"
|
|
|
|
|
|
@change="updateDocumentation"
|
|
|
|
|
|
@blur="updateDocumentation"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|