Selaa lähdekoodia

style(web): 对齐对账清单与账单明细表格列样式

sy 2 päivää sitten
vanhempi
commit
37a5e6b136

+ 71 - 45
web-scaffold/src/pages/SettlementRecordPages.tsx

@@ -259,22 +259,58 @@ function RerunDialog({ onClose }: { onClose: () => void }) {
 
 /* ── 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 },
+type SettlementLedgerColumn = { label: string; width: number; numeric?: boolean };
+const settlementActionWidth = 84;
+const statementColumns: readonly SettlementLedgerColumn[] = [
+  { label: "对账单号", width: 172 }, { label: "分成方", width: 180 },
+  { label: "自然月", width: 80 }, { label: "应出账日期", width: 104 },
+  { label: "触发方式", width: 88 }, { label: "明细条数", width: 86, numeric: true },
+  { label: "总金额", width: 112, numeric: true }, { label: "分成金额", width: 116, numeric: true },
+  { label: "出账状态", width: 98 }, { label: "批次状态", width: 104 },
+  { label: "执行人", width: 106 },
 ];
-const statementTableWidth = statementColumns.reduce((sum, column) => sum + column.width, 0);
+const billColumns: readonly SettlementLedgerColumn[] = [
+  { label: "分成方", width: 164 }, { label: "自然月", width: 80 },
+  { label: "客户", width: 180 }, { label: "订阅", width: 192 },
+  { label: "计费天数", width: 90, numeric: true }, { label: "分成基数", width: 112, numeric: true },
+  { label: "本方分成金额", width: 124, numeric: true }, { label: "对账单号", width: 164 },
+];
+
+function useSettlementLedgerTable(columns: readonly SettlementLedgerColumn[]) {
+  const { ref, width, overflow, canScrollLeft, canScrollRight } = useHorizontalOverflow();
+  const minContentWidth = columns.reduce((sum, column) => sum + column.width, 0);
+  const contentWidth = Math.max(minContentWidth, width - settlementActionWidth);
+  const widths = columns.map((column) => contentWidth * (column.width / minContentWidth)).concat(settlementActionWidth);
+  const className = [
+    "measured-table-scroll ops-table-wrap settlement-ledger-scroll",
+    overflow && "has-horizontal-overflow",
+    width >= 900 && "can-pin-identity",
+    canScrollLeft && "can-scroll-left",
+    canScrollRight && "can-scroll-right",
+  ].filter(Boolean).join(" ");
+  return { ref, className, widths, minWidth: minContentWidth + settlementActionWidth };
+}
+
+function SettlementLedgerHead({ columns }: { columns: readonly SettlementLedgerColumn[] }) {
+  return <thead><tr>
+    {columns.map(({ label, numeric }) => <th key={label} scope="col" className={numeric ? "settlement-ledger-number" : undefined}>{label}</th>)}
+    <th scope="col" className="settlement-ledger-action">操作</th>
+  </tr></thead>;
+}
+
+function SettlementHolderCell({ name, type }: { name: string; type: HolderType }) {
+  return <td>
+    <strong className="table-cell-title" title={name}>{name || <span className="table-placeholder">—</span>}</strong>
+    <div className="settlement-ledger-holder-type"><OpsTag tone={holderTone[type]}>{HOLDER_TYPE_TEXT[type]}</OpsTag></div>
+  </td>;
+}
 
 export function SettlementStatementListPage() {
   const identity = useDemoIdentity();
   const listState = useDetailLinkState();
   const back = detailBack(listState.previousState, "/settlement-batches", BACK_TO_RECON_LIST);
   const filters = useListFilters();
-  const tableOverflow = useHorizontalOverflow();
+  const table = useSettlementLedgerTable(statementColumns);
   const progressId = useId();
   // 导出当前结果(B):admin/opsMain/opsSub(demo 角色无 opsSub);⛔ teamLead/partner/operator。
   const canExportAll = !identity || identity.role === "admin" || identity.role === "regAdmin";
@@ -338,13 +374,6 @@ export function SettlementStatementListPage() {
   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(" ");
 
   async function exportAll() {
     if (exporting || list.loading) return;
@@ -484,28 +513,24 @@ export function SettlementStatementListPage() {
         </div>
 
         {/* S404 触顶 ⇒ 不渲染三卡与列表(⚠️ 禁止静默截断)。 */}
-        <div className={tableClass} ref={tableOverflow.ref} role="region" aria-label="对账批次,可横向滚动查看字段" tabIndex={0}>
+        <div className={table.className} ref={table.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>{statementColumns.map(({ label }) => <th key={label} scope="col">{label}</th>)}</tr>
-              </thead>
+            <table className="ops-table settlement-ledger statement-ledger" style={{ minWidth: table.minWidth }}>
+              <OpsTableColumns widths={table.widths} />
+              <SettlementLedgerHead columns={statementColumns} />
               <tbody>
                 {rows.map((row) => (
                   <tr key={row.batch_no}>
                     <td>
                       <span className="table-cell-title" title={row.batch_no}>{row.batch_no}</span>
                     </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>
+                    <SettlementHolderCell name={row.holder_name} type={row.holder_type} />
                     <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><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 className="settlement-ledger-number"><span className="table-number">{row.detail_count}</span><span className="settlement-ledger-unit"> 条</span></td>
+                    <td className="settlement-ledger-number"><span className="ops-money" title={moneyFromCents(row.base_cents)}>{moneyFromCents(row.base_cents)}</span></td>
+                    <td className="settlement-ledger-number"><span className="ops-money settlement-ledger-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>
                       <div className="statement-batch-status">
@@ -514,7 +539,7 @@ export function SettlementStatementListPage() {
                       </div>
                     </td>
                     <td title={executorText(row)}>{executorText(row)}</td>
-                    <td>
+                    <td className="settlement-ledger-action">
                       <Link className="ops-table-action" to={batchPath(row.holder_id, row.batch_no)} state={listState}>
                         详情<ArrowRight size={14} aria-hidden="true" />
                       </Link>
@@ -522,7 +547,7 @@ export function SettlementStatementListPage() {
                   </tr>
                 ))}
                 {!rows.length && (
-                  <OpsTableEmpty colSpan={statementColumns.length}>
+                  <OpsTableEmpty colSpan={table.widths.length}>
                     {list.loading ? "加载中…" : wiring ? "对账接口待后端接线,批次数据暂不可读。" : "没有符合筛选条件的对账清单。"}
                   </OpsTableEmpty>
                 )}
@@ -774,6 +799,7 @@ function BatchDetailBody({ d, isAdmin, onRerun, onExport, onCorrect, lineState }
 export function SettlementBillListPage() {
   const listNavState = useDetailLinkState();
   const filters = useListFilters();
+  const table = useSettlementLedgerTable(billColumns);
   const q = filters.get("q");
   const type = filters.get("type");
   const month = filters.get("month");
@@ -821,34 +847,34 @@ export function SettlementBillListPage() {
           {hasFilter && <Button variant="ghost" size="sm" onClick={filters.reset}>重置筛选</Button>}
         </div>
 
-        <div className="ops-table-wrap">
-          <table className="ops-table">
-            <OpsTableColumns widths={[180, 90, 170, 200, 90, 120, 130, 160, 76]} />
-            <thead><tr><th>分成方</th><th>自然月</th><th>客户</th><th>订阅</th><th>计费天数</th><th>分成基数</th><th>本方分成金额</th><th>对账单号</th><th>操作</th></tr></thead>
+        <div className={table.className} ref={table.ref} role="region" aria-label="账单明细,可横向滚动查看字段" tabIndex={0}>
+          <table className="ops-table settlement-ledger" style={{ minWidth: table.minWidth }}>
+            <OpsTableColumns widths={table.widths} />
+            <SettlementLedgerHead columns={billColumns} />
             <tbody>
               {rows.map((row) => (
                 <tr key={row.bill_detail_id}>
-                  <td><OpsTag tone={holderTone[row.holder_type]}>{HOLDER_TYPE_TEXT[row.holder_type]}</OpsTag> <strong className="table-cell-title">{row.holder_name}</strong></td>
+                  <SettlementHolderCell name={row.holder_name} type={row.holder_type} />
                   <td><span className="ops-mono">{row.period}</span></td>
-                  <td>{row.customer_name}</td>
-                  <td>{row.subscription_label}</td>
-                  <td className="table-number">{row.billing_days} 天</td>
-                  <td><span className="ops-money">{moneyFromCents(row.share_base_cents)}</span></td>
-                  <td><strong className="reconcile-money">{moneyFromCents(row.share_amount_cents)}</strong></td>
+                  <td><strong className="table-cell-title" title={row.customer_name}>{row.customer_name}</strong></td>
+                  <td><strong className="table-cell-title" title={row.subscription_label}>{row.subscription_label}</strong></td>
+                  <td className="settlement-ledger-number"><span className="table-number">{row.billing_days}</span><span className="settlement-ledger-unit"> 天</span></td>
+                  <td className="settlement-ledger-number"><span className="ops-money" title={moneyFromCents(row.share_base_cents)}>{moneyFromCents(row.share_base_cents)}</span></td>
+                  <td className="settlement-ledger-number"><span className="ops-money settlement-ledger-share" title={moneyFromCents(row.share_amount_cents)}>{moneyFromCents(row.share_amount_cents)}</span></td>
                   <td>
-                    <Link className="reconcile-row-link" title={row.batch_no} to={batchPath(row.holder_id, row.batch_no)} state={listNavState}>
-                      {row.batch_no}<ArrowRight size={14} />
+                    <Link className="ops-table-action settlement-ledger-batch-link" title={row.batch_no} to={batchPath(row.holder_id, row.batch_no)} state={listNavState}>
+                      <span>{row.batch_no}</span><ArrowRight size={14} aria-hidden="true" />
                     </Link>
                   </td>
-                  <td>
+                  <td className="settlement-ledger-action">
                     <Link className="ops-table-action" to={`/settlement-bills/${encodeURIComponent(row.bill_detail_id)}`} state={listNavState}>
-                      详情
+                      详情<ArrowRight size={14} aria-hidden="true" />
                     </Link>
                   </td>
                 </tr>
               ))}
               {!rows.length && (
-                <OpsTableEmpty colSpan={9}>
+                <OpsTableEmpty colSpan={table.widths.length}>
                   {list.loading ? "加载中…" : wiring ? "账单明细接口待后端接线,数据暂不可读。" : "没有符合筛选条件的账单明细。"}
                 </OpsTableEmpty>
               )}

+ 33 - 38
web-scaffold/src/styles/settlement-records.css

@@ -115,8 +115,6 @@
 .reconcile-ledger .ops-table td { vertical-align: middle; }
 .reconcile-ledger .ops-table td small { display: block; margin-top: 3px; color: var(--text-secondary); }
 .reconcile-ledger .ops-table th { white-space: nowrap; }
-.reconcile-row-link { display: inline-flex; align-items: center; gap: 5px; color: var(--primary); font-weight: 750; font-variant-numeric: tabular-nums; text-decoration: none; white-space: nowrap; }
-.reconcile-row-link:hover { text-decoration: underline; }
 .reconcile-money { color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
 .reconcile-footnote { margin: 0; padding: 13px 20px 17px; color: var(--text-secondary); font-size: var(--type-support); line-height: 1.6; }
 .reconcile-record > .ops-back-link { width: max-content; margin-bottom: 0; }
@@ -165,29 +163,42 @@
 
 /* 对账清单:金额列按需伸缩,固定编号及唯一详情入口。 */
 .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-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{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 :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(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-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-progress-table .table-cell-title{display:block}
 .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%)}
+
+/* 对账清单与账单明细沿用合同台账的紧凑行距、固定表头和操作列。 */
+.reconcile-ledger > .settlement-ledger-scroll { margin: 0; border: 0; border-radius: 0; }
+.settlement-ledger-scroll { position: relative; overflow: auto; scrollbar-gutter: stable; overscroll-behavior-x: contain; }
+.settlement-ledger-scroll:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
+.ops-table.settlement-ledger { table-layout: fixed; border-collapse: separate; border-spacing: 0; }
+.settlement-ledger th { position: sticky; top: 0; z-index: 2; padding-block: 8px; }
+.settlement-ledger td { padding-block: 10px; background: var(--card); }
+.settlement-ledger.statement-ledger th { border-top: 0; }
+.settlement-ledger tbody tr:is(:hover, :focus-within) td:not([colspan]) { background: var(--surface-subtle); }
+.settlement-ledger :is(td:not([colspan], :last-child), .table-cell-title, .settlement-ledger-batch-link > span) {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+.settlement-ledger .table-cell-title { display: block; }
+.settlement-ledger-holder-type { margin-top: 3px; }
+.settlement-ledger .settlement-ledger-number { text-align: right; font-variant-numeric: tabular-nums; }
+.settlement-ledger .settlement-ledger-unit { color: var(--muted-foreground); font-size: var(--type-meta); }
+.settlement-ledger td .ops-money { font-weight: 550; }
+.settlement-ledger td .settlement-ledger-share { color: var(--primary); }
+.settlement-ledger .settlement-ledger-action { padding-inline: 8px 16px; text-align: right; }
+.settlement-ledger .ops-table-action { min-height: 26px; padding-inline: 5px; }
+.settlement-ledger .settlement-ledger-batch-link { max-width: 100%; margin-inline-start: -5px; font-weight: 500; }
+.settlement-ledger-batch-link > span { min-width: 0; }
+.settlement-ledger-batch-link > svg { flex: none; }
+.settlement-ledger-scroll.has-horizontal-overflow.can-pin-identity .settlement-ledger :is(th, td):first-child:where(:not([colspan])) { position: sticky; inset-inline-start: 0; z-index: 3; }
+.settlement-ledger-scroll.has-horizontal-overflow .settlement-ledger .settlement-ledger-action { position: sticky; inset-inline-end: 0; z-index: 3; }
+.settlement-ledger-scroll.has-horizontal-overflow.can-pin-identity .settlement-ledger th:first-child,
+.settlement-ledger-scroll.has-horizontal-overflow .settlement-ledger th.settlement-ledger-action { z-index: 4; }
+.settlement-ledger-scroll.can-scroll-left.can-pin-identity .settlement-ledger :is(th, td):first-child:where(:not([colspan])) { box-shadow: 9px 0 12px -10px rgb(24 40 48 / 35%); border-inline-end: 1px solid var(--border-subtle); }
+.settlement-ledger-scroll.can-scroll-right .settlement-ledger .settlement-ledger-action { box-shadow: -9px 0 12px -10px rgb(24 40 48 / 35%); border-inline-start: 1px solid var(--border-subtle); }
 @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%)}
@@ -229,19 +240,3 @@
   .bill-record .bill-record-panel { padding-inline: 14px; }
   .bill-record-table .ops-table :is(th, td) { padding-inline: 8px; }
 }
-
-/* 账单明细:长名称及关联单号适度加宽,其余均衡,天数/操作保持紧凑。 */
-.bill-ledger-scroll{position:relative;overflow-x:auto;overflow-y:hidden;scrollbar-gutter:stable;overscroll-behavior-x:contain}
-.bill-ledger-scroll:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}
-.ops-table.bill-ledger{min-width:1460px;table-layout:fixed;border-collapse:separate;border-spacing:0}
-.bill-ledger td{background:var(--card)}
-.bill-ledger td:not(:last-child),.bill-ledger td strong,.bill-ledger td small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;overflow-wrap:normal}
-.bill-ledger tbody tr:is(:hover,:focus-within) td{background:var(--surface-subtle)}
-.bill-ledger :is(th,td):is(:nth-child(6),:nth-child(7),:last-child){text-align:right;font-variant-numeric:tabular-nums}
-.bill-ledger .reconcile-row-link{justify-content:flex-end}
-.bill-ledger-scroll.has-horizontal-overflow.can-pin-identity .bill-ledger :is(th,td):first-child:where(:not([colspan])){position:sticky;left:0;z-index:2}
-.bill-ledger-scroll.has-horizontal-overflow .bill-ledger :is(th,td):last-child:where(:not([colspan])){position:sticky;right:0;z-index:2}
-.bill-ledger-scroll.can-scroll-left.can-pin-identity .bill-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)}
-.bill-ledger-scroll.can-scroll-right .bill-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)}
-
-.bill-ledger :is(th,td):nth-child(5){text-align:center}