feat:执行过程编排页面重构及删除功能新增

This commit is contained in:
liailing1026
2026-03-03 09:56:58 +08:00
parent f0f0d5bdcd
commit 2be5a5a454
5 changed files with 739 additions and 336 deletions

View File

@@ -677,6 +677,37 @@ class Api {
}
}
/**
* 删除任务过程分支数据
* @param TaskID 大任务ID
* @param stepId 小任务ID
* @param branchId 要删除的分支ID
* @returns 是否删除成功
*/
deleteTaskProcessBranch = async (
TaskID: string,
stepId: string,
branchId: string,
): Promise<boolean> => {
if (!websocket.connected) {
throw new Error('WebSocket未连接')
}
try {
const rawResponse = await websocket.send('delete_task_process_branch', {
task_id: TaskID,
stepId,
branchId,
})
const response = this.extractResponse<{ status: string }>(rawResponse)
return response?.status === 'success' || false
} catch (error) {
console.error('删除任务过程分支数据失败:', error)
return false
}
}
/**
* 更新任务大纲数据
* @param taskId 任务ID

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { ref, computed, watch, nextTick } from 'vue'
import { useAgentsStore } from '@/stores'
import SvgIcon from '@/components/SvgIcon/index.vue'
import PlanModification from './TaskSyllabus/Branch/PlanModification.vue'
@@ -13,6 +13,9 @@ const visible = ref(false)
const activeTab = ref('outline')
const isMaximized = ref(false)
// PlanTask 组件引用
const planTaskRef = ref<InstanceType<typeof PlanTask> | null>(null)
// 判断是否有流程数据
const planReady = computed(() => {
return agentsStore.agentRawPlan.data !== undefined
@@ -66,6 +69,18 @@ const handleTabChange = (tabKey: string) => {
activeTab.value = tabKey
}
// 切换到执行过程编排时,延迟触发自适应视图
watch(activeTab, (newTab) => {
if (newTab === 'process') {
nextTick(() => {
setTimeout(() => {
// 通过 expose 的方法触发自适应视图(如果有的话)
;(planTaskRef.value as any)?.triggerFitView?.()
}, 400)
})
}
})
// 切换最大化/还原
const toggleMaximize = () => {
isMaximized.value = !isMaximized.value
@@ -126,7 +141,7 @@ defineExpose({
<!-- 任务过程 -->
<div v-show="activeTab === 'process'" class="tab-content">
<PlanTask />
<PlanTask ref="planTaskRef" />
</div>
</div>
</div>

View File

@@ -310,6 +310,26 @@ export const useSelectionStore = defineStore('selection', () => {
return result
}
/**
* 从数据库删除指定分支
* @param TaskID 大任务ID数据库主键
* @param stepId 小任务ID
* @param branchId 要删除的分支ID
* @returns Promise<boolean> 是否删除成功
*/
async function deleteTaskProcessBranchFromDB(
TaskID: string,
stepId: string,
branchId: string,
): Promise<boolean> {
// 导入 api避免循环导入问题
const { default: api } = await import('@/api')
const result = await api.deleteTaskProcessBranch(TaskID, stepId, branchId)
return result
}
/**
* 从数据库恢复任务过程分支数据
* @param dbBranches 从数据库读取的任务过程分支数据
@@ -676,6 +696,7 @@ export const useSelectionStore = defineStore('selection', () => {
saveBranchesToDB,
restoreAgentCombinationsFromDB,
saveTaskProcessBranchesToDB,
deleteTaskProcessBranchFromDB,
restoreTaskProcessBranchesFromDB,
}
})