فهرست منبع

feat(web): 重设计对账清单及人工补跑对话框

sy 2 روز پیش
والد
کامیت
84ecc96116

+ 172 - 126
web-scaffold/src/pages/SettlementRecordPages.tsx

@@ -8,22 +8,23 @@
  * 「分成方式与取值」列走 ../lib/settle-text 单源(册 4 settle_text,⛔ 本册自造分成取值文案)。
  * 禁项:⛔「按金额分成本期不计算」「未对账」「已打回」字样;⛔ 出账状态与批次状态混列;⛔ history.back()。
  */
-import { useEffect, useState, type FormEvent } from "react";
+import { useEffect, useId, useState, type FormEvent } from "react";
 import { PageIntro } from "../components/PageIntro";
-import { ArrowLeft, ArrowRight, Download, FileSpreadsheet, Search, X } from "lucide-react";
+import { ArrowLeft, ArrowRight, CalendarClock, ChevronDown, Download, FileSpreadsheet, RefreshCw, Search, TriangleAlert, X } from "lucide-react";
 import { Link, useLocation, useNavigate, useParams, useSearchParams } from "react-router";
 import { Button } from "../components/ui/button";
 import { SearchInput } from "../components/ui/search-input";
 import { FilterSelect } from "../components/ui/filter-select";
 import { MonthFilter } from "../components/ui/month-filter";
 import { ServerListPager } from "../components/ListPager";
-import { OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty, OpsTag, type OpsTone } from "../components/OperationsKit";
+import { OpsDialog, OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty, OpsTag, type OpsTone } from "../components/OperationsKit";
 import { useDemoIdentity } from "../lib/demo-session";
 import { entTeamGetList, operatorGetList, partnerGetList, reconExportDetail, reconExportList } from "../lib/api/bos";
 import type { HolderType, ReconBatchStatus, ReconcileStatus, ReconDetailResult } from "../lib/api/types";
 import type { StatusTone } from "../domain/statuses";
 import { WORD_FETCH_FAILED } from "../lib/api/lockedCopy";
 import { settleTextFromSnapshot } from "../lib/settle-text";
+import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
 import {
   lastClosedMonth, submitReconRerun,
   useBillDetail, useBillList, useReconDetail, useReconList, useReconPeriods,
@@ -112,9 +113,10 @@ function useListFilters() {
   const [params, setParams] = useSearchParams();
   const has = (key: string) => params.has(key);
   const get = (key: string) => params.get(key) ?? "";
-  const set = (key: string, value: string) =>
+  const set = (key: string, value: string, resetPage = false) =>
     setParams((current) => {
       const next = new URLSearchParams(current);
+      if (resetPage) next.delete("page");
       if (value) next.set(key, value);
       else next.delete(key);
       return next;
@@ -126,7 +128,7 @@ function useListFilters() {
 /** 失败原因行末红点(fail_reason 原文悬浮;⚠️ 不是 KLT-* 码,对账§7.1 末格)。 */
 function FailDot({ reason }: { reason: string | null }) {
   if (!reason) return null;
-  return <span style={{ color: "var(--destructive)", cursor: "help" }} title={reason}> ●</span>;
+  return <span className="statement-failure-mark" title={reason} aria-label={reason}>●</span>;
 }
 
 /* ── 人工补跑对话框(14.1 动作矩阵:仅 admin;入参只三件) ────────── */
@@ -134,13 +136,17 @@ function FailDot({ reason }: { reason: string | null }) {
 function RerunDialog({ onClose }: { onClose: () => void }) {
   const navigate = useNavigate();
   const location = useLocation();
+  const typeId = useId();
+  const holderInputId = useId();
+  const [maxMonth] = useState(lastClosedMonth);
   const [holderType, setHolderType] = useState<HolderType>("operator");
   const [holders, setHolders] = useState<{ id: string; name: string }[] | null>(null);
   const [holdersError, setHoldersError] = useState("");
   const [holderId, setHolderId] = useState("");
-  const [period, setPeriod] = useState(lastClosedMonth());
+  const [period, setPeriod] = useState(maxMonth);
   const [error, setError] = useState("");
   const [busy, setBusy] = useState(false);
+  const [holderRetry, setHolderRetry] = useState(0);
 
   // 分成方候选=第 1 册三类档案真源列表口(⛔ 本地台账);切换类型时重拉。
   useEffect(() => {
@@ -168,10 +174,11 @@ function RerunDialog({ onClose }: { onClose: () => void }) {
     return () => {
       alive = false;
     };
-  }, [holderType]);
+  }, [holderType, holderRetry]);
 
   function submit(event: FormEvent) {
     event.preventDefault();
+    if (busy) return;
     if (!holderId || !period) {
       setError(!holderId ? "请选择分成方。" : "请选择自然月。");
       return;
@@ -181,7 +188,9 @@ function RerunDialog({ onClose }: { onClose: () => void }) {
     submitReconRerun({ holder_type: holderType, holder_id: holderId, period })
       .then((res) => {
         onClose();
-        navigate(batchPath(holderId, res.batch_no), { state: location.state });
+        navigate(batchPath(holderId, res.batch_no), {
+          state: { from: location.pathname, listSearch: location.search },
+        });
       })
       .catch((e: unknown) => {
         // 四道闸(60502→60503→60504→60506)/KLT-S407:文案直读后端 message(出路句由服务端带出)。
@@ -191,51 +200,82 @@ function RerunDialog({ onClose }: { onClose: () => void }) {
   }
 
   // 弹窗须写明补跑对象(分成方名称+月份),⛔ 只回显 ID。
-  const holderName = holders?.find((h) => h.id === holderId)?.name ?? holderId;
+  const holderName = holders?.find((h) => h.id === holderId)?.name;
+  const close = () => { if (!busy) onClose(); };
 
   return (
-    <div className="ops-confirm-backdrop" role="presentation" onMouseDown={onClose}>
-      <div className="ops-confirm" role="dialog" aria-modal="true" aria-labelledby="rerun-dialog-title" onMouseDown={(event) => event.stopPropagation()}>
-        <h2 id="rerun-dialog-title">{RERUN_DIALOG_TITLE}</h2>
-        <form onSubmit={submit}>
-          <p style={{ margin: "12px 0" }}>
-            <FilterSelect icon="type" aria-label="分成方类型" value={holderType} onChange={(event) => { setHolderType(event.target.value as HolderType); }}>
-              <option value="operator">{HOLDER_TYPE_TEXT.operator}</option>
-              <option value="partner">{HOLDER_TYPE_TEXT.partner}</option>
-              <option value="ops_team">{HOLDER_TYPE_TEXT.ops_team}</option>
-            </FilterSelect>{" "}
-            {holders ? (
-              <FilterSelect icon="operator" aria-label="分成方" value={holderId} onChange={(event) => setHolderId(event.target.value)}>
-                {holders.map((h) => <option key={h.id} value={h.id}>{h.name}</option>)}
-                {!holders.length && <option value="">(无可选分成方)</option>}
+    <OpsDialog title={RERUN_DIALOG_TITLE} className="statement-run-dialog" onClose={close}>
+      <form onSubmit={submit}>
+        <div className="statement-run-body">
+          <fieldset className="statement-run-fields" aria-label="补跑条件" disabled={busy}>
+            <div className="statement-run-field">
+              <label htmlFor={typeId}>分成方类型</label>
+              <FilterSelect id={typeId} icon="type" value={holderType} onChange={(event) => {
+                setError("");
+                setHolderType(event.target.value as HolderType);
+              }}>
+                <option value="operator">{HOLDER_TYPE_TEXT.operator}</option>
+                <option value="partner">{HOLDER_TYPE_TEXT.partner}</option>
+                <option value="ops_team">{HOLDER_TYPE_TEXT.ops_team}</option>
               </FilterSelect>
-            ) : (
-              <span>{holdersError || "加载中…"}</span>
-            )}{" "}
-            {/* 月份上界=上一个已结束自然月(对账§8.3 只可对已结束月份补跑);期次必填 ⇒ ⛔「全部自然月」。 */}
-            <MonthFilter value={period} onChange={setPeriod} maxMonth={lastClosedMonth()} allowAll={false} />
-          </p>
-          <p>{rerunScopeLine(holderName, period)}</p>
-          <p>{rerunMonthBoundNote(lastClosedMonth())}</p>
-          <p>{RERUN_NO_EMPTY_BATCH_NOTE}</p>
-          <p>{RERUN_VOID_NOTE}</p>
-          {error && <p className="ops-form-error" role="alert">{error}</p>}
-          <div>
-            <Button variant="outline" type="button" onClick={onClose} disabled={busy}>取消</Button>
-            <Button type="submit" disabled={busy || !holders?.length}>{busy ? "提交中…" : RERUN_SUBMIT}</Button>
+            </div>
+            <div className="statement-run-field">
+              <span>账期</span>
+              <MonthFilter value={period} onChange={(value) => { setPeriod(value); setError(""); }} maxMonth={maxMonth} allowAll={false} />
+            </div>
+            <div className="statement-run-field statement-run-party">
+              <label htmlFor={holderInputId}>分成方</label>
+              <FilterSelect id={holderInputId} icon="operator" value={holderId} placeholder={!holderId} disabled={!holders?.length}
+                onChange={(event) => { setHolderId(event.target.value); setError(""); }}>
+                {!holders?.length && <option value="">{holdersError ? "分成方加载失败" : holders ? "暂无可选分成方" : "正在加载分成方…"}</option>}
+                {holders?.map((h) => <option key={h.id} value={h.id}>{h.name}</option>)}
+              </FilterSelect>
+              {holdersError && <div className="statement-run-load-error">
+                <p role="alert">{holdersError}</p>
+                <Button variant="ghost" size="sm" onClick={() => setHolderRetry((value) => value + 1)}>重试</Button>
+              </div>}
+            </div>
+          </fieldset>
+          <div className="statement-run-scope">
+            <CalendarClock size={19} aria-hidden="true" />
+            <div>
+              <strong>{holderName ? rerunScopeLine(holderName, period) : "选择分成方后即可确认补跑范围"}</strong>
+              <p>{rerunMonthBoundNote(maxMonth)}</p>
+            </div>
           </div>
-        </form>
-      </div>
-    </div>
+          <div className="statement-run-impact">
+            <TriangleAlert size={16} aria-hidden="true" />
+            <div><p>{RERUN_VOID_NOTE}</p><p>{RERUN_NO_EMPTY_BATCH_NOTE}</p></div>
+          </div>
+          {error && <p className="ops-form-error statement-run-error" role="alert">{error}</p>}
+        </div>
+        <footer>
+          <Button variant="outline" type="button" onClick={close} disabled={busy}>取消</Button>
+          <Button type="submit" disabled={busy || !holderId || !period}>{busy ? "正在补跑…" : RERUN_SUBMIT}</Button>
+        </footer>
+      </form>
+    </OpsDialog>
   );
 }
 
 /* ── FN-05 对账清单(14.1) ─────────────────────────────────────── */
 
+const statementColumns = [
+  { label: "对账单号", width: 168 }, { label: "分成方", width: 190 },
+  { label: "自然月", width: 86 }, { label: "应出账日期", width: 108 },
+  { label: "触发方式", width: 92 }, { label: "明细条数", width: 84 },
+  { label: "总金额", width: 112 }, { label: "分成金额", width: 116 },
+  { label: "出账状态", width: 98 }, { label: "批次状态", width: 114 },
+  { label: "执行人", width: 100 }, { label: "操作", width: 80 },
+];
+const statementTableWidth = statementColumns.reduce((sum, column) => sum + column.width, 0);
+
 export function SettlementStatementListPage() {
   const identity = useDemoIdentity();
   const location = useLocation();
   const filters = useListFilters();
+  const tableOverflow = useHorizontalOverflow();
+  const progressId = useId();
   // 导出当前结果(B):admin/opsMain/opsSub(demo 角色无 opsSub);⛔ teamLead/partner/operator。
   const canExportAll = !identity || identity.role === "admin" || identity.role === "regAdmin";
   const isAdmin = !identity || identity.role === "admin";
@@ -252,10 +292,7 @@ export function SettlementStatementListPage() {
   const zero = filters.get("zero") === "1";
   const q = filters.get("q");
   const page = Number(filters.get("page") || "1") || 1;
-  const setMonth = (value: string) => {
-    filters.set("page", "");
-    filters.set("month", value === "" ? "all" : value === defaultMonth ? "" : value);
-  };
+  const setMonth = (value: string) => filters.set("month", value === "" ? "all" : value === defaultMonth ? "" : value, true);
   const hasFilter = Boolean(monthAll || filters.get("month") || type || party || reconcile || status || trigger || zero || q);
 
   const periodsFetch = useReconPeriods();
@@ -283,7 +320,7 @@ export function SettlementStatementListPage() {
       setMonthFallback(false);
       return;
     }
-    filters.set("month", periods[0]);
+    filters.set("month", periods[0], true);
     setMonthFallback(true);
     // eslint-disable-next-line react-hooks/exhaustive-deps
   }, [periods, month, monthAll]);
@@ -309,29 +346,47 @@ export function SettlementStatementListPage() {
   const [notice, setNotice] = useState("");
   const [runOpen, setRunOpen] = useState(false);
   const [progressOpen, setProgressOpen] = useState(false);
+  const [exporting, setExporting] = useState(false);
+  const tableClass = [
+    "measured-table-scroll ops-table-wrap statement-ledger-scroll",
+    tableOverflow.overflow && "has-horizontal-overflow",
+    tableOverflow.width >= 900 && "can-pin-identity",
+    tableOverflow.canScrollLeft && "can-scroll-left",
+    tableOverflow.canScrollRight && "can-scroll-right",
+  ].filter(Boolean).join(" ");
+  const listState = { from: "/settlement-batches", listSearch: location.search };
 
-  function exportAll() {
+  async function exportAll() {
+    if (exporting || list.loading) return;
     // 筛选无结果 ⇒ 只提示、不导出、无错误码(14.1 动作矩阵)。
     if (!rows.length) {
       setNotice(EXPORT_EMPTY_NOTE);
       return;
     }
-    reconExportList({ period: month || undefined, holder_type: type || undefined, status: status || undefined })
-      .then((res) => setNotice(saveReconExportCsv(res) ? exportResultNote(res) : EXPORT_EMPTY_NOTE))
-      .catch((e: unknown) => setNotice(e instanceof Error && e.message ? e.message : WORD_FETCH_FAILED));
+    setExporting(true);
+    try {
+      const result = await reconExportList({ period: month || undefined, holder_type: type || undefined, status: status || undefined });
+      setNotice(saveReconExportCsv(result) ? exportResultNote(result) : EXPORT_EMPTY_NOTE);
+    } catch (e: unknown) {
+      setNotice(e instanceof Error && e.message ? e.message : WORD_FETCH_FAILED);
+    } finally {
+      setExporting(false);
+    }
   }
 
   return (
     <section className="ops-page reconcile-index page-fill page-fill-window">
-      <header className="reconcile-page-heading">
+      <header className="ops-heading statement-heading">
         <div>
-          <p className="ops-eyebrow"><span /> RECONCILIATION / 分成与对账</p>
           <h1>对账清单</h1>
           <PageIntro>每个账期出账后,按分成方核对批次状态和结算结果。</PageIntro>
         </div>
-        <div className="statement-heading-actions">
-          {isAdmin && <Button onClick={() => setRunOpen(true)}>人工补跑</Button>}
-        </div>
+        {(canExportAll || isAdmin) && <div className="statement-heading-actions">
+          {canExportAll && <Button variant="outline" disabled={list.loading || exporting} onClick={exportAll}>
+            <Download size={16} aria-hidden="true" />{exporting ? "正在导出…" : "导出当前结果"}
+          </Button>}
+          {isAdmin && <Button onClick={() => setRunOpen(true)}><RefreshCw size={16} aria-hidden="true" />人工补跑</Button>}
+        </div>}
       </header>
       {runOpen && <RerunDialog onClose={() => setRunOpen(false)} />}
 
@@ -341,53 +396,41 @@ export function SettlementStatementListPage() {
       {monthFallback && !rows.length && <p className="ops-import-note" role="status">{MONTH_NO_BATCH_NOTE}</p>}
 
       {/* ② 三统计卡:与列表同一响应同一行集;S404 ⇒ 整体不渲染(不是显示 0);单格 null ⇒「取数失败」。 */}
-      {!s404 && !wiring && data && (
-        <div className="reconcile-totals" aria-label="当前筛选结果统计">
+      {!s404 && (wiring || data) && (
+        <div className="statement-totals" role="group" aria-label="当前筛选结果统计">
           {STAT_CARDS.map((card) => {
-            const value =
-              card.key === "base" ? data.stats.total_base_cents : card.key === "cost" ? data.stats.total_cost_cents : data.stats.total_share_cents;
+            const value = data?.stats[`total_${card.key}_cents`] ?? null;
             return (
-              <div key={card.key}>
+              <div key={card.key} data-total={card.key}>
                 <span>{card.title}</span>
-                <strong>{moneyCell(value)}</strong>
+                <strong className={wiring || value == null ? "statement-total-empty" : undefined}>{wiring ? BACKEND_NOT_WIRED : moneyCell(value)}</strong>
                 <small>{card.subtitle}</small>
               </div>
             );
           })}
         </div>
       )}
-      {/* 契约占位分支:卡结构落位、值格显式标「后端未下发」(总则§16.9,⛔ 演示例数冒充)。 */}
-      {wiring && (
-        <div className="reconcile-totals" aria-label="当前筛选结果统计">
-          {STAT_CARDS.map((card) => (
-            <div key={card.key}>
-              <span>{card.title}</span>
-              <strong>{BACKEND_NOT_WIRED}</strong>
-              <small>{card.subtitle}</small>
-            </div>
-          ))}
-        </div>
-      )}
-
       {/* ③-1 期次出账进度(常驻;只随自然月变化,⛔ 随其余筛选变;后端未下发 ⇒ 不渲)。 */}
       {data?.progress && (
-        <>
-          <div className="ops-detail-callout" role="status">
-            <strong>{periodProgressLine(data.progress)}</strong>
-            <p>
-              <button type="button" className="ops-table-action" onClick={() => setProgressOpen((v) => !v)}>
-                {progressOpen ? PROGRESS_COLLAPSE : PROGRESS_EXPAND} <ArrowRight size={13} />
-              </button>
-            </p>
+        <section className="statement-progress" aria-label="期次出账进度">
+          <div className="statement-progress-line">
+            <CalendarClock size={18} aria-hidden="true" />
+            <p role="status">{periodProgressLine(data.progress)}</p>
+            <Button variant="ghost" size="sm" aria-expanded={progressOpen} aria-controls={progressId} onClick={() => setProgressOpen((v) => !v)}>
+              {progressOpen ? PROGRESS_COLLAPSE : PROGRESS_EXPAND}<ChevronDown size={14} aria-hidden="true" />
+            </Button>
           </div>
-          {progressOpen && (
-            <div className="ops-table-wrap">
+          <div id={progressId} hidden={!progressOpen} className="ops-table-wrap statement-progress-table">
+            {progressOpen && (
               <table className="ops-table">
                 <thead><tr><th>分成方</th><th>建档区域</th><th>对账日</th><th>本期应出账日期</th><th>状态</th><th>对账单号</th></tr></thead>
                 <tbody>
                   {data.progress.items.map((item) => (
                     <tr key={`${item.holder_type}-${item.holder_id}`}>
-                      <td><OpsTag tone={holderTone[item.holder_type]}>{HOLDER_TYPE_TEXT[item.holder_type]}</OpsTag> {item.holder_name}</td>
+                      <td>
+                        <strong className="table-cell-title" title={item.holder_name}>{item.holder_name}</strong>
+                        <OpsTag tone={holderTone[item.holder_type]}>{HOLDER_TYPE_TEXT[item.holder_type]}</OpsTag>
+                      </td>
                       <td>{item.region_label ?? <span className="table-placeholder">—</span>}</td>
                       <td>{item.recon_day} 日</td>
                       <td>{item.expected_date}</td>
@@ -397,44 +440,45 @@ export function SettlementStatementListPage() {
                   ))}
                 </tbody>
               </table>
-            </div>
-          )}
-        </>
+            )}
+          </div>
+        </section>
       )}
 
       {/* ④ 批次清单 */}
       <div className="reconcile-ledger list-shell-fill">
         {/* ③ 筛选条:自然月(periods 口)/分成方类型/分成方(可搜)/出账状态/批次状态/对账单号关键字/零明细开关/重置筛选。 */}
-        <div className="reconcile-filters">
+        <div className="ops-toolbar reconcile-filters statement-filters" role="group" aria-label="对账清单筛选">
           <label className="ops-search">
-            <Search size={17} />
+            <Search size={17} aria-hidden="true" />
             <SearchInput aria-label="搜索对账单号" placeholder="搜索对账单号" value={q}
-              onCommit={(value) => { filters.set("page", ""); filters.set("q", value); }} />
-            {q && <button type="button" aria-label="清空搜索" onClick={() => filters.set("q", "")}><X size={15} /></button>}
+              onCommit={(value) => filters.set("q", value, true)} />
+            {q && <button type="button" aria-label="清空对账单号" onClick={() => filters.set("q", "", true)}><X size={15} aria-hidden="true" /></button>}
+          </label>
+          <label className="ops-search">
+            <Search size={17} aria-hidden="true" />
+            <SearchInput aria-label="搜索分成方" placeholder="搜索分成方" value={party}
+              onCommit={(value) => filters.set("party", value, true)} />
+            {party && <button type="button" aria-label="清空分成方" onClick={() => filters.set("party", "", true)}><X size={15} aria-hidden="true" /></button>}
           </label>
           <FilterSelect icon="month" aria-label="自然月" value={monthAll ? "" : month} onChange={(event) => setMonth(event.target.value)}>
             <option value="">{ALL_PERIODS_LABEL}</option>
             {(periods ?? (month ? [month] : [])).map((p) => <option key={p} value={p}>{p}</option>)}
           </FilterSelect>
-          <FilterSelect icon="type" aria-label="分成方类型" value={type} onChange={(event) => { filters.set("page", ""); filters.set("type", event.target.value); }}>
+          <FilterSelect icon="type" aria-label="分成方类型" value={type} onChange={(event) => filters.set("type", event.target.value, true)}>
             <option value="">全部类型</option>
             <option value="operator">{HOLDER_TYPE_TEXT.operator}</option>
             <option value="partner">{HOLDER_TYPE_TEXT.partner}</option>
             <option value="ops_team">{HOLDER_TYPE_TEXT.ops_team}</option>
           </FilterSelect>
-          <label className="ops-search">
-            <Search size={17} />
-            <SearchInput aria-label="搜索分成方" placeholder="搜索分成方" value={party}
-              onCommit={(value) => { filters.set("page", ""); filters.set("party", value); }} />
-          </label>
           {/* 出账状态与批次状态是两个独立下拉(⚠️ 合并=缺陷);出账状态⛔ 出现「待执行」「已作废」。 */}
-          <FilterSelect icon="status" aria-label="出账状态" value={reconcile} onChange={(event) => { filters.set("page", ""); filters.set("reconcile", event.target.value); }}>
+          <FilterSelect icon="status" aria-label="出账状态" value={reconcile} onChange={(event) => filters.set("reconcile", event.target.value, true)}>
             <option value="">全部出账状态</option>
             <option value="settled">{RECONCILE_STATUS_TEXT.settled}</option>
             <option value="abnormal">{RECONCILE_STATUS_TEXT.abnormal}</option>
             <option value="unsettled">{RECONCILE_STATUS_TEXT.unsettled}</option>
           </FilterSelect>
-          <FilterSelect icon="action" aria-label="批次状态" value={status} onChange={(event) => { filters.set("page", ""); filters.set("status", event.target.value); }}>
+          <FilterSelect icon="action" aria-label="批次状态" value={status} onChange={(event) => filters.set("status", event.target.value, true)}>
             <option value="">全部批次状态</option>
             <option value="pending">{BATCH_STATUS_TEXT.pending}</option>
             <option value="executed">{BATCH_STATUS_TEXT.executed}</option>
@@ -442,63 +486,65 @@ export function SettlementStatementListPage() {
             <option value="voided">{BATCH_STATUS_TEXT.voided}</option>
           </FilterSelect>
           {/* 触发方式(手册步序:批次状态之后、关键字之前):只两值,⛔ 第三值。 */}
-          <FilterSelect icon="action" aria-label="触发方式" value={trigger} onChange={(event) => { filters.set("page", ""); filters.set("trigger", event.target.value); }}>
+          <FilterSelect icon="action" aria-label="触发方式" value={trigger} onChange={(event) => filters.set("trigger", event.target.value, true)}>
             <option value="">全部触发方式</option>
             {(["manual", "auto"] as const).map((key) => <option key={key} value={key}>{TRIGGER_TYPE_TEXT[key]}</option>)}
           </FilterSelect>
-          <Button variant={zero ? "default" : "outline"} size="sm" aria-pressed={zero}
-            onClick={() => { filters.set("page", ""); filters.set("zero", zero ? "" : "1"); }}>零明细批次</Button>
-          {hasFilter && <Button variant="ghost" size="sm" onClick={() => { filters.reset(); setMonthFallback(false); }}>重置筛选</Button>}
-          {canExportAll && <Button variant="outline" size="sm" onClick={exportAll}><Download size={16} />导出当前结果</Button>}
+          <Button variant="outline" className="statement-zero-filter" aria-pressed={zero}
+            onClick={() => filters.set("zero", zero ? "" : "1", true)}>零明细批次</Button>
+          {hasFilter && <Button variant="ghost" onClick={() => { filters.reset(); setMonthFallback(false); }}>重置筛选</Button>}
         </div>
 
         {/* S404 触顶 ⇒ 不渲染三卡与列表(⚠️ 禁止静默截断)。 */}
-        {s404 ? (
-          <p className="ops-import-note" role="alert">{S404_EMPTY_NOTE}</p>
-        ) : (
-          <div className="ops-table-wrap">
-            <table className="ops-table reconcile-table">
-              <OpsTableColumns widths={[150, 190, 90, 100, 90, 80, 110, 110, 96, 96, 90, 76]} />
+        <div className={tableClass} ref={tableOverflow.ref} role="region" aria-label="对账批次,可横向滚动查看字段" tabIndex={0}>
+          {s404 ? <p className="ops-import-note" role="alert">{S404_EMPTY_NOTE}</p> : (
+            <table className="ops-table statement-ledger" style={{ minWidth: statementTableWidth }}>
+              <OpsTableColumns widths={statementColumns.map(({ width }) => width)} />
               <thead>
-                <tr><th>对账单号</th><th>分成方</th><th>自然月</th><th>应出账日期</th><th>触发方式</th><th>明细条数</th><th>总金额</th><th>分成金额</th><th>出账状态</th><th>批次状态</th><th>执行人</th><th>操作</th></tr>
+                <tr>{statementColumns.map(({ label }) => <th key={label} scope="col">{label}</th>)}</tr>
               </thead>
               <tbody>
                 {rows.map((row) => (
                   <tr key={row.batch_no}>
                     <td>
-                      <Link className="reconcile-row-link" title={row.batch_no} to={batchPath(row.holder_id, row.batch_no)}
-                        state={{ from: "/settlement-batches", listSearch: location.search }}>
-                        {row.batch_no}<ArrowRight size={14} />
+                      <Link className="table-cell-title statement-number-link" title={row.batch_no}
+                        to={batchPath(row.holder_id, row.batch_no)} state={listState}>
+                        {row.batch_no}
                       </Link>
                     </td>
-                    <td><OpsTag tone={holderTone[row.holder_type]}>{HOLDER_TYPE_TEXT[row.holder_type]}</OpsTag> <strong title={row.holder_name}>{row.holder_name}</strong></td>
+                    <td><strong className="table-cell-title" title={row.holder_name}>{row.holder_name}</strong>
+                      <div className="statement-holder-type"><OpsTag tone={holderTone[row.holder_type]}>{HOLDER_TYPE_TEXT[row.holder_type]}</OpsTag></div>
+                    </td>
                     <td><span className="ops-mono">{row.period}</span></td>
                     <td>{row.recon_date}</td>
                     <td><OpsTag tone={row.trigger_type === "manual" ? "warning" : "neutral"}>{TRIGGER_TYPE_TEXT[row.trigger_type]}</OpsTag></td>
-                    <td className="table-number">{row.detail_count} 条</td>
-                    <td><span className="ops-money">{moneyFromCents(row.base_cents)}</span></td>
-                    <td><strong className="reconcile-money">{moneyFromCents(row.share_cents)}</strong></td>
+                    <td><span className="table-number">{row.detail_count}</span><span className="statement-unit"> 条</span></td>
+                    <td><span className="table-number" title={moneyFromCents(row.base_cents)}>{moneyFromCents(row.base_cents)}</span></td>
+                    <td><span className="table-number statement-share" title={moneyFromCents(row.share_cents)}>{moneyFromCents(row.share_cents)}</span></td>
                     <td><OpsStatus tone={reconcileTone[row.reconcile_status]}>{RECONCILE_STATUS_TEXT[row.reconcile_status]}</OpsStatus></td>
                     <td>
-                      <OpsStatus tone={batchTone[row.status]}>{BATCH_STATUS_TEXT[row.status]}</OpsStatus>
-                      {row.status === "failed" && <FailDot reason={row.fail_reason} />}
+                      <div className="statement-batch-status">
+                        <OpsStatus tone={batchTone[row.status]}>{BATCH_STATUS_TEXT[row.status]}</OpsStatus>
+                        {row.status === "failed" && <FailDot reason={row.fail_reason} />}
+                      </div>
                     </td>
-                    <td title={row.operator_user_id ?? undefined}>{executorText(row)}</td>
+                    <td title={executorText(row)}>{executorText(row)}</td>
                     <td>
-                      <Link className="ops-table-action" to={batchPath(row.holder_id, row.batch_no)}
-                        state={{ from: "/settlement-batches", listSearch: location.search }}>详情</Link>
+                      <Link className="ops-table-action" to={batchPath(row.holder_id, row.batch_no)} state={listState}>
+                        详情<ArrowRight size={14} aria-hidden="true" />
+                      </Link>
                     </td>
                   </tr>
                 ))}
                 {!rows.length && (
-                  <OpsTableEmpty colSpan={12}>
+                  <OpsTableEmpty colSpan={statementColumns.length}>
                     {list.loading ? "加载中…" : wiring ? "对账接口待后端接线,批次数据暂不可读。" : "没有符合筛选条件的对账清单。"}
                   </OpsTableEmpty>
                 )}
               </tbody>
             </table>
-          </div>
-        )}
+          )}
+        </div>
         {!s404 && (
           <ServerListPager
             total={total}

+ 111 - 0
web-scaffold/src/pages/__tests__/settlement-statement-list.test.tsx

@@ -0,0 +1,111 @@
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import { MemoryRouter, Route, Routes, useLocation } from "react-router";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { reconExportList, reconGetList, reconRerun } from "../../lib/api/bos";
+import { SettlementStatementListPage } from "../SettlementRecordPages";
+
+vi.mock("../../lib/recon", async (load) => ({
+  ...await load<typeof import("../../lib/recon")>(),
+  lastClosedMonth: () => "2026-10",
+}));
+vi.mock("../../lib/demo-session", async (load) => ({
+  ...await load<typeof import("../../lib/demo-session")>(),
+  useDemoIdentity: () => ({ role: "admin" }),
+}));
+vi.mock("../../lib/api/bos", async (load) => ({
+  ...await load<typeof import("../../lib/api/bos")>(),
+  reconGetPeriods: vi.fn(async () => ({ periods: ["2026-10", "2026-09"] })),
+  reconGetList: vi.fn(async () => ({
+    total: 25,
+    stats: { total_base_cents: 120000, total_cost_cents: null, total_share_cents: 19000 },
+    items: [{
+      batch_no: "RECON-001", holder_type: "operator", holder_id: "OP-1", holder_name: "华东运营商",
+      period: "2026-10", recon_date: "2026-11-05", trigger_type: "manual", detail_count: 3,
+      base_cents: 120000, share_cents: 19000, reconcile_status: "abnormal", status: "failed",
+      fail_reason: "示例失败原因", operator_user_id: null,
+    }],
+    progress: {
+      period: "2026-10", expected: 1, generated: 0, not_due: 0, overdue: 1,
+      items: [{ holder_type: "operator", holder_id: "OP-1", holder_name: "华东运营商",
+        region_label: "上海市", recon_day: 5, expected_date: "2026-11-05", status: "未出账", batch_no: null }],
+    },
+  })),
+  reconExportList: vi.fn(async () => ({ rows: [] })),
+  operatorGetList: vi.fn(async () => ({ items: [{ operator_id: "OP-1", name: "华东运营商" }] })),
+  partnerGetList: vi.fn(async () => ({ items: [{ partner_id: "PARTNER-1", name: "渠道伙伴" }] })),
+  reconRerun: vi.fn(async () => ({ batch_no: "RECON-002" })),
+}));
+
+const dialogPrototype = HTMLDialogElement.prototype;
+const { showModal, close } = dialogPrototype;
+beforeEach(() => {
+  vi.clearAllMocks();
+  vi.stubGlobal("ResizeObserver", class {
+    observe() {}
+    disconnect() {}
+  });
+  Object.assign(dialogPrototype, {
+    showModal(this: HTMLDialogElement) { this.open = true; },
+    close(this: HTMLDialogElement) { this.open = false; },
+  });
+});
+afterEach(() => {
+  cleanup();
+  vi.unstubAllGlobals();
+  Object.assign(dialogPrototype, { showModal, close });
+});
+
+function Destination() {
+  const { pathname, state } = useLocation();
+  return <output aria-label="补跑详情">{pathname} {state.listSearch}</output>;
+}
+
+function renderPage(search = "") {
+  return render(<MemoryRouter initialEntries={[`/settlement-batches${search}`]}>
+    <Routes>
+      <Route path="/settlement-batches" element={<SettlementStatementListPage />} />
+      <Route path="/settlement-batches/:holder/:batch" element={<Destination />} />
+    </Routes>
+  </MemoryRouter>);
+}
+
+it("从页头导出,表格分开展示两种状态,改筛选时返回第一页", async () => {
+  renderPage("?page=2&type=operator");
+  const table = within(screen.getByRole("region", { name: "对账批次,可横向滚动查看字段" }));
+  expect(await table.findByRole("link", { name: "RECON-001" })).toBeTruthy();
+  expect(table.getByRole("columnheader", { name: "出账状态" })).toBeTruthy();
+  expect(table.getByRole("columnheader", { name: "批次状态" })).toBeTruthy();
+  expect(table.getByText("出账异常")).toBeTruthy();
+  expect(table.getByText("执行失败")).toBeTruthy();
+  expect(table.getByTitle("示例失败原因")).toBeTruthy();
+  expect(screen.getByRole("group", { name: "当前筛选结果统计" }).textContent).toContain("取数失败");
+  const banner = within(screen.getByRole("banner"));
+  const [exportButton, rerunButton] = banner.getAllByRole("button");
+  expect(exportButton.textContent).toBe("导出当前结果");
+  expect(rerunButton.textContent).toBe("人工补跑");
+  fireEvent.click(exportButton);
+  await waitFor(() => expect(reconExportList).toHaveBeenCalledWith({ period: "2026-10", holder_type: "operator", status: undefined }));
+
+  fireEvent.change(screen.getByRole("combobox", { name: "批次状态" }), { target: { value: "failed" } });
+  await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({
+    page: 0, holder_type: "operator", status: "failed",
+  })));
+  fireEvent.click(screen.getByRole("button", { name: "展开各分成方明细" }));
+  expect(within(screen.getByRole("region", { name: "期次出账进度" })).getByText("上海市")).toBeTruthy();
+});
+
+it("补跑对话框预览选择的分成方和账期,完成后进入新批次并保留来路", async () => {
+  renderPage("?type=operator");
+  fireEvent.click(screen.getByRole("button", { name: "人工补跑" }));
+  const dialog = within(screen.getByRole("dialog", { name: "确认人工补跑" }));
+  expect(await dialog.findByText("补跑对象:华东运营商 · 2026-10。")).toBeTruthy();
+  fireEvent.change(dialog.getByRole("combobox", { name: "分成方类型" }), { target: { value: "partner" } });
+  expect(await dialog.findByText("补跑对象:渠道伙伴 · 2026-10。")).toBeTruthy();
+  const submit = dialog.getByRole("button", { name: "确认补跑" });
+  expect(submit.closest("footer")).toBeTruthy();
+  fireEvent.click(submit);
+  await waitFor(() => expect(reconRerun).toHaveBeenCalledWith({
+    holder_type: "partner", holder_id: "PARTNER-1", period: "2026-10",
+  }));
+  expect((await screen.findByLabelText("补跑详情")).textContent).toBe("/settlement-batches/PARTNER-1/RECON-002 ?type=operator");
+});

+ 109 - 16
web-scaffold/src/styles/settlement-records.css

@@ -9,12 +9,89 @@
 .reconcile-heading-aside { display: flex; flex: none; align-items: baseline; gap: 8px; color: var(--primary); }
 .reconcile-heading-aside strong { font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
 .reconcile-heading-aside span { color: var(--text-secondary); font-size: var(--type-support); }
-.statement-heading-actions { display:flex; flex:none; align-items:center; gap:16px; }
-.statement-heading-actions > button { white-space:nowrap; }
-.statement-run-dialog { inset:0; margin:auto; width:min(480px, calc(100vw - 32px)); color:var(--foreground); }
-.statement-run-dialog::backdrop { background:var(--overlay); }
-.statement-run-dialog .ops-form-grid { grid-template-columns:minmax(0, 1fr); }
-.statement-run-dialog footer { display:flex; justify-content:flex-end; gap:8px; margin-top:20px; }
+.statement-heading { margin-bottom: 0; }
+.statement-heading > div:first-child { min-width: 0; }
+.statement-heading-actions { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 8px; }
+.statement-totals {
+  display: grid;
+  grid-template-columns: repeat(3, minmax(0, 1fr));
+  overflow: hidden;
+  border: 1px solid var(--border);
+  border-radius: var(--radius-card);
+  background: var(--card);
+  box-shadow: var(--shadow-card);
+}
+.statement-totals > div { display: grid; align-content: start; gap: 5px; min-width: 0; padding: 14px 18px; }
+.statement-totals > div + div { border-inline-start: 1px solid var(--border-subtle); }
+.statement-totals > [data-total="share"] { background: var(--primary-soft); }
+.statement-totals span { color: var(--text-secondary); font-size: var(--type-support); font-weight: 500; }
+.statement-totals strong { color: var(--foreground); font-size: clamp(20px, 1.65vw, 25px); line-height: 1.25; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
+.statement-totals > [data-total="share"] strong { color: var(--primary-soft-foreground); }
+.statement-totals .statement-total-empty { font-size: var(--type-body); font-weight: 500; }
+.statement-totals small { color: var(--muted-foreground); font-size: var(--type-meta); line-height: 1.5; }
+
+.statement-progress { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--card); }
+.statement-progress-line { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; padding: 8px 16px; }
+.statement-progress-line > svg { flex: none; color: var(--primary); }
+.statement-progress-line p { flex: 1 1 250px; min-width: 0; color: var(--text-secondary); font-size: var(--type-support); line-height: 1.5; overflow-wrap: anywhere; }
+.statement-progress-line button { margin-inline-start: auto; color: var(--primary); }
+.statement-progress-line button[aria-expanded="true"] svg { transform: rotate(180deg); }
+.statement-progress-table { max-height: 260px; overflow: auto; border-top: 1px solid var(--border-subtle); }
+.statement-progress-table table { min-width: 740px; }
+.statement-progress-table th { position: sticky; top: 0; z-index: 1; }
+.statement-progress-table td .table-cell-title { margin-bottom: 4px; }
+
+.ops-dialog.statement-run-dialog {
+  position: fixed;
+  inset: 0;
+  width: min(620px, calc(100vw - 24px));
+  max-height: calc(100dvh - 24px);
+  overflow: hidden;
+}
+.statement-run-dialog[open], .statement-run-dialog > form { display: flex; flex-direction: column; }
+.statement-run-dialog > header, .statement-run-dialog footer { flex: none; }
+.ops-dialog.statement-run-dialog > form { min-height: 0; padding: 0; }
+.statement-run-body { display: grid; gap: 16px; min-height: 0; padding: 18px 24px; overflow: auto; overscroll-behavior: contain; }
+.statement-run-fields {
+  display: grid;
+  grid-template-columns: repeat(2, minmax(0, 1fr));
+  gap: 13px 14px;
+  min-width: 0;
+  padding: 0;
+  border: 0;
+}
+.statement-run-party { grid-column: 1 / -1; }
+.statement-run-field { display: grid; gap: 5px; min-width: 0; }
+.statement-run-field > :is(label:not(.filter-select), span) { color: var(--field-label); font-size: var(--type-body); }
+.statement-run-field > .filter-select { inline-size: 100%; max-width: 100%; }
+.statement-run-field > .month-filter-trigger:disabled { cursor: not-allowed; opacity: .55; }
+.statement-run-load-error { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; color: var(--destructive); font-size: var(--type-meta); }
+.statement-run-load-error p { padding-block: 6px; overflow-wrap: anywhere; }
+.statement-run-scope, .statement-run-impact {
+  display: flex;
+  align-items: flex-start;
+  gap: 9px;
+  padding: 11px 13px;
+  border-radius: var(--radius-control);
+  font-size: var(--type-support);
+  line-height: 1.55;
+}
+.statement-run-scope { background: var(--surface-subtle); color: var(--text-secondary); }
+.statement-run-scope strong { color: var(--foreground); font-weight: 600; overflow-wrap: anywhere; }
+.statement-run-scope p { margin-top: 3px; color: var(--muted-foreground); font-size: var(--type-meta); }
+.statement-run-impact { border: 1px solid var(--warning-border); background: var(--warning-soft); color: var(--text-secondary); }
+.statement-run-impact p + p { margin-top: 2px; }
+.statement-run-scope > svg, .statement-run-impact > svg { flex: none; margin-top: 2px; color: var(--primary); }
+.statement-run-impact > svg { color: var(--warning); }
+.statement-run-body .statement-run-error { margin: 0; overflow-wrap: anywhere; }
+.statement-run-dialog footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--border-subtle); background: var(--card); }
+@media (max-width: 599px) {
+  .statement-totals { grid-template-columns: minmax(0, 1fr); }
+  .statement-totals > div { padding: 11px 15px; }
+  .statement-totals > div + div { border-inline-start: 0; border-top: 1px solid var(--border-subtle); }
+  .statement-progress-line { padding-inline: 13px; }
+  .statement-run-dialog :is(.statement-run-body, footer) { padding-inline: 14px; }
+}
 .reconcile-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
 .reconcile-totals > div,.bill-index-summary > div { display: grid; align-content: start; gap: 5px; min-width: 0; padding: 16px 19px; border: 1px solid var(--border); border-radius: 9px; background: var(--card); }
 .reconcile-totals > div:nth-child(2) { border-color: var(--primary-border); background: var(--primary-soft); }
@@ -87,20 +164,36 @@
 @media (max-width: 430px) { .reconcile-record-stats,.bill-index-summary,.reconcile-record-facts { grid-template-columns: 1fr; } }
 
 /* 对账清单:金额列按需伸缩,固定编号及唯一详情入口。 */
-.statement-ledger-scroll{position:relative;overflow-x:auto;overflow-y:hidden;scrollbar-gutter:stable;overscroll-behavior-x:contain}
+.reconcile-index > .reconcile-ledger > .statement-filters{gap:8px;margin:0;border-bottom:1px solid var(--border-subtle)}
+.reconcile-index > .reconcile-ledger > .statement-ledger-scroll{margin:0;border:0;border-radius:0}
+.statement-filters .ops-search{flex:0 1 188px;min-width:min(152px,100%)}
+.statement-zero-filter[aria-pressed="true"]{border-color:var(--primary-border);background:var(--primary-soft);color:var(--primary-soft-foreground)}
+.statement-ledger-scroll{position:relative;overflow:auto;overscroll-behavior-x:contain}
 .statement-ledger-scroll:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}
-.ops-table.statement-ledger{min-width:1500px;table-layout:fixed;border-collapse:separate;border-spacing:0}
+.ops-table.statement-ledger{table-layout:fixed;border-collapse:separate;border-spacing:0}
+.statement-ledger th{position:sticky;top:0;z-index:2;border-top:0}
 .statement-ledger td{background:var(--card)}
 .statement-ledger :is(th,td){width:auto}
-.statement-ledger td:not(:last-child),.statement-ledger td strong,.statement-ledger td small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;overflow-wrap:normal}
+.statement-ledger :is(td:not(:last-child),.table-cell-title){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;overflow-wrap:normal}
 .statement-ledger tbody tr:is(:hover,:focus-within) td{background:var(--surface-subtle)}
-.statement-ledger :is(th,td):is(:nth-child(4),:nth-child(5),:nth-child(10),:last-child){text-align:right;font-variant-numeric:tabular-nums}
-.statement-ledger .reconcile-row-link{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
-.statement-ledger .reconcile-row-link>svg{display:none}
-.statement-ledger-scroll.has-horizontal-overflow.can-pin-identity .statement-ledger :is(th,td):first-child:where(:not([colspan])){position:sticky;left:0;z-index:2}
-.statement-ledger-scroll.has-horizontal-overflow .statement-ledger :is(th,td):last-child:where(:not([colspan])){position:sticky;right:0;z-index:2}
-.statement-ledger-scroll.can-scroll-left.can-pin-identity .statement-ledger :is(th,td):first-child:where(:not([colspan])){box-shadow:9px 0 12px -10px rgb(24 40 48 / 35%);border-right:1px solid var(--border-subtle)}
-.statement-ledger-scroll.can-scroll-right .statement-ledger :is(th,td):last-child:where(:not([colspan])){box-shadow:-9px 0 12px -10px rgb(24 40 48 / 35%);border-left:1px solid var(--border-subtle)}
+.statement-ledger :is(th,td):is(:nth-child(n+6):nth-child(-n+8),:last-child):not([colspan]){text-align:right;font-variant-numeric:tabular-nums}
+.statement-ledger :is(th,td):last-child:not([colspan]){padding-inline:10px 16px}
+.statement-ledger .table-cell-title,.statement-progress-table .table-cell-title{display:block}
+.statement-ledger .statement-number-link:hover{color:var(--primary);text-decoration:underline}
+.statement-holder-type{margin-top:4px}
+.statement-ledger .statement-unit{color:var(--muted-foreground);font-size:var(--type-meta)}
+.statement-ledger td .statement-share{color:var(--primary);font-weight:600}
+.statement-batch-status{display:flex;align-items:center;gap:5px}
+.statement-failure-mark{color:var(--destructive);font-size:9px;cursor:help}
+.statement-ledger-scroll.has-horizontal-overflow.can-pin-identity .statement-ledger :is(th,td):first-child:not([colspan]){position:sticky;left:0;z-index:3}
+.statement-ledger-scroll.has-horizontal-overflow .statement-ledger :is(th,td):last-child:not([colspan]){position:sticky;right:0;z-index:3}
+.statement-ledger-scroll.has-horizontal-overflow .statement-ledger th:is(:first-child,:last-child){z-index:4}
+.statement-ledger-scroll.can-scroll-left.can-pin-identity .statement-ledger :is(th,td):first-child:not([colspan]){box-shadow:9px 0 12px -10px rgb(24 40 48 / 35%)}
+.statement-ledger-scroll.can-scroll-right .statement-ledger :is(th,td):last-child:not([colspan]){box-shadow:-9px 0 12px -10px rgb(24 40 48 / 35%)}
+@media (max-width: 599px) {
+  .reconcile-index > .reconcile-ledger > .statement-filters{padding-inline:12px}
+  .statement-filters .ops-search{flex:1 1 130px;min-width:min(130px,100%)}
+}
 
 /* 账单明细:长名称及关联单号适度加宽,其余均衡,天数/操作保持紧凑。 */
 .bill-ledger-scroll{position:relative;overflow-x:auto;overflow-y:hidden;scrollbar-gutter:stable;overscroll-behavior-x:contain}