ElementOtherConfig.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. import { ref, watch, nextTick, onBeforeUnmount } from 'vue'
  20. import { ElInput } from 'element-plus'
  21. const props = defineProps({
  22. id: String
  23. })
  24. const documentation = ref('')
  25. const bpmnElement = ref()
  26. const updateDocumentation = () => {
  27. ;(bpmnElement.value && bpmnElement.value.id === props.id) ||
  28. (bpmnElement.value = window.bpmnInstances.elementRegistry.get(props.id))
  29. const documentation = window.bpmnInstances.bpmnFactory.create('bpmn:Documentation', {
  30. text: documentation.value
  31. })
  32. window.bpmnInstances.modeling.updateProperties(bpmnElement.value, {
  33. documentation: [documentation]
  34. })
  35. }
  36. onBeforeUnmount(() => {
  37. bpmnElement.value = null
  38. })
  39. watch(
  40. () => props.id,
  41. (id) => {
  42. if (id && id.length) {
  43. nextTick(() => {
  44. const documentations = window.bpmnInstances.bpmnElement.businessObject?.documentation
  45. documentation.value = documentations && documentations.length ? documentations[0].text : ''
  46. })
  47. } else {
  48. documentation.value = ''
  49. }
  50. },
  51. { immediate: true }
  52. )
  53. </script>