/** * 册10 SC-03 执行记录与轮次详情。 * 契约:docs/.../10-第10册-定时任务与审计视图/14-页面契约本册逐页.md §14.2、作业§4.4/§4.5。 * 接线现状:`/jobs/runs@v1` [实]——五件筛选(关键字/任务/触发方式/结果/日期区间)、 * `page` 0 基翻页、留存期总数 N 与命中数 M 分列下发;标注行返回空流水说明(⛔ 显 0)。 * 关键字当前只检索轮次字段(平台 R-1 `object_keyword` 未交付)⇒ `W22` 常驻。 */ import { useMemo, useState, type ReactNode } from "react"; import { Check, Search, X } from "lucide-react"; import { OpsDialog, OpsStatus, OpsTableColumns } from "../components/OperationsKit"; import { Button } from "../components/ui/button"; import { FilterSelect } from "../components/ui/filter-select"; import { Input } from "../components/ui/input"; import { fmtDateTime, fmtDuration, last7Days, useJobRuns, EMPTY_RUNS_FILTER, type JobListRow, type RunsFilter, } from "../lib/scheduled-jobs"; import { RESULT_WORDS, ROUND_DETAIL_EMPTY, RUNS_EMPTY, TRIGGER_WORDS, W18A, W18B, W18C, W18D, W18E_FROM, W18E_TO, W19, W20, W21_ABNORMAL, W21_LAST7, W21_RESET, W22, W23_DETAIL, W23_GOTO, W27, W28, w16, w17, w26, w29, } from "../lib/copy-jobs"; import type { JobRunRow } from "../lib/api/types"; import { useNavigate } from "react-router"; export interface JobRunsPreset { jobKey: string; jobName: string; } export function JobRunsDialog({ preset, rows, onClose }: { preset: JobRunsPreset; rows: JobListRow[]; onClose: () => void }) { const navigate = useNavigate(); const [filter, setFilter] = useState({ ...EMPTY_RUNS_FILTER, jobKey: preset.jobKey }); const [applied, setApplied] = useState({ ...EMPTY_RUNS_FILTER, jobKey: preset.jobKey }); const [detail, setDetail] = useState(null); const state = useJobRuns(applied); const jobOptions = useMemo(() => rows.filter((row) => !row.annotation), [rows]); const recentDates = last7DaysFilter(); const recentSelected = applied.dateFrom === recentDates.dateFrom && applied.dateTo === recentDates.dateTo; const abnormalSelected = applied.result === "异常"; const apply = (next: RunsFilter) => { setFilter(next); setApplied(next); }; // W16:N 为服务端留存期总数,M 为当前已装载轮次。 const title = w16(state.retentionTotal === null ? "—" : String(state.retentionTotal), state.runs.length); return (

{w17(preset.jobName)}

setFilter({ ...filter, jobKey: event.target.value })}> {jobOptions.map((row) => ( ))} setFilter({ ...filter, trigger: event.target.value })}> {TRIGGER_WORDS.map((word) => ( ))} setFilter({ ...filter, result: event.target.value })}> {RESULT_WORDS.map((word) => ( ))} setFilter({ ...filter, dateFrom: event.target.value })} /> setFilter({ ...filter, dateTo: event.target.value })} />
{/* 平台 R-1(object_keyword 入参)未交付 ⇒ W22 常驻(契约 作业§4.4.6) */}

{W22}

{state.error ? (

{W20}:{state.error}

) : state.annotationMessage ? (
{state.annotationMessage}
) : state.loading && state.runs.length === 0 ? (

正在加载…

) : state.runs.length === 0 ? (
{RUNS_EMPTY}
) : (
{state.runs.map((run) => ( setDetail(run)} onGoto={(page) => { onClose(); navigate(page); }} /> ))}
执行编号 任务 触发 / 执行人 执行时间 对象处理扫描 / 命中 / 成功 / 跳过 / 失败 结果 / 处置 操作
{state.hasMore && (
)}
)}
{detail && setDetail(null)} />}
); } function last7DaysFilter(): Pick { const { from, to } = last7Days(); return { dateFrom: from, dateTo: to }; } function RunCell({ label, children }: { label: string; children: ReactNode }) { return ( {children} ); } function RunText({ children }: { children: string }) { return {children}; } function RunRow({ run, rows, onDetail, onGoto }: { run: JobRunRow; rows: JobListRow[]; onDetail: () => void; onGoto: (page: string) => void }) { const meta = rows.find((row) => row.key === run.job_key); const gotoPage = run.goto_page; const executor = run.trigger === "人工" ? run.actor_user_id ?? "—" : "系统"; const duration = fmtDuration(run.started_at, run.finished_at); const counts = [run.scanned, run.matched, run.succeeded, run.skipped, run.failed].join(" / "); return ( {run.run_id} {run.job_name ?? meta?.displayName ?? run.job_key} {run.job_key} {run.trigger || "—"} {executor} {fmtDateTime(run.started_at)} {run.finished_at && {`完成 ${fmtDateTime(run.finished_at)}`}} {`耗时 ${duration}`} {counts} {run.status} {run.disposition_code !== "none" && run.disposition && {run.disposition}}
{run.disposition_code === "pending_rerun" && run.goto_visible && gotoPage && ( )}
); } /** 轮次弹窗(契约 作业§4.5):计数卡五格+结果说明+对象级明细区。 */ function RoundDialog({ run, rows, onClose }: { run: JobRunRow; rows: JobListRow[]; onClose: () => void }) { const meta = rows.find((row) => row.key === run.job_key); const interrupted = run.scanned === 0 && run.matched === 0 && run.status === "失败"; const detail = run.detail ?? []; const violations = run.violations ?? []; return (

{run.job_name ?? meta?.displayName ?? run.job_key} {interrupted ? W28 : W27}

扫描{run.scanned}
命中{run.matched}
成功{run.succeeded}
跳过{run.skipped}
失败{run.failed}
{run.message &&

{run.message}

} {run.period &&

账期:{run.period}

} {run.biz_date &&

业务日:{run.biz_date}

}

{w29(detail.length)}

{detail.length === 0 ? (

{ROUND_DETAIL_EMPTY}

) : (
{detail.map((item, idx) => ( ))}
对象类型 对象标识 处置 说明
{item.object_type ?? "—"} {item.object_name ?? item.object_id ?? "—"} {item.disposition ?? "—"} {item.reason ?? "—"}
)} {violations.length > 0 && ( <>

跳过/失败原因({violations.length} 条)

    {violations.map((v, idx) => (
  • {v.object_name ?? v.object_id ?? v.object_type ?? "—"} {v.reason ? `:${v.reason}` : ""}
  • ))}
)}
); }