ElementOtherConfig.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div class="panel-tab__content">
  3. <div class="element-property input-property">
  4. <div class="element-property__label">元素文档:</div>
  5. <div class="element-property__value">
  6. <el-input
  7. type="textarea"
  8. v-model="documentation"
  9. resize="vertical"
  10. :autosize="{ minRows: 2, maxRows: 4 }"
  11. @input="updateDocumentation"
  12. @blur="updateDocumentation"
  13. />
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script setup lang="ts" name="ElementOtherConfig">
  19. const props = defineProps({
  20. id: String
  21. })
  22. const documentation = ref('')
  23. const bpmnElement = ref()
  24. const bpmnInstances = () => (window as any).bpmnInstances
  25. const updateDocumentation = () => {
  26. ;(bpmnElement.value && bpmnElement.value.id === props.id) ||
  27. (bpmnElement.value = bpmnInstances().elementRegistry.get(props.id))
  28. const documentations = bpmnInstances().bpmnFactory.create('bpmn:Documentation', {
  29. text: documentation.value
  30. })
  31. bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
  32. documentation: [documentations]
  33. })
  34. }
  35. onBeforeUnmount(() => {
  36. bpmnElement.value = null
  37. })
  38. watch(
  39. () => props.id,
  40. (id) => {
  41. if (id && id.length) {
  42. nextTick(() => {
  43. const documentations = bpmnInstances().bpmnElement.businessObject?.documentation
  44. documentation.value = documentations && documentations.length ? documentations[0].text : ''
  45. })
  46. } else {
  47. documentation.value = ''
  48. }
  49. },
  50. { immediate: true }
  51. )
  52. </script>