feat:专家智能体评选分组和维度删除功能

This commit is contained in:
liailing1026
2026-03-01 22:41:19 +08:00
parent ceee955b44
commit f0f0d5bdcd
5 changed files with 122 additions and 11 deletions

View File

@@ -54,6 +54,17 @@ const taskOutlineList = computed(() => {
// 选中的任务大纲项
const selectedTaskOutline = ref<string>('')
// 监听 currentTask 变化,自动选中当前步骤
watch(
() => currentTask.value?.StepName,
(newStepName) => {
if (newStepName) {
selectedTaskOutline.value = newStepName
}
},
{ immediate: true }
)
// 判断任务大纲项是否被选中
const isTaskOutlineSelected = (task: { StepName?: string }) => {
return selectedTaskOutline.value === task.StepName
@@ -713,6 +724,9 @@ const getHeatmapColor = (score: number) => {
const deleteDialogVisible = ref(false)
const dimensionToDelete = ref<string | null>(null)
// 删除分组弹窗相关状态
const groupToDelete = ref<{ index: number; agents: string[] } | null>(null)
// 删除维度(显示确认对话框)
const handleDeleteDimension = (dimension: string, event: Event) => {
event.stopPropagation() // 阻止冒泡,避免触发维度选择
@@ -720,6 +734,13 @@ const handleDeleteDimension = (dimension: string, event: Event) => {
deleteDialogVisible.value = true
}
// 删除分组(显示确认对话框)
const handleDeleteGroup = (groupIndex: number, agents: string[], event: Event) => {
event.stopPropagation() // 阻止冒泡,避免触发分组选择
groupToDelete.value = { index: groupIndex, agents }
deleteDialogVisible.value = true
}
// 确认删除维度
const confirmDeleteDimension = async () => {
if (!dimensionToDelete.value) return
@@ -729,8 +750,7 @@ const confirmDeleteDimension = async () => {
// 先获取要删除的维度索引(在修改数据之前)
const dimensionIndex = scoreDimensions.value.indexOf(dimension)
if (dimensionIndex === -1) {
deleteDialogVisible.value = false
dimensionToDelete.value = null
// 维度不存在,不需要删除
return
}
@@ -794,11 +814,69 @@ const confirmDeleteDimension = async () => {
console.error('同步删除数据库维度失败:', error)
}
}
}
// 关闭对话框并清理状态
deleteDialogVisible.value = false
dimensionToDelete.value = null
}
// 确认删除分组
const confirmDeleteGroup = async () => {
if (!groupToDelete.value || !currentTask.value?.Id) return
const { index, agents: deletedAgents } = groupToDelete.value
const taskId = currentTask.value.Id
// 从 store 中删除分组
agentsStore.removeConfirmedAgentGroup(taskId, index)
// 从 selectionStore 中删除对应的 TaskProcess 数据
selectionStore.removeAgentTaskProcess(taskId, deletedAgents)
// 同步到数据库
const dbTaskId = (window as any).__CURRENT_TASK_ID__
if (dbTaskId && taskId) {
try {
const updatedGroups = agentsStore.getConfirmedAgentGroups(taskId)
// 获取更新后的所有组合的 TaskProcess 数据
const agentCombinations: Record<string, { process: any; brief: any }> = {}
updatedGroups.forEach(group => {
const processData = selectionStore.getAgentTaskProcess(taskId, group)
if (processData) {
const groupKey = selectionStore.getAgentGroupKey(group)
agentCombinations[groupKey] = {
process: processData.process || [],
brief: processData.brief || {}
}
}
})
await api.updateAssignedAgents({
task_id: dbTaskId,
step_id: taskId,
agents: [],
confirmed_groups: updatedGroups,
agent_combinations: agentCombinations
})
} catch (error) {
console.error('❌ 保存删除后的 confirmed_groups 失败:', error)
}
}
// 如果删除的分组是当前选中的分组,清除选中状态
if (isAgentGroupSelected(groupToDelete.value.agents)) {
selectedAssignmentGroup.value = []
selectedAgents.value = new Set()
}
}
// 统一确认删除处理
const handleConfirmDelete = async () => {
if (dimensionToDelete.value) {
await confirmDeleteDimension()
} else if (groupToDelete.value) {
await confirmDeleteGroup()
}
// 关闭对话框并清理状态
deleteDialogVisible.value = false
dimensionToDelete.value = null
groupToDelete.value = null
}
</script>
<template>
@@ -844,6 +922,7 @@ const confirmDeleteDimension = async () => {
icon-class="close"
size="14px"
color="var(--color-text-secondary)"
@click="handleDeleteGroup(groupIndex, group, $event)"
/>
</div>
<!-- 智能体列表容器选中时有渐变边框 -->
@@ -1086,12 +1165,12 @@ const confirmDeleteDimension = async () => {
</div>
</div>
<!-- 删除维度确认对话框 -->
<!-- 删除确认对话框 -->
<DeleteConfirmDialog
v-model="deleteDialogVisible"
title="确认删除该维度 ?"
content="删除后,该维度的评分数据将无法恢复 !"
@confirm="confirmDeleteDimension"
:title="groupToDelete ? '确认删除该分组 ?' : '确认删除该维度 ?'"
:content="groupToDelete ? '删除后,该分组的智能体数据将无法恢复 !' : '删除后,该维度的评分数据将无法恢复 !'"
@confirm="handleConfirmDelete"
/>
</div>
</template>