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

@@ -2508,9 +2508,16 @@ def handle_update_assigned_agents(data):
# 更新 confirmed_groups确认的组合列表 # 更新 confirmed_groups确认的组合列表
if confirmed_groups: if confirmed_groups:
existing_assigned[step_id]["confirmed_groups"] = confirmed_groups existing_assigned[step_id]["confirmed_groups"] = confirmed_groups
# 清理已删除分组的 agent_combinations 数据
existing_combinations = existing_assigned[step_id].get("agent_combinations", {})
new_combinations_keys = {json.dumps(list(group), sort_keys=True) for group in confirmed_groups}
keys_to_remove = [k for k in existing_combinations.keys() if k not in new_combinations_keys]
for key in keys_to_remove:
del existing_combinations[key]
existing_assigned[step_id]["agent_combinations"] = existing_combinations
# 更新 agent_combinations保存 TaskProcess 数据) # 更新 agent_combinations保存 TaskProcess 数据)
if agent_combinations: elif agent_combinations:
# 合并新旧数据 # 合并新旧数据
existing_combinations = existing_assigned[step_id].get("agent_combinations", {}) existing_combinations = existing_assigned[step_id].get("agent_combinations", {})
for key, value in agent_combinations.items(): for key, value in agent_combinations.items():

View File

@@ -73,6 +73,10 @@ watch(
// 监听对话框显示状态变化 // 监听对话框显示状态变化
watch(dialogVisible, val => { watch(dialogVisible, val => {
emit('update:modelValue', val) emit('update:modelValue', val)
// 当对话框关闭时,重置 loading 状态
if (!val) {
loading.value = false
}
}) })
// 确认删除 // 确认删除

View File

@@ -54,6 +54,17 @@ const taskOutlineList = computed(() => {
// 选中的任务大纲项 // 选中的任务大纲项
const selectedTaskOutline = ref<string>('') const selectedTaskOutline = ref<string>('')
// 监听 currentTask 变化,自动选中当前步骤
watch(
() => currentTask.value?.StepName,
(newStepName) => {
if (newStepName) {
selectedTaskOutline.value = newStepName
}
},
{ immediate: true }
)
// 判断任务大纲项是否被选中 // 判断任务大纲项是否被选中
const isTaskOutlineSelected = (task: { StepName?: string }) => { const isTaskOutlineSelected = (task: { StepName?: string }) => {
return selectedTaskOutline.value === task.StepName return selectedTaskOutline.value === task.StepName
@@ -713,6 +724,9 @@ const getHeatmapColor = (score: number) => {
const deleteDialogVisible = ref(false) const deleteDialogVisible = ref(false)
const dimensionToDelete = ref<string | null>(null) const dimensionToDelete = ref<string | null>(null)
// 删除分组弹窗相关状态
const groupToDelete = ref<{ index: number; agents: string[] } | null>(null)
// 删除维度(显示确认对话框) // 删除维度(显示确认对话框)
const handleDeleteDimension = (dimension: string, event: Event) => { const handleDeleteDimension = (dimension: string, event: Event) => {
event.stopPropagation() // 阻止冒泡,避免触发维度选择 event.stopPropagation() // 阻止冒泡,避免触发维度选择
@@ -720,6 +734,13 @@ const handleDeleteDimension = (dimension: string, event: Event) => {
deleteDialogVisible.value = true deleteDialogVisible.value = true
} }
// 删除分组(显示确认对话框)
const handleDeleteGroup = (groupIndex: number, agents: string[], event: Event) => {
event.stopPropagation() // 阻止冒泡,避免触发分组选择
groupToDelete.value = { index: groupIndex, agents }
deleteDialogVisible.value = true
}
// 确认删除维度 // 确认删除维度
const confirmDeleteDimension = async () => { const confirmDeleteDimension = async () => {
if (!dimensionToDelete.value) return if (!dimensionToDelete.value) return
@@ -729,8 +750,7 @@ const confirmDeleteDimension = async () => {
// 先获取要删除的维度索引(在修改数据之前) // 先获取要删除的维度索引(在修改数据之前)
const dimensionIndex = scoreDimensions.value.indexOf(dimension) const dimensionIndex = scoreDimensions.value.indexOf(dimension)
if (dimensionIndex === -1) { if (dimensionIndex === -1) {
deleteDialogVisible.value = false // 维度不存在,不需要删除
dimensionToDelete.value = null
return return
} }
@@ -794,11 +814,69 @@ const confirmDeleteDimension = async () => {
console.error('同步删除数据库维度失败:', error) console.error('同步删除数据库维度失败:', error)
} }
} }
}
// 确认删除分组
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 deleteDialogVisible.value = false
dimensionToDelete.value = null dimensionToDelete.value = null
} groupToDelete.value = null
}
</script> </script>
<template> <template>
@@ -844,6 +922,7 @@ const confirmDeleteDimension = async () => {
icon-class="close" icon-class="close"
size="14px" size="14px"
color="var(--color-text-secondary)" color="var(--color-text-secondary)"
@click="handleDeleteGroup(groupIndex, group, $event)"
/> />
</div> </div>
<!-- 智能体列表容器选中时有渐变边框 --> <!-- 智能体列表容器选中时有渐变边框 -->
@@ -1086,12 +1165,12 @@ const confirmDeleteDimension = async () => {
</div> </div>
</div> </div>
<!-- 删除维度确认对话框 --> <!-- 删除确认对话框 -->
<DeleteConfirmDialog <DeleteConfirmDialog
v-model="deleteDialogVisible" v-model="deleteDialogVisible"
title="确认删除该维度 ?" :title="groupToDelete ? '确认删除该分组 ?' : '确认删除该维度 ?'"
content="删除后,该维度的评分数据将无法恢复 !" :content="groupToDelete ? '删除后,该分组的智能体数据将无法恢复 !' : '删除后,该维度的评分数据将无法恢复 !'"
@confirm="confirmDeleteDimension" @confirm="handleConfirmDelete"
/> />
</div> </div>
</template> </template>

View File

@@ -292,6 +292,15 @@ export const useAgentsStore = defineStore('agents', () => {
confirmedAgentGroupsMap.value.set(taskId, groups) confirmedAgentGroupsMap.value.set(taskId, groups)
} }
// 删除指定任务的某个agent组合
function removeConfirmedAgentGroup(taskId: string, groupIndex: number) {
const groups = confirmedAgentGroupsMap.value.get(taskId) || []
if (groupIndex >= 0 && groupIndex < groups.length) {
groups.splice(groupIndex, 1)
confirmedAgentGroupsMap.value.set(taskId, groups)
}
}
const planModificationWindow = ref(false) const planModificationWindow = ref(false)
const planTaskWindow = ref(false) const planTaskWindow = ref(false)
const agentAllocationDialog = ref(false) const agentAllocationDialog = ref(false)
@@ -645,6 +654,7 @@ export const useAgentsStore = defineStore('agents', () => {
clearConfirmedAgentGroups, clearConfirmedAgentGroups,
clearAllConfirmedAgentGroups, clearAllConfirmedAgentGroups,
setConfirmedAgentGroups, setConfirmedAgentGroups,
removeConfirmedAgentGroup,
// 停止填充状态 // 停止填充状态
hasStoppedFilling, hasStoppedFilling,
setHasStoppedFilling, setHasStoppedFilling,

View File

@@ -424,6 +424,16 @@ export const useSelectionStore = defineStore('selection', () => {
return agentTaskProcessMap.value.get(taskId)?.has(groupKey) || false return agentTaskProcessMap.value.get(taskId)?.has(groupKey) || false
} }
/**
* 删除指定任务的某个 agent 组合的 TaskProcess 数据
* @param taskId 任务 ID
* @param agents Agent 列表
*/
function removeAgentTaskProcess(taskId: string, agents: string[]) {
const groupKey = getAgentGroupKey(agents)
agentTaskProcessMap.value.get(taskId)?.delete(groupKey)
}
/** /**
* 清除指定任务的所有 agent 组合 TaskProcess 数据 * 清除指定任务的所有 agent 组合 TaskProcess 数据
* @param taskId 任务 ID * @param taskId 任务 ID
@@ -656,6 +666,7 @@ export const useSelectionStore = defineStore('selection', () => {
setAgentTaskProcess, setAgentTaskProcess,
getAgentTaskProcess, getAgentTaskProcess,
hasAgentTaskProcess, hasAgentTaskProcess,
removeAgentTaskProcess,
clearAgentTaskProcess, clearAgentTaskProcess,
getAgentCombinations, getAgentCombinations,
clearAllAgentTaskProcess, clearAllAgentTaskProcess,