import React, { useState } from 'react'; import { FileText, Search, Filter, Plus, Download, Edit3, Send, Clock, CheckCircle, AlertCircle, ChevronRight, Target, Brain, TrendingUp, Compass, Database, MoreHorizontal, FolderOpen, Folder, BarChart3, } from 'lucide-react'; import { useTheme } from '../contexts/ThemeContext'; import { PageType } from '../components/Sidebar'; type ResultCategory = 'planning' | 'mnty' | 'effect-pg' | 'xk' | 'dq-research' | 'other'; interface ResultTask { id: string; title: string; category: ResultCategory; subCategory: string; status: 'completed' | 'pending' | 'draft'; createdAt: string; updatedAt: string; reportType: 'strategy' | 'consult' | 'analysis' | 'summary'; agentCount: number; description: string; } interface ResultManagementProps { onNavigate: (page: PageType, taskId?: string) => void; initialCategory?: ResultCategory; } // 任务类别配置 const categoryConfig: Record = { 'planning': { label: '规划任务', icon: Target, color: 'blue', subCategories: ['目标分析', '品牌策略', '内容规划', '渠道规划', '叙事策略'] }, 'mnty': { label: 'MNTY任务', icon: Brain, color: 'purple', subCategories: ['机制研究', '方案设计', 'ZSTY分析'] }, 'effect-pg': { label: '效果PG任务', icon: TrendingUp, color: 'amber', subCategories: ['行为PG', '效果评估', '信息PG', '账号PG'] }, 'xk': { label: 'XK任务', icon: Compass, color: 'cyan', subCategories: ['任务JC', '任务调度'] }, 'dq-research': { label: 'DQ研究类任务', icon: Database, color: 'green', subCategories: ['受众分析', '知识库研究', '趋势研究'] }, 'other': { label: '其他类任务', icon: MoreHorizontal, color: 'slate', subCategories: ['通用分析', '临时任务', '其他'] } }; // 模拟任务数据 const mockTasks: ResultTask[] = [ { id: 'task-001', title: '五四青年节宣传活动策略', category: 'planning', subCategory: '叙事策略', status: 'completed', createdAt: '2026-03-19 10:30', updatedAt: '2026-03-19 15:30', reportType: 'strategy', agentCount: 6, description: '针对五四青年节的品牌传播策略方案' }, { id: 'task-002', title: '品牌年轻化受众分析', category: 'dq-research', subCategory: '受众分析', status: 'completed', createdAt: '2026-03-18 14:20', updatedAt: '2026-03-18 16:45', reportType: 'analysis', agentCount: 3, description: '分析Z世代用户的消费行为和品牌偏好' }, { id: 'task-003', title: 'UGC激励机制设计', category: 'effect-pg', subCategory: '效果评估', status: 'completed', createdAt: '2026-03-17 09:00', updatedAt: '2026-03-17 11:20', reportType: 'strategy', agentCount: 4, description: '设计用户生成内容激励机制方案' }, { id: 'task-004', title: '短视频平台效果预测', category: 'mnty', subCategory: '方案设计', status: 'pending', createdAt: '2026-03-20 08:00', updatedAt: '2026-03-20 08:00', reportType: 'consult', agentCount: 5, description: '预测不同短视频平台的传播效果' }, { id: 'task-005', title: '活动传播风险评估', category: 'planning', subCategory: '目标分析', status: 'draft', createdAt: '2026-03-20 10:00', updatedAt: '2026-03-20 10:30', reportType: 'analysis', agentCount: 2, description: '评估五四活动可能面临的传播风险' }, { id: 'task-006', title: '竞品营销策略研究', category: 'dq-research', subCategory: '趋势研究', status: 'completed', createdAt: '2026-03-16 13:00', updatedAt: '2026-03-16 18:00', reportType: 'analysis', agentCount: 3, description: '分析主要竞品的营销策略和效果' }, ]; const ResultManagement: React.FC = ({ onNavigate, initialCategory = 'planning' }) => { const { theme } = useTheme(); const isDark = theme === 'dark'; // 主题颜色类 const cardBg = isDark ? 'bg-slate-800/30' : 'bg-white'; const cardBorder = isDark ? 'border-blue-800/30' : 'border-gray-200'; const textPrimary = isDark ? 'text-white' : 'text-gray-900'; const textSecondary = isDark ? 'text-slate-400' : 'text-gray-600'; const textMuted = isDark ? 'text-slate-500' : 'text-gray-500'; const btnPrimary = isDark ? 'bg-blue-600 hover:bg-blue-500' : 'bg-red-600 hover:bg-red-500'; const btnSecondary = isDark ? 'bg-slate-700/50 hover:bg-slate-600/50 border-blue-800/30 text-slate-300' : 'bg-gray-100 hover:bg-gray-200 border-gray-300 text-gray-700'; const inputBg = isDark ? 'bg-slate-900/50' : 'bg-gray-50'; const inputBorder = isDark ? 'border-blue-800/30' : 'border-gray-300'; // 状态 const [selectedCategory, setSelectedCategory] = useState(initialCategory); const [selectedSubCategory, setSelectedSubCategory] = useState(null); const [searchQuery, setSearchQuery] = useState(''); const [statusFilter, setStatusFilter] = useState<'all' | 'completed' | 'pending' | 'draft'>('all'); const [expandedCategories, setExpandedCategories] = useState>( new Set([initialCategory]) ); // 切换分类展开状态 const toggleCategory = (category: ResultCategory) => { setExpandedCategories(prev => { const next = new Set(prev); if (next.has(category)) { next.delete(category); } else { next.add(category); } return next; }); }; // 过滤任务 const filteredTasks = mockTasks.filter(task => { const matchesCategory = task.category === selectedCategory; const matchesSubCategory = !selectedSubCategory || task.subCategory === selectedSubCategory; const matchesSearch = !searchQuery || task.title.toLowerCase().includes(searchQuery.toLowerCase()) || task.description.toLowerCase().includes(searchQuery.toLowerCase()); const matchesStatus = statusFilter === 'all' || task.status === statusFilter; return matchesCategory && matchesSubCategory && matchesSearch && matchesStatus; }); // 获取状态样式 const getStatusStyle = (status: ResultTask['status']) => { switch (status) { case 'completed': return { bg: isDark ? 'bg-green-500/20 text-green-400' : 'bg-green-100 text-green-700', icon: CheckCircle, label: '已完成' }; case 'pending': return { bg: isDark ? 'bg-yellow-500/20 text-yellow-400' : 'bg-yellow-100 text-yellow-700', icon: Clock, label: '进行中' }; case 'draft': return { bg: isDark ? 'bg-slate-500/20 text-slate-400' : 'bg-gray-100 text-gray-700', icon: Edit3, label: '草稿' }; } }; // 获取报告类型样式 const getReportTypeStyle = (type: ResultTask['reportType']) => { const styles = { 'strategy': { color: 'blue', label: '策略报告' }, 'consult': { color: 'purple', label: '会商报告' }, 'analysis': { color: 'cyan', label: '分析报告' }, 'summary': { color: 'green', label: '总结报告' } }; return styles[type]; }; // 查看任务详情 const handleViewDetail = (taskId: string) => { onNavigate('result-detail', taskId); }; const currentCategoryConfig = categoryConfig[selectedCategory]; const CategoryIcon = currentCategoryConfig.icon; return (
{/* 左侧分类导航 */}

结果管理

{/* 分类列表 */}
{(Object.entries(categoryConfig) as [ResultCategory, typeof categoryConfig[ResultCategory]][]).map(([key, config]) => { const Icon = config.icon; const isExpanded = expandedCategories.has(key); const isActive = selectedCategory === key; return (
{/* 一级分类 */} {/* 二级分类 */} {isExpanded && (
{/* 全部 */} {/* 各子分类 */} {config.subCategories.map(sub => { const count = mockTasks.filter(t => t.category === key && t.subCategory === sub).length; if (count === 0) return null; return ( ); })}
)}
); })}
{/* 右侧任务列表 */}
{/* 顶部工具栏 */}

{selectedSubCategory || currentCategoryConfig.label}

共 {filteredTasks.length} 个结果

{/* 搜索和筛选 */}
setSearchQuery(e.target.value)} placeholder="搜索任务标题或描述..." className={`w-full pl-10 pr-4 py-2.5 rounded-lg text-sm bg-transparent focus:outline-none ${ isDark ? 'text-white placeholder-slate-500' : 'text-gray-800 placeholder-gray-400' }`} />
{/* 任务列表 */}
{filteredTasks.length === 0 ? (

暂无结果

在对应任务中生成结果后,将在此显示

) : (
{filteredTasks.map((task) => { const statusInfo = getStatusStyle(task.status); const StatusIcon = statusInfo.icon; const reportTypeInfo = getReportTypeStyle(task.reportType); return ( handleViewDetail(task.id)} > ); })}
任务名称 报告类型 智能体数 状态 更新时间 操作

{task.title}

{task.description}

{reportTypeInfo.label} {task.agentCount} {statusInfo.label} {task.updatedAt} e.stopPropagation()}>
)}
{/* 自定义滚动条样式 */}
); }; export default ResultManagement;