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

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

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>

View File

@@ -292,6 +292,15 @@ export const useAgentsStore = defineStore('agents', () => {
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 planTaskWindow = ref(false)
const agentAllocationDialog = ref(false)
@@ -645,6 +654,7 @@ export const useAgentsStore = defineStore('agents', () => {
clearConfirmedAgentGroups,
clearAllConfirmedAgentGroups,
setConfirmedAgentGroups,
removeConfirmedAgentGroup,
// 停止填充状态
hasStoppedFilling,
setHasStoppedFilling,

View File

@@ -424,6 +424,16 @@ export const useSelectionStore = defineStore('selection', () => {
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 数据
* @param taskId 任务 ID
@@ -656,6 +666,7 @@ export const useSelectionStore = defineStore('selection', () => {
setAgentTaskProcess,
getAgentTaskProcess,
hasAgentTaskProcess,
removeAgentTaskProcess,
clearAgentTaskProcess,
getAgentCombinations,
clearAllAgentTaskProcess,