fix: 【bpm】bpmn设计器: 消息与信号不能保存,对应issure:#202 #206【同步自 vue3 + element-plus】

pull/292/MERGE
YunaiV 2025-12-07 12:28:24 +08:00
parent 7366b948a3
commit 274aa7da73
1 changed files with 37 additions and 0 deletions

View File

@ -136,6 +136,8 @@ const addNewObject = () => {
}
}
dialogVisible.value = false;
//
saveChanges();
initDataList();
};
@ -155,6 +157,8 @@ const removeObject = (type: any, row: any) => {
if (elementIndex !== -1) {
rootElements.value.splice(elementIndex, 1);
}
//
saveChanges();
//
initDataList();
message.success('移除成功');
@ -165,6 +169,39 @@ const removeObject = (type: any, row: any) => {
});
};
//
const saveChanges = () => {
const modeler = bpmnInstances().modeler;
if (!modeler) return;
try {
// canvas
const canvas = modeler.get('canvas');
// Process
const rootElement = canvas.getRootElement();
// changed
const eventBus = modeler.get('eventBus');
if (eventBus) {
eventBus.fire('root.added', { element: rootElement });
eventBus.fire('elements.changed', { elements: [rootElement] });
}
//
const commandStack = modeler.get('commandStack');
if (commandStack && commandStack._stack) {
//
commandStack.execute('element.updateProperties', {
element: rootElement,
properties: {},
});
}
} catch (error) {
console.warn('保存更改时出错:', error);
}
};
onMounted(() => {
initDataList();
});