ElementOtherConfig.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 updateDocumentation = () => {
  25. ;(bpmnElement.value && bpmnElement.value.id === props.id) ||
  26. (bpmnElement.value = (window as any).bpmnInstances.elementRegistry.get(props.id))
  27. const documentations = window.bpmnInstances.bpmnFactory.create('bpmn:Documentation', {
  28. text: documentation.value
  29. })
  30. window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), {
  31. documentation: [documentations]
  32. })
  33. }
  34. onBeforeUnmount(() => {
  35. bpmnElement.value = null
  36. })
  37. watch(
  38. () => props.id,
  39. (id) => {
  40. if (id && id.length) {
  41. nextTick(() => {
  42. const documentations = window.bpmnInstances.bpmnElement.businessObject?.documentation
  43. documentation.value = documentations && documentations.length ? documentations[0].text : ''
  44. })
  45. } else {
  46. documentation.value = ''
  47. }
  48. },
  49. { immediate: true }
  50. )
  51. </script>