feat:任务大纲探索窗口分支创建根节点基线完成度计算修改
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 自定义任务节点 -->
|
||||
<!-- 任务节点 -->
|
||||
<template #node-task="nodeProps">
|
||||
<TaskNode
|
||||
:key="nodeProps.data.updateKey || nodeProps.id"
|
||||
@@ -722,25 +722,12 @@ const handleAddBranch = async (taskId: string, branchContent: string) => {
|
||||
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
|
||||
const initialInput = agentsStore.agentRawPlan.data?.['Initial Input Object'] || []
|
||||
|
||||
// 提取现有步骤名称
|
||||
const existingSteps = collaborationProcess.value
|
||||
.map(step => step.StepName)
|
||||
.filter(Boolean) as string[]
|
||||
|
||||
// 计算基线完成度
|
||||
const baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(
|
||||
(collaborationProcess.value.length / collaborationProcess.value.length) * 100
|
||||
)
|
||||
: 0
|
||||
|
||||
// 调用 Mock API
|
||||
// 根节点分支:从零开始生成完整方案
|
||||
const response = await api.mockBranchPlanOutline({
|
||||
branch_Number: 1,
|
||||
Modification_Requirement: branchContent,
|
||||
Existing_Steps: existingSteps,
|
||||
Baseline_Completion: baselineCompletion,
|
||||
Existing_Steps: [],
|
||||
Baseline_Completion: 0,
|
||||
initialInputs: Array.isArray(initialInput) ? initialInput : [initialInput],
|
||||
goal: generalGoal
|
||||
})
|
||||
@@ -773,24 +760,12 @@ const handleAddBranch = async (taskId: string, branchContent: string) => {
|
||||
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
|
||||
const initialInput = agentsStore.agentRawPlan.data?.['Initial Input Object'] || []
|
||||
|
||||
// 提取现有步骤名称
|
||||
const existingSteps = collaborationProcess.value
|
||||
.map(step => step.StepName)
|
||||
.filter(Boolean) as string[]
|
||||
|
||||
// 计算基线完成度
|
||||
const baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(
|
||||
(collaborationProcess.value.length / collaborationProcess.value.length) * 100
|
||||
)
|
||||
: 0
|
||||
|
||||
// 根节点分支:从零开始生成完整方案
|
||||
const response = await api.branchPlanOutline({
|
||||
branch_Number: 1,
|
||||
Modification_Requirement: branchContent,
|
||||
Existing_Steps: existingSteps,
|
||||
Baseline_Completion: baselineCompletion,
|
||||
Existing_Steps: [],
|
||||
Baseline_Completion: 0,
|
||||
initialInputs: Array.isArray(initialInput) ? initialInput : [initialInput],
|
||||
goal: generalGoal
|
||||
})
|
||||
@@ -911,25 +886,67 @@ const handleAddBranch = async (taskId: string, branchContent: string) => {
|
||||
const newBranchNodes: Node[] = []
|
||||
const newBranchEdges: Edge[] = []
|
||||
|
||||
// 🆕 判断父节点是否是分支节点
|
||||
const parentIsBranchTask = parentNode.data.isBranchTask || false
|
||||
|
||||
if (USE_MOCK_DATA) {
|
||||
// 使用 Mock API
|
||||
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
|
||||
const initialInput = agentsStore.agentRawPlan.data?.['Initial Input Object'] || []
|
||||
|
||||
// 提取现有步骤名称
|
||||
const existingSteps = collaborationProcess.value
|
||||
.map(step => step.StepName)
|
||||
.filter(Boolean) as string[]
|
||||
// 🆕 根据父节点类型构建 existingSteps
|
||||
let existingSteps: any[] = []
|
||||
let baselineCompletion = 0
|
||||
|
||||
// 计算基线完成度
|
||||
const baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(
|
||||
(collaborationProcess.value.length / collaborationProcess.value.length) * 100
|
||||
)
|
||||
: 0
|
||||
if (!parentIsBranchTask) {
|
||||
// 父节点是主流程节点:传递主流程从 0 到父节点的步骤
|
||||
const parentTaskIndex = collaborationProcess.value.findIndex(
|
||||
task => task.StepName === parentNode.data.task.StepName
|
||||
)
|
||||
const parentIndex = parentTaskIndex >= 0 ? parentTaskIndex : 0
|
||||
|
||||
existingSteps = collaborationProcess.value.slice(0, parentIndex + 1).map(step => ({
|
||||
StepName: step.StepName,
|
||||
TaskContent: step.TaskContent,
|
||||
InputObject_List: step.InputObject_List || [],
|
||||
OutputObject: step.OutputObject || ''
|
||||
}))
|
||||
|
||||
baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(((parentIndex + 1) / collaborationProcess.value.length) * 100)
|
||||
: 0
|
||||
} else {
|
||||
// 父节点是分支节点:从分支数据中获取步骤
|
||||
const branches = selectionStore.getAllFlowBranches()
|
||||
|
||||
// 找到父节点所属的分支
|
||||
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(step => ({
|
||||
StepName: step.StepName,
|
||||
TaskContent: step.TaskContent,
|
||||
InputObject_List: step.InputObject_List || [],
|
||||
OutputObject: step.OutputObject || ''
|
||||
}))
|
||||
|
||||
// 分支节点的基线完成度:根据主流程进度计算
|
||||
const parentTaskIndex = collaborationProcess.value.findIndex(
|
||||
task => task.StepName === parentNode.data.task.StepName
|
||||
)
|
||||
const parentIndex = parentTaskIndex >= 0 ? parentTaskIndex : 0
|
||||
baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(((parentIndex + 1) / collaborationProcess.value.length) * 100)
|
||||
: 0
|
||||
}
|
||||
}
|
||||
|
||||
// 调用 Mock API
|
||||
const response = await api.mockBranchPlanOutline({
|
||||
branch_Number: 1,
|
||||
Modification_Requirement: branchContent,
|
||||
@@ -967,18 +984,58 @@ const handleAddBranch = async (taskId: string, branchContent: string) => {
|
||||
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
|
||||
const initialInput = agentsStore.agentRawPlan.data?.['Initial Input Object'] || []
|
||||
|
||||
// 提取现有步骤名称
|
||||
const existingSteps = collaborationProcess.value
|
||||
.map(step => step.StepName)
|
||||
.filter(Boolean) as string[]
|
||||
// 🆕 根据父节点类型构建 existingSteps
|
||||
let existingSteps: any[] = []
|
||||
let baselineCompletion = 0
|
||||
|
||||
// 计算基线完成度
|
||||
const baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(
|
||||
(collaborationProcess.value.length / collaborationProcess.value.length) * 100
|
||||
)
|
||||
: 0
|
||||
if (!parentIsBranchTask) {
|
||||
// 父节点是主流程节点:传递主流程从 0 到父节点的步骤
|
||||
const parentTaskIndex = collaborationProcess.value.findIndex(
|
||||
task => task.StepName === parentNode.data.task.StepName
|
||||
)
|
||||
const parentIndex = parentTaskIndex >= 0 ? parentTaskIndex : 0
|
||||
|
||||
existingSteps = collaborationProcess.value.slice(0, parentIndex + 1).map(step => ({
|
||||
StepName: step.StepName,
|
||||
TaskContent: step.TaskContent,
|
||||
InputObject_List: step.InputObject_List || [],
|
||||
OutputObject: step.OutputObject || ''
|
||||
}))
|
||||
|
||||
baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(((parentIndex + 1) / collaborationProcess.value.length) * 100)
|
||||
: 0
|
||||
} else {
|
||||
// 父节点是分支节点:从分支数据中获取步骤
|
||||
const branches = selectionStore.getAllFlowBranches()
|
||||
|
||||
// 找到父节点所属的分支
|
||||
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(step => ({
|
||||
StepName: step.StepName,
|
||||
TaskContent: step.TaskContent,
|
||||
InputObject_List: step.InputObject_List || [],
|
||||
OutputObject: step.OutputObject || ''
|
||||
}))
|
||||
|
||||
// 分支节点的基线完成度:根据主流程进度计算
|
||||
const parentTaskIndex = collaborationProcess.value.findIndex(
|
||||
task => task.StepName === parentNode.data.task.StepName
|
||||
)
|
||||
const parentIndex = parentTaskIndex >= 0 ? parentTaskIndex : 0
|
||||
baselineCompletion =
|
||||
collaborationProcess.value.length > 0
|
||||
? Math.round(((parentIndex + 1) / collaborationProcess.value.length) * 100)
|
||||
: 0
|
||||
}
|
||||
}
|
||||
|
||||
const response = await api.branchPlanOutline({
|
||||
branch_Number: 1,
|
||||
@@ -989,11 +1046,10 @@ const handleAddBranch = async (taskId: string, branchContent: string) => {
|
||||
goal: generalGoal
|
||||
})
|
||||
|
||||
console.log('API Response:', response)
|
||||
// 直接获取协作流程数据(API 返回二维数组 [[task1, task2, ...]],取第一个分支)
|
||||
newTasks = response?.[0] || []
|
||||
|
||||
// 调试日志:验证数据提取
|
||||
|
||||
console.log('获取到的新newTasks:', newTasks)
|
||||
// ========== 填充每个任务的 TaskProcess ==========
|
||||
for (let i = 0; i < newTasks.length; i++) {
|
||||
const task = newTasks[i]
|
||||
|
||||
@@ -189,7 +189,7 @@ function generateCollaborationBrief(task: IRawStepTask): {
|
||||
*
|
||||
* @param branch_Number - 分支数量
|
||||
* @param Modification_Requirement - 修改需求
|
||||
* @param Existing_Steps - 现有步骤名称列表
|
||||
* @param Existing_Steps - 现有步骤列表(包含完整信息的对象数组)
|
||||
* @param Baseline_Completion - 基线完成度
|
||||
* @param InitialObject_List - 初始对象列表
|
||||
* @param General_Goal - 总体目标
|
||||
@@ -198,7 +198,7 @@ function generateCollaborationBrief(task: IRawStepTask): {
|
||||
export const mockBranchPlanOutlineAPI = async (params: {
|
||||
branch_Number: number
|
||||
Modification_Requirement: string
|
||||
Existing_Steps: string[]
|
||||
Existing_Steps: any[] // 临时使用 any[],因为这里没有 IRawStepTask 类型
|
||||
Baseline_Completion: number
|
||||
InitialObject_List: string[]
|
||||
General_Goal: string
|
||||
@@ -221,7 +221,7 @@ export const mockBranchPlanOutlineAPI = async (params: {
|
||||
// 保存本次的选择索引
|
||||
sessionStorage.setItem(sessionKey, selectedBranchIndex.toString())
|
||||
|
||||
const rawBranchData = mockBranchDataRaw[selectedBranchIndex]
|
||||
const rawBranchData = mockBranchDataRaw[selectedBranchIndex] || []
|
||||
|
||||
console.log(
|
||||
'[Mock API] branch_PlanOutline 选择分支方案:',
|
||||
|
||||
Reference in New Issue
Block a user