feat:修改任务过程大纲探索后端返回不符合用户要求的bug

This commit is contained in:
liailing1026
2026-01-13 17:58:52 +08:00
parent 244deceb91
commit 0e87777ae8
4 changed files with 120 additions and 40 deletions

View File

@@ -268,8 +268,6 @@ const initializeFlow = () => {
const branchesInitialized = sessionStorage.getItem(branchesInitKey) === 'true'
if (branchesInitialized && savedBranches.length > 0) {
// ✅ 已有分支,完全从 store 恢复所有节点和边
// 🔑 关键清空当前节点完全从store恢复确保初始流程节点位置和数据不变
nodes.value = []
edges.value = []
@@ -703,6 +701,9 @@ const onNodeClick = (event: any) => {
// 🆕 点击主流程节点时,从 store 读取"初始流程"分支的副本
if (currentTask.value) {
const taskStepId = currentTask.value.Id
if (!taskStepId) {
return
}
const currentAgents = currentTask.value.AgentSelection || []
const branches = selectionStore.getTaskProcessBranches(taskStepId, currentAgents)
const initialBranch = branches.find(branch => branch.branchContent === '初始流程')
@@ -806,16 +807,14 @@ const submitBranch = async () => {
// 使用 Mock API
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
// 计算基线完成度
const currentTaskProcess = taskProcess.value || []
const baselineCompletion = currentTaskProcess.length > 0 ? 0 : 100
// 调用 Mock API返回 2D 数组,与后端格式一致)
// 🆕 根节点分支:从零开始生成完整方案
// Baseline_Completion = 0 表示没有已完成的部分,需要生成所有阶段
// Existing_Steps 传空数组,不传递初始流程信息
const response = await api.mockBranchTaskProcess({
branch_Number: 1,
Modification_Requirement: branchContent,
Existing_Steps: [],
Baseline_Completion: baselineCompletion,
Existing_Steps: [], // ← 根节点分支不传递现有步骤
Baseline_Completion: 0, // ← 从零开始
stepTaskExisting: currentTask.value,
goal: generalGoal
})
@@ -843,15 +842,14 @@ const submitBranch = async () => {
// 调用真实 API
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
// 计算基线完成度
const currentTaskProcess = taskProcess.value || []
const baselineCompletion = currentTaskProcess.length > 0 ? 0 : 100
// 🆕 根节点分支:从零开始生成完整方案
// Baseline_Completion = 0 表示没有已完成的部分,需要生成所有阶段
// Existing_Steps 传空数组,不传递初始流程信息
const response = await api.branchTaskProcess({
branch_Number: 1,
Modification_Requirement: branchContent,
Existing_Steps: [],
Baseline_Completion: baselineCompletion,
Existing_Steps: [], // ← 根节点分支不传递现有步骤
Baseline_Completion: 0, // ← 从零开始
stepTaskExisting: currentTask.value,
goal: generalGoal
})
@@ -989,28 +987,68 @@ const submitBranch = async () => {
}
} else {
// ========== Agent 节点分支 ==========
// 获取父 agent 节点的原始索引
const parentIsBranchTask = parentNode.data.isBranchTask || false
const parentOriginalIndex = parentNode.data.originalIndex ?? 0
const parentAgentName = parentNode.data.agentName
let newAgentActions: IApiAgentAction[] = []
if (USE_MOCK_DATA) {
// 使用 Mock API
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
// 计算基线完成度
const currentTaskProcess = taskProcess.value || []
const baselineCompletion =
currentTaskProcess.length > 0
? Math.round(((parentOriginalIndex + 1) / currentTaskProcess.length) * 100)
: 100
// 🆕 根据父节点类型构建 existingSteps
let existingSteps: any[] = []
let baselineCompletion = 100
if (!parentIsBranchTask) {
// 父节点是主流程节点:传递主流程从 0 到父节点的步骤
baselineCompletion =
currentTaskProcess.length > 0
? Math.round(((parentOriginalIndex + 1) / currentTaskProcess.length) * 100)
: 100
existingSteps = currentTaskProcess.slice(0, parentOriginalIndex + 1).map((p: any) => ({
ID: p.ID,
ActionType: p.ActionType,
AgentName: p.AgentName,
Description: p.Description,
ImportantInput: p.ImportantInput || []
}))
} else {
// 父节点是分支节点:从分支数据中获取步骤
const taskStepId = currentTask.value?.Id || ''
const currentAgents = currentTask.value?.AgentSelection || []
const branches = selectionStore.getTaskProcessBranches(taskStepId, currentAgents)
// 找到父节点所属的分支
const parentBranch = branches.find(branch =>
branch.nodes.some(n => n.id === parentNode.id)
)
if (parentBranch && parentBranch.tasks) {
// 获取分支中从第一个节点到父节点的所有步骤
const parentIndexInBranch = parentBranch.nodes.findIndex(n => n.id === parentNode.id)
existingSteps = parentBranch.tasks.slice(0, parentIndexInBranch + 1).map((p: any) => ({
ID: p.ID,
ActionType: p.ActionType,
AgentName: p.AgentName,
Description: p.Description,
ImportantInput: p.ImportantInput || []
}))
// 分支节点的基线完成度:根据主流程进度计算
baselineCompletion =
currentTaskProcess.length > 0
? Math.round(((parentOriginalIndex + 1) / currentTaskProcess.length) * 100)
: 100
}
}
// 调用 Mock API
const response = await api.mockBranchTaskProcess({
branch_Number: 1,
Modification_Requirement: branchContent,
Existing_Steps: [],
Existing_Steps: existingSteps,
Baseline_Completion: baselineCompletion,
stepTaskExisting: currentTask.value,
goal: generalGoal
@@ -1038,23 +1076,66 @@ const submitBranch = async () => {
} else {
// 调用真实 API
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
// 计算基线完成度
const currentTaskProcess = taskProcess.value || []
const baselineCompletion =
currentTaskProcess.length > 0
? Math.round(((parentOriginalIndex + 1) / currentTaskProcess.length) * 100)
: 100
// 🆕 根据父节点类型构建 existingSteps
let existingSteps: any[] = []
let baselineCompletion = 100
if (!parentIsBranchTask) {
// 父节点是主流程节点:传递主流程从 0 到父节点的步骤
baselineCompletion =
currentTaskProcess.length > 0
? Math.round(((parentOriginalIndex + 1) / currentTaskProcess.length) * 100)
: 100
existingSteps = currentTaskProcess.slice(0, parentOriginalIndex + 1).map((p: any) => ({
ID: p.ID,
ActionType: p.ActionType,
AgentName: p.AgentName,
Description: p.Description,
ImportantInput: p.ImportantInput || []
}))
} else {
// 父节点是分支节点:从分支数据中获取步骤
const taskStepId = currentTask.value?.Id || ''
const currentAgents = currentTask.value?.AgentSelection || []
const branches = selectionStore.getTaskProcessBranches(taskStepId, currentAgents)
// 找到父节点所属的分支
const parentBranch = branches.find(branch =>
branch.nodes.some(n => n.id === parentNode.id)
)
if (parentBranch && parentBranch.tasks) {
// 获取分支中从第一个节点到父节点的所有步骤
const parentIndexInBranch = parentBranch.nodes.findIndex(n => n.id === parentNode.id)
existingSteps = parentBranch.tasks.slice(0, parentIndexInBranch + 1).map((p: any) => ({
ID: p.ID,
ActionType: p.ActionType,
AgentName: p.AgentName,
Description: p.Description,
ImportantInput: p.ImportantInput || []
}))
// 分支节点的基线完成度:根据主流程进度计算
baselineCompletion =
currentTaskProcess.length > 0
? Math.round(((parentOriginalIndex + 1) / currentTaskProcess.length) * 100)
: 100
}
}
const response = await api.branchTaskProcess({
branch_Number: 1,
Modification_Requirement: branchContent,
Existing_Steps: [],
Existing_Steps: existingSteps,
Baseline_Completion: baselineCompletion,
stepTaskExisting: currentTask.value,
goal: generalGoal
})
console.log('branchTaskProcess response:', response)
// 后端返回格式: [[action1, action2], [action3, action4]]
// 取第一个分支
if (response && response.length > 0) {