Просмотр исходного кода

调整运营商表格列宽并突出关键字段

sy 1 день назад
Родитель
Сommit
3646679917
2 измененных файлов с 62 добавлено и 25 удалено
  1. 42 21
      web-scaffold/src/pages/OrganizationPages.tsx
  2. 20 4
      web-scaffold/src/styles/organization.css

+ 42 - 21
web-scaffold/src/pages/OrganizationPages.tsx

@@ -9,7 +9,7 @@ import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
 import { FilterIcon, FilterSelect } from "../components/ui/filter-select";
 import { useLayoutEffect, useEffect, useMemo, useRef, useState, type CSSProperties, type FormEvent, type ReactNode } from "react";
 import { createPortal } from "react-dom";
-import { ArrowLeft, ArrowRight, ChevronDown, ChevronRight, Download, Info, MapPinned, PencilLine, Plus, Search, Trash2, UserRound, Users, Wrench, X } from "lucide-react";
+import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, ChevronDown, ChevronRight, Download, Info, MapPinned, PencilLine, Plus, Search, Trash2, UserRound, Users, Wrench, X } from "lucide-react";
 import { Link, useParams, useSearchParams } from "react-router";
 import { Button as FilterResetButton } from "../components/ui/button";
 import { TreeSelect } from "../components/ui/tree-select";
@@ -1011,16 +1011,11 @@ export function RegionManagementPage() {
 export function OperatorManagementPage() {
   const data = useOrganizationData(["regions", "operators", "enterprises"]);
   const tableOverflow = useHorizontalOverflow();
-  // 操作列空间够:账号+编辑+删除直接展开,⛔ 再收进「更多」。
-  const expandedActions = true;
-  const actionWidth = 168;
-  const dayWidth = 148;
-  const cycleWidth = 72;
-  const customerWidth = 52;
-  const accountWidth = 88;
-  const fixed = dayWidth + cycleWidth + customerWidth + accountWidth + actionWidth;
-  const flex = Math.max(280, (tableOverflow.width || 1200) - fixed);
-  const columnWidths = [flex * .22, flex * .36, dayWidth, cycleWidth, flex * .42, customerWidth, accountWidth, actionWidth];
+  const minimumWidths = [122, 98, 140, 80, 80, 86, 108, 188];
+  const minimumTableWidth = minimumWidths.reduce((sum, width) => sum + width, 0);
+  const extraWidth = Math.max(0, tableOverflow.width - minimumTableWidth);
+  const extraShares = [.43, .33, 0, 0, .24, 0, 0, 0];
+  const columnWidths = minimumWidths.map((width, index) => width + extraWidth * extraShares[index]);
   const [query, setQuery] = useState("");
   const regionIds = useMemo(() => new Set(data.regions.map((item) => item.id)), [data.regions]);
   const [region, setRegion, invalidRegion] = useRegionQueryFilter(regionIds);
@@ -1068,7 +1063,17 @@ export function OperatorManagementPage() {
       ...rows.map((o) => [o.name, regionPath(data, o.region), reconcileDayText(o, defaultDay), o.payCycle || "未配置", o.sharePending ? "未配置" : `${shareText(o)} · ${o.shareMode}`, o.customerCount ?? "", o.account, o.login || ""]),
     ]);
   }
-  const sortAria = (key: OpSort) => sortKey === key ? (sortDir === "asc" ? "ascending" : "descending") : "none";
+  function sortHeader(key: OpSort, label: string) {
+    const active = sortKey === key;
+    const SortIcon = active ? (sortDir === "asc" ? ArrowUp : ArrowDown) : ArrowUpDown;
+    return (
+      <th scope="col" aria-sort={active ? (sortDir === "asc" ? "ascending" : "descending") : undefined}>
+        <button className="org-operator-sort" type="button" onClick={() => toggleSort(key)}>
+          {label}<SortIcon size={13} aria-hidden="true" />
+        </button>
+      </th>
+    );
+  }
   return <div className="org-page org-operator-page page-fill">
     <PageHead eyebrow="组织与区域 / 02" title="运营商管理" description="按所属区域建立结算对手方档案,集中核对对账口径。" action={<Button onClick={() => setEditor({ kind: "operator" })}><Plus size={16} /> 新增运营商</Button>} />
     <OrgFetchState status={status} collections={["operators"]} />
@@ -1086,18 +1091,34 @@ export function OperatorManagementPage() {
         <FilterResetButton variant="ghost" size="sm" disabled={!rows.length} onClick={exportRows}><Download size={14} /> 导出 CSV</FilterResetButton>
       </div>
       <div ref={tableOverflow.ref} tabIndex={0} role="region" aria-label="运营商列表,可横向滚动查看字段" className={`measured-table-scroll org-table-wrap org-operator-table-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.width >= 600 ? " can-pin-identity" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`}>
-        <table className="org-table org-operator-ledger"><OpsTableColumns widths={columnWidths} />
-          <thead><tr><th className="sortable" aria-sort={sortAria("name")} onClick={() => toggleSort("name")}>运营商</th><th className="sortable" aria-sort={sortAria("region")} onClick={() => toggleSort("region")}>所属区域</th><th>对账日</th><th>付款周期</th><th>分成规则</th><th className="sortable" aria-sort={sortAria("customers")} onClick={() => toggleSort("customers")}>客户</th><th>账号</th><th className="org-table-actions-heading">操作</th></tr></thead>
+        <table className="org-table org-operator-ledger" style={{ minWidth: minimumTableWidth }}>
+          <OpsTableColumns widths={columnWidths} />
+          <thead>
+            <tr>
+              {sortHeader("name", "运营商")}
+              {sortHeader("region", "所属区域")}
+              <th scope="col">对账日</th>
+              <th scope="col">付款周期</th>
+              <th scope="col">分成规则</th>
+              {sortHeader("customers", "客户数")}
+              <th scope="col">账号状态</th>
+              <th scope="col" className="org-table-actions-heading">操作</th>
+            </tr>
+          </thead>
           <tbody>{!status.partial.operators && pageRows.map((o) => {
             const shareLabel = o.sharePending ? "未配置" : `${shareText(o)} · ${o.shareMode}`;
             const accountOpened = o.account !== "未开通";
             return <tr className={selected === o.id ? "selected" : ""} key={o.id} tabIndex={0} aria-label={`查看${regionPath(data, o.region)}${o.name}档案`} onKeyDown={(event) => { if (event.key === "Enter" && event.target === event.currentTarget) setSelected(o.id); }} onClick={() => setSelected(o.id)}>
-              <td><strong title={o.name}>{o.name}</strong></td>
+              <td className="org-operator-identity"><strong title={o.name}>{o.name}</strong>{o.brand && <small>{o.brand}</small>}</td>
               <td title={regionPath(data, o.region)}>{regionPath(data, o.region)}</td>
-              <td><span title={reconcileDayTitle(o, defaultDay)}>{reconcileDayText(o, defaultDay)}</span></td>
-              <td>{o.payCycle || "未配置"}</td>
-              <td title={shareLabel}>{shareLabel}</td>
-              <td className="org-number"><Count v={o.customerCount} /></td>
+              <td><span className="org-operator-value" title={reconcileDayTitle(o, defaultDay)}>{reconcileDayText(o, defaultDay)}</span></td>
+              <td title={o.payCycle || undefined}>{o.payCycle || "未配置"}</td>
+              <td title={shareLabel}>
+                {o.sharePending ? <span className="org-operator-muted">{shareLabel}</span> : (
+                  <><span className="org-operator-value">{shareText(o)}</span><small>{o.shareMode}</small></>
+                )}
+              </td>
+              <td className="org-operator-customer-count"><Count v={o.customerCount} /></td>
               <td>{/* 账号列只显示状态徽标;登录名/手机号挂 title,悬停可见。 */}
                 <OrganizationAccountStatus
                   status={o.account}
@@ -1107,8 +1128,8 @@ export function OperatorManagementPage() {
                 />
               </td>
               <td className="org-table-actions-cell"><div className="org-table-actions is-icons">
-                <button className="is-account" onClick={(event) => { event.stopPropagation(); setSelected(o.id); setAccountTarget({ kind: "operator", id: o.id }); }} type="button"><UserRound size={15} />账号</button>
-                <OpsResponsiveActions expanded={expandedActions} items={[
+                <button className="is-account" aria-haspopup="dialog" onClick={(event) => { event.stopPropagation(); setSelected(o.id); setAccountTarget({ kind: "operator", id: o.id }); }} type="button"><UserRound size={15} />账号</button>
+                <OpsResponsiveActions expanded items={[
                   { label: "编辑", icon: <PencilLine size={15} />, onSelect: () => { setSelected(o.id); setEditor({ kind: "operator", id: o.id }); } },
                   { label: "删除", danger: true, icon: <Trash2 size={15} />, onSelect: () => { setSelected(o.id); setDeleteId(o.id); } },
                 ]} />

+ 20 - 4
web-scaffold/src/styles/organization.css

@@ -642,15 +642,28 @@ a.org-overview-card{text-decoration:none;color:inherit}
 .org-operator-page .org-filterbar,.org-operator-page .org-list-pager,.org-partner-page .org-filterbar,.org-partner-page .ops-list-heading,.org-partner-page .org-list-pager,.org-operations-ledger-page .ops-list-heading,.org-operations-ledger-page .ops-toolbar,.org-operations-ledger-page .org-list-pager,.org-operations-ledger-page .org-maintenance-ledger-note,.org-maintenance-ledger-page .ops-list-heading,.org-maintenance-ledger-page .ops-toolbar,.org-maintenance-ledger-page .org-list-pager,.org-maintenance-ledger-page .org-maintenance-ledger-note{flex:none}
 .org-operator-table-scroll,.org-partner-table-scroll,.org-operations-ledger-page .org-team-table-scroll,.org-maintenance-ledger-page .org-team-table-scroll{position:relative;flex:1;min-height:0;overflow:auto;scrollbar-gutter:stable;overscroll-behavior-x:contain}
 .org-operator-table-scroll:focus-visible,.org-partner-table-scroll:focus-visible,.org-team-table-scroll:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}
-.org-operator-ledger{min-width:0;width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0}
+.org-operator-ledger{width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0}
 .org-operator-ledger :is(th,td){padding:10px 12px}
+.org-operator-ledger :is(th,td):first-child { padding-inline-start: 16px; }
 .org-operator-ledger td{background:var(--card)}
-.org-operator-ledger th{font-weight:500;background:var(--org-soft)}
+.org-operator-ledger th{font-weight:600;background:var(--org-soft);white-space:nowrap}
 .org-operator-ledger thead th{position:sticky;top:0;z-index:1}
 .org-operator-ledger td:not(:last-child),.org-operator-ledger td strong,.org-operator-ledger td small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.org-operator-sort { display: inline-flex; align-items: center; gap: 5px; border-radius: 4px; font: inherit; color: inherit; cursor: pointer; }
+.org-operator-sort svg { flex: none; color: var(--icon); }
+.org-operator-ledger th[aria-sort] .org-operator-sort svg, .org-operator-sort:hover { color: var(--primary); }
+.org-operator-sort:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
+.org-operator-ledger .org-operator-identity { position: relative; }
+.org-operator-ledger .org-operator-identity strong { font-weight: 600; }
+.org-operator-ledger .org-operator-value + small,
+.org-operator-ledger .org-operator-identity small { margin-top: 3px; font-size: var(--type-meta); }
+.org-operator-value { display: block; overflow: hidden; color: var(--foreground); font-weight: 550; font-variant-numeric: tabular-nums; text-overflow: ellipsis; }
+.org-operator-muted { color: var(--muted-foreground); }
 .org-operator-ledger tbody tr:is(:hover,:focus-within) td{background:var(--surface-subtle)}
-.org-operator-ledger tbody tr.selected td{background:var(--primary-soft)}
+.org-operator-ledger tbody tr.selected td{background:color-mix(in srgb,var(--primary-soft) 42%,var(--card))}
+.org-operator-ledger tbody tr.selected .org-operator-identity::before { position: absolute; inset-block: 8px; inset-inline-start: 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); content: ""; }
 .org-operator-ledger :is(th,td):nth-child(6){text-align:right;font-variant-numeric:tabular-nums;padding-right:14px}
+.org-operator-ledger .org-operator-customer-count { color: var(--primary); font-weight: 600; }
 /* 操作列表头与按钮组右缘对齐(⛔ 表头左飘/与单元格错位)。 */
 .org-operator-ledger .org-table-actions-heading,.org-operator-ledger .org-table-actions-cell{text-align:right;padding-right:10px;vertical-align:middle}
 .org-operator-ledger .org-table-actions-heading{letter-spacing:.04em}
@@ -661,7 +674,10 @@ a.org-overview-card{text-decoration:none;color:inherit}
 .org-operator-table-scroll.can-scroll-left.can-pin-identity .org-operator-ledger :is(th,td):first-child{box-shadow:9px 0 12px -10px rgb(24 40 48 / 35%);border-right:1px solid var(--org-line)}
 .org-operator-table-scroll.can-scroll-right .org-operator-ledger :is(th,td):last-child{box-shadow:-9px 0 12px -10px rgb(24 40 48 / 35%);border-left:1px solid var(--org-line)}
 .org-operator-ledger .org-table-actions.is-icons{gap:2px;flex-wrap:nowrap;justify-content:flex-end}
-.org-operator-ledger .org-table-actions.is-icons button{padding:3px 5px;min-height:28px}
+.org-operator-ledger .org-table-actions.is-icons button{gap:4px;padding:3px 4px;min-height:28px;white-space:nowrap}
+.org-operator-ledger .org-table-actions.is-icons button svg { flex: none; width: 14px; height: 14px; }
+.org-operator-ledger .org-table-actions.is-icons button.is-account { border: 1px solid var(--primary-border); border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
+.org-operator-ledger .org-table-actions.is-icons button.is-account:hover { border-color: var(--primary); }
 @media(max-width:1100px){.org-operator-page .org-ledger,.org-partner-page .org-ledger{grid-template-columns:minmax(0,1fr)}.org-operator-page .org-ledger-detail{border-left:0;border-top:1px solid var(--org-line)}}
 
 /* 合伙人名录:与运营商台账同风格,表体区内滚。 */