新增模块
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
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<ReviewRecord[]>([]);
|
||||
const [selected, setSelected] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setRecords(listReviewRecords());
|
||||
setSelected(null);
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
if (!open) return null;
|
||||
const detail = selected ? getReviewRecord(selected) : null;
|
||||
|
||||
return (
|
||||
<div className="hist-mask" role="dialog" aria-label="评审历史">
|
||||
<div className="hist">
|
||||
<div className="hist-head">
|
||||
<span>{detail ? "执行详情" : "评审历史"}</span>
|
||||
<button
|
||||
type="button"
|
||||
className="icon-btn"
|
||||
onClick={detail ? () => setSelected(null) : onClose}
|
||||
aria-label={detail ? "返回列表" : "关闭"}
|
||||
>
|
||||
{detail ? "←" : "✕"}
|
||||
</button>
|
||||
</div>
|
||||
<div className="hist-body">
|
||||
{detail ? (
|
||||
<>
|
||||
<dl className="kv-grid">
|
||||
<dt>记录编号</dt><dd>{detail.id}</dd>
|
||||
<dt>发起人</dt><dd>{detail.operator.name} · {detail.operator.code}</dd>
|
||||
<dt>开始时间</dt><dd>{fmt(detail.startedAt)}</dd>
|
||||
<dt>结束时间</dt><dd>{fmt(detail.finishedAt)}</dd>
|
||||
<dt>来源文档</dt><dd>{detail.fileName}</dd>
|
||||
<dt>需求</dt><dd>{detail.productType} {detail.quantity} 个 @ {detail.unitPrice} 元</dd>
|
||||
<dt>可行性判定</dt><dd>{detail.feasibilityCategory}</dd>
|
||||
<dt>评级记分</dt><dd>{detail.ratingTotal} 分</dd>
|
||||
<dt>整体结论</dt><dd>{detail.overall}</dd>
|
||||
<dt>订单 / 授信</dt><dd>{detail.orderNo ?? (detail.creditStarted ? "已发起临时授信" : "—")}</dd>
|
||||
</dl>
|
||||
<div className="todo-actions">
|
||||
<button type="button" className="btn btn-primary" onClick={() => openReportHtml(detail.reportHtml)}>
|
||||
打开当次评估报告
|
||||
</button>
|
||||
</div>
|
||||
<h3 className="hist-sub">执行轨迹</h3>
|
||||
<ol className="trace">
|
||||
{detail.trace.map((t, i) => (
|
||||
<li key={i}>
|
||||
<div className="trace-head">
|
||||
<span className="trace-time">{t.time}</span>
|
||||
<span className="trace-agent">{t.agent}</span>
|
||||
<strong>{t.title}</strong>
|
||||
</div>
|
||||
{t.note ? <p className="trace-note">{t.note}</p> : null}
|
||||
{t.rows?.length ? <EvidenceTable rows={t.rows} /> : null}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</>
|
||||
) : records.length === 0 ? (
|
||||
<p className="chat-empty">暂无评审记录。上传需求文档发起评审后,完成的评审会自动归档在此。</p>
|
||||
) : (
|
||||
<table className="hist-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>记录编号</th>
|
||||
<th>发起时间</th>
|
||||
<th>发起人</th>
|
||||
<th>需求</th>
|
||||
<th>结论</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{records.map((r) => (
|
||||
<tr key={r.id}>
|
||||
<td>{r.id}</td>
|
||||
<td>{fmt(r.startedAt)}</td>
|
||||
<td>{r.operator.name}</td>
|
||||
<td>{r.productType} {r.quantity} 个</td>
|
||||
<td>
|
||||
<span className={`badge ${r.orderNo ? "badge-ok" : "badge-fail"}`}>{r.overall}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" className="btn" onClick={() => setSelected(r.id)}>
|
||||
查看
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user