import { memo, useMemo, useState } from "react"; import { ArrowDownToLine, ArrowUpRight, ChevronLeft, ChevronRight, Copy, } from "lucide-react"; import { DIMENSIONS, GROUP_LABELS, type AssistantAction, type AssistantResult, type AssistantRow, type Dimension, type QueryPlan, } from "../../../shared/assets/assistant"; import { fetchAuthenticated } from "../../../auth/api-client"; import { Chart } from "./Chart"; import { copyResultText, displayTime, resultScope, resultDisplay, queryPath, compactAnalysisPath, } from "./result-presentation"; function Records({ rows, flow }: { rows: AssistantRow[]; flow: boolean }) { const [page, setPage] = useState(0), [search, setSearch] = useState(""); const filtered = rows.filter((r) => [r.plate, r.city, r.type, r.model, r.department, r.abnormalType].some((v) => v?.includes(search), ), ); const pages = Math.max(1, Math.ceil(filtered.length / 8)), current = Math.min(page, pages - 1); return ( <>
| {h} | ))}|||||||
|---|---|---|---|---|---|---|---|
| {r.plate || "未登记车牌"} | {r.type} {r.model} | {r.city} | {flow ? r.event : r.status} | {flow ? ({r.date} | ) : ( <>{r.abnormal ? "异动" : r.pending ? "待交车" : "—"} | {r.abnormalType || "—"} | {r.targetCompletionTime || "—"} | > )}
没有符合条件的明细
}此搜索仅筛选当前明细表;继续追问仍使用上方分析条件。
)} > ); } export type ResultViewProps = { result: AssistantResult; ask: (text: string) => void; operate: (action: AssistantAction, label: string) => void; restore: (resultId: string) => void; active: boolean; activate: () => void; subject: string | null; disabled: boolean; correctionMessage?: string; correctionResultId?: string; showCorrection: (resultId: string) => void; display?: "metrics" | "chart" | "table" | "list"; }; function ResultViewContent({ result, ask, operate, restore, active, activate, subject, disabled, correctionMessage, correctionResultId, showCorrection, display: preferredDisplay, }: ResultViewProps) { const [expandedGroupResult, setExpandedGroupResult] = useState{correctionMessage}
{correctionResultId && ( )}{result.correction.message}
{outcomeLabels[result.outcome]}
)}{result.summary}
{!result.conciseCount && !!visibleMetrics.length && ({item.question} {item.reason}
))}{result.gap.recorded ? "这个需求已记下。" : "可以点击下方「未解决我的问题」记录需求。"}
)} {plan.kind !== "clarify" && !result.conciseCount && ( <>{result.inventoryBreakdown.summary}
{briefing && !!result.insights?.length && (当前分组对比 · 数量最多的分组为基准: {result.groupComparison.baseline}
| {h} | ))}||||
|---|---|---|---|---|
| {r.name} | {r.count} | {r.delta} | {r.share}% | {r.rateDelta} |
上一等长周期:{result.comparisonPeriod?.start} —{" "} {result.comparisonPeriod?.end}
| {h} | ), )}||||
|---|---|---|---|---|
| {m.label} | {m.current} | {m.previous} | {m.delta > 0 ? "+" : ""} {m.delta} | {m.rate === null ? "基期为0,不计算" : `${m.rate}%`} |
| {h} | ))}||||
|---|---|---|---|---|
| {d.date} | {d.delivered} | {d.returned} | {d.replaced} |
点击分组继续下钻 · 筛选条件自动用于下一次追问
| {h} | ))}||||||
|---|---|---|---|---|---|---|
| {g.name} | {g.count} | {g.share}% | {result.plan.category !== "operating" && <>{g.rate}% | {g.abnormal} | {g.pending} | >}
当前条件没有匹配数据,可返回上层调整。
)} > )}公司:{scope.company} · 权限:{scope.permission}
生效条件:{scope.filters.join(" · ") || "无额外筛选"}
分组:{scope.grouping} · 期间:{scope.period}
源数据更新时间:{displayTime(scope.sourceUpdatedAt)} · 查询时间: {displayTime(result.fetchedAt)}
{result.contextNote &&{result.contextNote}
} {result.warning &&{result.warning}
} {scope.definitions.map((definition) => ({definition}
))}来源:{result.source}
{notice}
)}