feat:修复分支数据动态存储数据库bug
This commit is contained in:
@@ -71,6 +71,45 @@ export const useSelectionStore = defineStore('selection', () => {
|
||||
return flowBranches.value
|
||||
}
|
||||
|
||||
/**
|
||||
* 从主大纲同步最新的任务数据到分支的 tasks 中
|
||||
* @param mainOutlineTasks 主大纲中的 Collaboration Process 任务列表
|
||||
* @description 遍历所有分支,根据节点 ID 匹配主大纲中的任务,更新 tasks 数组
|
||||
*/
|
||||
function syncBranchTasksFromMainOutline(mainOutlineTasks: any[]): void {
|
||||
if (!mainOutlineTasks || !Array.isArray(mainOutlineTasks)) return
|
||||
|
||||
for (const branch of flowBranches.value) {
|
||||
if (!branch.nodes || !Array.isArray(branch.nodes)) continue
|
||||
|
||||
// 构建节点 ID 到任务详情的映射
|
||||
const nodeIdToTaskMap = new Map<string, any>()
|
||||
for (const node of branch.nodes) {
|
||||
if (node.data?.task) {
|
||||
nodeIdToTaskMap.set(node.id, node.data.task)
|
||||
}
|
||||
}
|
||||
|
||||
// 根据主大纲更新 tasks 数组
|
||||
const updatedTasks: any[] = []
|
||||
for (const node of branch.nodes) {
|
||||
const task = nodeIdToTaskMap.get(node.id)
|
||||
if (task) {
|
||||
// 从主大纲中找到对应 ID 的任务,使用主大纲中的最新数据
|
||||
const mainTask = mainOutlineTasks.find(
|
||||
(t: any) => t.Id === task.Id || t.StepName === task.StepName
|
||||
)
|
||||
if (mainTask) {
|
||||
updatedTasks.push(mainTask)
|
||||
} else {
|
||||
updatedTasks.push(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
branch.tasks = updatedTasks
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父节点 ID 获取流程图分支
|
||||
* @param parentNodeId 父节点 ID
|
||||
@@ -745,6 +784,7 @@ export const useSelectionStore = defineStore('selection', () => {
|
||||
removeFlowBranch,
|
||||
clearFlowBranches,
|
||||
clearFlowBranchesByParent,
|
||||
syncBranchTasksFromMainOutline,
|
||||
|
||||
// ==================== 任务过程分支管理方法 ====================
|
||||
addTaskProcessBranch,
|
||||
|
||||
Reference in New Issue
Block a user