import { useEffect, useState } from "react"; import type { ReviewRecord } from "../state/history"; import { getReviewRecord, listReviewRecords } from "../state/history"; import { EvidenceTable } from "./EvidenceTable"; /** 评审历史:已完成评审的清单与当次执行轨迹回看 */ function fmt(iso: string): string { return new Date(iso).toLocaleString("zh-CN", { hour12: false }); } function openReportHtml(html: string): void { const url = URL.createObjectURL(new Blob([html], { type: "text/html;charset=utf-8" })); window.open(url, "_blank"); setTimeout(() => URL.revokeObjectURL(url), 60_000); } export function HistoryPanel({ open, onClose }: { open: boolean; onClose: () => void }) { const [records, setRecords] = useState([]); const [selected, setSelected] = useState(null); useEffect(() => { if (open) { setRecords(listReviewRecords()); setSelected(null); } }, [open]); if (!open) return null; const detail = selected ? getReviewRecord(selected) : null; return (
{detail ? "执行详情" : "评审历史"}
{detail ? ( <>
记录编号
{detail.id}
发起人
{detail.operator.name} · {detail.operator.code}
开始时间
{fmt(detail.startedAt)}
结束时间
{fmt(detail.finishedAt)}
来源文档
{detail.fileName}
需求
{detail.productType} {detail.quantity} 个 @ {detail.unitPrice} 元
可行性判定
{detail.feasibilityCategory}
评级记分
{detail.ratingTotal} 分
整体结论
{detail.overall}
订单 / 授信
{detail.orderNo ?? (detail.creditStarted ? "已发起临时授信" : "—")}

执行轨迹

    {detail.trace.map((t, i) => (
  1. {t.time} {t.agent} {t.title}
    {t.note ?

    {t.note}

    : null} {t.rows?.length ? : null}
  2. ))}
) : records.length === 0 ? (

暂无评审记录。上传需求文档发起评审后,完成的评审会自动归档在此。

) : ( {records.map((r) => ( ))}
记录编号 发起时间 发起人 需求 结论
{r.id} {fmt(r.startedAt)} {r.operator.name} {r.productType} {r.quantity} 个 {r.overall}
)}
); }