/** * filekorolheader: 地块决策分布地图组件 - 地理位置决策可视化 * 功能:地块标记、状态可视化、悬浮详情、图例说明 * 路径:/ai-crop-model/support/dashboard/components/DecisionMap * 规范:遵循crop-x/docs/开发项目规范.md,使用shadcn语义化样式 */ import { Card } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { MapPin, Map as MapIcon } from 'lucide-react'; import { FieldDecisionInfo } from './aiDecisionDashboardReducer'; interface DecisionMapProps { fieldDecisions: FieldDecisionInfo[]; } export function DecisionMap({ fieldDecisions }: DecisionMapProps) { return (

地块决策分布地图

{fieldDecisions.length}个地块
{/* 模拟地图区域 */}
{/* 地图背景 */}
{/* 地块标记点 */} {fieldDecisions.map((field, index) => { // 计算标记点位置(模拟分布) const positions = [ { top: '15%', left: '20%' }, { top: '25%', left: '65%' }, { top: '45%', left: '30%' }, { top: '55%', left: '75%' }, { top: '70%', left: '45%' }, { top: '35%', left: '85%' }, { top: '80%', left: '25%' }, ]; const position = positions[index] || { top: '50%', left: '50%' }; return (
{/* 标记点 */}
0 ? 'bg-red-500 dark:bg-red-600' : field.generatedCount > 0 ? 'bg-blue-500 dark:bg-blue-600' : field.executingCount > 0 ? 'bg-purple-500 dark:bg-purple-600' : 'bg-green-500 dark:bg-green-600' }`}>
{/* 决策数量标记 */} {field.decisions.length > 0 && (
{field.decisions.length}
)} {/* 悬浮信息卡片 */}
{field.fieldName}
{field.cropType} · {field.area}亩
总决策: {field.decisions.length}条
{field.urgentCount > 0 && (
紧急: {field.urgentCount}条
)} {field.generatedCount > 0 && (
已生成: {field.generatedCount}条
)} {field.executingCount > 0 && (
执行中: {field.executingCount}条
)} {field.completedCount > 0 && (
已完成: {field.completedCount}条
)}
{/* 最新决策 */} {field.decisions.length > 0 && (
最新决策:
{field.decisions[0].title}
)}
); })} {/* 图例 */}
状态图例
有紧急决策
有待执行决策
有执行中决策
全部完成
{/* 地块列表 */}
{fieldDecisions.map((field) => (
0 ? 'text-red-500 dark:text-red-400' : field.generatedCount > 0 ? 'text-blue-500 dark:text-blue-400' : field.executingCount > 0 ? 'text-purple-500 dark:text-purple-400' : 'text-green-500 dark:text-green-400' }`} />
{field.fieldName}
{field.cropType} · {field.area}亩
{field.decisions.length}条决策 {field.urgentCount > 0 && ( {field.urgentCount}紧急 )}
))}
); }