fix: 【bpm】bpmn设计器: 消息与信号不能保存,对应issure:#202 #206【同步自 vue3 + element-plus】
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user