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