Files
SBrainCO/client/src/components/DecisionCard.tsx
T
selfrelease d373fb5f0c feat: 新增智脑决策中心模块(决策中心/AI员工组织/知识资产)
- 新增 DecisionsPage、AgentsPage、KnowledgePage 三个页面
- 新增 DecisionCard、DecisionDrawer、DecisionSummary、KnowledgeCard、LoopHealthBar、AgentCard 组件
- 新增 decision-aggregator 决策聚合逻辑和 agents 数据
- Layout 导航重构:新增智脑决策分组,调整系统配置和经营本体分组
- BossPage 集成决策摘要和闭环健康度,利润机会池支持警告样式
- TasksPage 增强任务展示
- 抽屉式详情统一改为居中弹窗风格
- data.ts 后端调整
- run.md 更新数据库连接说明
- 新增玄谋智脑实际版建设方案文档

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-14 19:34:04 +08:00

89 lines
3.1 KiB
TypeScript

/**
* 决策卡组件
*
* 在决策中心列表中展示单个决策卡,点击可展开详情抽屉。
*/
import { ChevronRight } from 'lucide-react'
import { cn, formatCurrency } from '@/lib/utils'
import type { DecisionCard } from '@/lib/decision-aggregator'
import { SOURCE_LABELS, LEVEL_LABELS } from '@/lib/decision-aggregator'
interface DecisionCardProps {
decision: DecisionCard
index: number
approved: boolean
onOpen: (d: DecisionCard) => void
}
/** 来源类型颜色 */
const SOURCE_COLORS: Record<string, string> = {
profit_opportunity: 'bg-purple-100 text-purple-700',
risk_alert: 'bg-red-100 text-red-700',
task_anomaly: 'bg-amber-100 text-amber-700',
}
/** 等级颜色 */
const LEVEL_COLORS: Record<string, string> = {
L1: 'bg-red-50 text-red-600 border border-red-200',
L2: 'bg-amber-50 text-amber-600 border border-amber-200',
L3: 'bg-green-50 text-green-600 border border-green-200',
}
export function DecisionCardItem({ decision, index, approved, onOpen }: DecisionCardProps) {
const isApproved = approved || decision.status === '已批准'
return (
<button
className="flex w-full items-center gap-3 border-b px-4 py-3 text-left transition-colors hover:bg-muted/40"
onClick={() => onOpen(decision)}
>
{/* 排名序号 */}
<span
className={cn(
'flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-bold',
index < 3 ? 'bg-purple-600 text-white' : 'bg-muted text-muted-foreground',
)}
>
{index + 1}
</span>
{/* 主体内容 */}
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<span className={cn('rounded px-1.5 py-0.5 text-[10px] font-medium', SOURCE_COLORS[decision.sourceType])}>
{SOURCE_LABELS[decision.sourceType]}
</span>
<span className={cn('rounded px-1.5 py-0.5 text-[10px] font-medium', LEVEL_COLORS[decision.level])}>
{LEVEL_LABELS[decision.level]}
</span>
<span className="text-[10px] text-muted-foreground">{decision.agentName}</span>
</div>
<p className="mt-1 truncate text-sm font-medium">{decision.title}</p>
<p className="mt-0.5 truncate text-xs text-muted-foreground">{decision.reason}</p>
</div>
{/* 影响金额 + 状态 */}
<div className="shrink-0 text-right">
{decision.impactAmount > 0 ? (
<p className="text-sm font-bold text-green-600">{formatCurrency(decision.impactAmount)}</p>
) : (
<p className="text-sm font-medium text-muted-foreground">{decision.impactDescription}</p>
)}
<p className="text-[10px] text-muted-foreground">{decision.deadline}</p>
</div>
{/* 状态标签 */}
<span
className={cn(
'shrink-0 rounded px-2 py-0.5 text-[10px] font-medium',
isApproved ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-600',
)}
>
{isApproved ? '已批准' : decision.status}
</span>
<ChevronRight className="h-4 w-4 shrink-0 text-muted-foreground" />
</button>
)
}