xiangpei
2025-02-13 a3dbb8fe40e06f9abd9718f14aaa7311bddbc150
src/components/Process/designer.vue
@@ -66,7 +66,7 @@
import TaskListener from './panel/taskListener'
import MultiInstance from './panel/multiInstance'
import CommonPanel from './panel/commonPanel'
import UserTaskPanel from './panel/taskPanel'
import UserTaskPanel from './panel/TaskConfPanel'
import ConditionPanel from './panel/conditionPanel'
import FormPanel from './panel/formPanel'
import OtherPanel from './panel/otherPanel'
@@ -133,16 +133,15 @@
    getActiveElement() {
      // 初始第一个选中元素 bpmn:Process
      this.initFormOnChanged(null);
      // see https://bpmn.io/toolkit/bpmn-js/walkthrough/
      this.modelerStore.modeler.on("import.done", e => {
        this.initFormOnChanged(null);
      });
      // 监听选择事件,修改当前激活的元素以及表单
      this.modelerStore.modeler.on("selection.changed", ({newSelection}) => {
        console.log("数据改变1", newSelection)
        this.initFormOnChanged(newSelection[0] || null);
      });
      this.modelerStore.modeler.on("element.changed", ({element}) => {
        console.log("数据改变2")
        // 保证 修改 "默认流转路径" 类似需要修改多个元素的事件发生的时候,更新表单的元素与原选中元素不一致。
        if (element && element.id === this.elementId) {
          this.initFormOnChanged(element);
@@ -152,24 +151,19 @@
    // 初始化数据
    initFormOnChanged(element) {
      console.log(element, "节点数据")
      let activatedElement = element;
      if (!activatedElement) {
        console.log(1)
        activatedElement =
          this.modelerStore.elRegistry.find(el => el.type === "bpmn:Process") ??
          this.modelerStore.elRegistry.find(el => el.type === "bpmn:Collaboration");
      }
      if (!activatedElement) return;
      console.log(2, activatedElement)
      this.modelerStore.element = activatedElement;
      this.elementId = activatedElement.id;
      // 确保elementId值没变也要更新form组件选中的值
      if (this.formVisible) {
        console.log(this.modelerStore.element.businessObject.formKey, "新的值")
        this.$refs.formSelect.init()
      }
      console.log(3, this.elementId)
      this.elementType = activatedElement.type.split(":")[1] || "";
      this.conditionVisible = !!(
        this.elementType === "SequenceFlow" &&