ElementOtherConfig.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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, toRaw } 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. console.log(props, 'props')
  28. console.log(window, 'window')
  29. console.log(
  30. window.bpmnInstances.elementRegistry.get(props.id),
  31. 'window.bpmnInstances.elementRegistry.get(props.id)'
  32. )
  33. console.log(bpmnElement.value, 'bpmnElement.value ')
  34. if (bpmnElement.value && bpmnElement.value.id === props.id) {
  35. bpmnElement.value = window?.bpmnInstances.elementRegistry.get(props.id)
  36. }
  37. console.log(
  38. bpmnElement.value,
  39. 'bpmnElement.value bpmnElement.value bpmnElement.value bpmnElement.value bpmnElement.value bpmnElement.value '
  40. )
  41. // (bpmnElement.value && bpmnElement.value.id === props.id) ||
  42. // (bpmnElement.value = window.bpmnInstances.elementRegistry.get(props.id))
  43. const documentations = window.bpmnInstances.bpmnFactory.create('bpmn:Documentation', {
  44. text: documentation.value
  45. })
  46. window.bpmnInstances.modeling.updateProperties(toRaw(bpmnElement.value), {
  47. documentation: [documentations]
  48. })
  49. }
  50. onBeforeUnmount(() => {
  51. bpmnElement.value = null
  52. })
  53. watch(
  54. () => props.id,
  55. (id) => {
  56. if (id && id.length) {
  57. nextTick(() => {
  58. const documentations = window.bpmnInstances.bpmnElement.businessObject?.documentation
  59. documentation.value = documentations && documentations.length ? documentations[0].text : ''
  60. })
  61. } else {
  62. documentation.value = ''
  63. }
  64. },
  65. { immediate: true }
  66. )
  67. </script>