This commit is contained in:
YunaiV
2025-12-07 12:01:01 +08:00

View File

@@ -197,6 +197,8 @@ const addNewObject = () => {
}
}
dialogVisible.value = false
// 触发建模器更新以保存更改
saveChanges()
initDataList()
}
@@ -214,6 +216,8 @@ const removeObject = (type, row) => {
if (elementIndex !== -1) {
rootElements.value.splice(elementIndex, 1)
}
// 触发建模器更新以保存更改
saveChanges()
// 刷新列表
initDataList()
message.success('移除成功')
@@ -221,6 +225,39 @@ const removeObject = (type, row) => {
.catch(() => console.info('操作取消'))
}
// 触发建模器更新以保存更改
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()
})