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

style(web): 重设计我的套餐页面布局

sy 3 дней назад
Родитель
Сommit
c680eb2bb4
2 измененных файлов с 155 добавлено и 48 удалено
  1. 75 48
      web-scaffold/src/pages/CustomerSelfServicePages.tsx
  2. 80 0
      web-scaffold/src/styles/portal-plans.css

+ 75 - 48
web-scaffold/src/pages/CustomerSelfServicePages.tsx

@@ -13,11 +13,11 @@ import { useMemo, useState } from "react";
 import { PageIntro } from "../components/PageIntro";
 import { PageIntro } from "../components/PageIntro";
 import { useNavigate, useParams } from "react-router";
 import { useNavigate, useParams } from "react-router";
 import { FetchError } from "../components/fetchError";
 import { FetchError } from "../components/fetchError";
-import { PencilLine } from "lucide-react";
+import { ArrowDown, History, Layers3, PencilLine } from "lucide-react";
 import { Button } from "../components/ui/button";
 import { Button } from "../components/ui/button";
 import { Input } from "../components/ui/input";
 import { Input } from "../components/ui/input";
 import { ListPager } from "../components/ListPager";
 import { ListPager } from "../components/ListPager";
-import { OpsNotice, OpsStatus, OpsTableEmpty } from "../components/OperationsKit";
+import { OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty } from "../components/OperationsKit";
 import { Tri } from "../components/triState";
 import { Tri } from "../components/triState";
 import { LIST_PAGE_SIZE, clampPage } from "../lib/list-paging";
 import { LIST_PAGE_SIZE, clampPage } from "../lib/list-paging";
 import { useDemoIdentity } from "../lib/demo-session";
 import { useDemoIdentity } from "../lib/demo-session";
@@ -29,6 +29,7 @@ import { ACCT_STATUS, PLAN_FAMILY, label } from "../lib/api/labels";
 import type { PortalPlanBoardRow, SubAccountRow } from "../lib/api/types";
 import type { PortalPlanBoardRow, SubAccountRow } from "../lib/api/types";
 import { isSeatPlaceholder, seatDisplayName } from "../lib/customer-subaccounts";
 import { isSeatPlaceholder, seatDisplayName } from "../lib/customer-subaccounts";
 import "../styles/operations.css";
 import "../styles/operations.css";
+import "../styles/portal-plans.css";
 
 
 const MISSING = "后端未下发";
 const MISSING = "后端未下发";
 
 
@@ -59,52 +60,78 @@ export function CustomerPlanPage() {
   const board = useLoad(() => portalPlanBoard({ view: "board" }), []);
   const board = useLoad(() => portalPlanBoard({ view: "board" }), []);
   const data = board.data;
   const data = board.data;
 
 
-  if (board.error) {
-    return <section className="ops-page"><header className="ops-heading"><div><p className="ops-eyebrow"><span /> 企业门户 · 我的套餐</p><h1>我的套餐</h1></div></header>
-      <FetchError message={board.error.message} onRetry={board.reload} />
-    </section>;
-  }
-  if (board.loading && !data) {
-    return <section className="ops-page"><header className="ops-heading"><div><p className="ops-eyebrow"><span /> 企业门户 · 我的套餐</p><h1>我的套餐</h1></div></header>
-      <div className="ops-card ops-plan-card"><div><h2>套餐加载中…</h2><p>正在按会话主体号读取当前套餐与往期套餐。</p></div></div>
-    </section>;
-  }
-  if (!data) {
-    return <section className="ops-page"><header className="ops-heading"><div><p className="ops-eyebrow"><span /> 企业门户 · 我的套餐</p><h1>我的套餐</h1></div></header>
-      <div className="ops-card ops-plan-card"><div><h2>套餐暂不可读</h2><p>{customerNo ? `会话主体号 ${customerNo}` : "当前会话未带客户主体号"} 未取到套餐数据,请稍后重试或联系运维核实账号权限。</p></div></div>
-    </section>;
-  }
-  const current = data.current_rows;
-  const history = data.history_rows;
-  const table = (title: string, rows: PortalPlanBoardRow[], empty: string) =>
-    <div className="ops-list-shell list-shell-fill">
-      <div className="ops-card-title-row"><h2>{title}</h2><span className="ops-muted">共 {rows.length} 条</span></div>
-      <div className="ops-table-wrap measured-table-scroll"><table className="ops-table">
-        <thead><tr><th>套餐 / 合同</th><th>运营商</th><th>总金额</th><th>方式</th><th>线路出口</th><th>期间</th><th>状态</th></tr></thead>
-        <tbody>
-          {rows.map((row) => <tr key={row.subscription_id}>
-            <td>
-              <strong>{row.plan_name}</strong>
-              <div className="ops-muted">{row.contract_no ?? <span className="table-placeholder">—</span>}</div>
-              {/* 交付现状摘要(第 9 册 §4.3 行内摘要):台账口径,只读;⛔ 不占列、不开详情口 */}
-              {row.ip_summary && <div className="ops-muted">在册 {row.ip_summary.live_ip_count} 个 IP · {row.ip_summary.live_account_count} 个在用账号{row.ip_summary.released_ip_count > 0 ? `(已回收 ${row.ip_summary.released_ip_count})` : ""}</div>}
-            </td>
-            <td>{data.party.operator_name ?? <Tri tone="missing" text={MISSING} title="客户档案未挂运营商:合同签订方一列无值,非取数失败" />}</td>
-            <td className="table-number">{money(row.contract_amount_cents)}</td>
-            <td>{row.plan_family ? label(PLAN_FAMILY, row.plan_family) : <span className="table-placeholder">—</span>}</td>
-            <td>{exits(row.line_exits)}</td>
-            <td>{row.start_date ?? <span className="table-placeholder">—</span>} 至 {row.end_date ?? <span className="table-placeholder">—</span>}</td>
-            <td><OpsStatus tone={row.status.key === "active" ? "success" : row.status.key === "pending" ? "warning" : "neutral"}>{row.status.label}</OpsStatus></td>
-          </tr>)}
-          {!rows.length && <OpsTableEmpty colSpan={7}>{empty}</OpsTableEmpty>}
-        </tbody>
-      </table></div>
-      <p className="ops-muted" role="note">{data.amount_note}</p>
-    </div>;
-  return <section className="ops-page"><header className="ops-heading"><div><p className="ops-eyebrow"><span /> 企业门户 · 我的套餐</p><h1>{data.party.customer_name || customerNo}</h1><p>所属区域:{data.party.region_path ?? <Tri tone="missing" text={MISSING} />} · 运营商:{data.party.operator_name ?? <Tri tone="missing" text={MISSING} />}</p></div></header>
-    {table("当前套餐", current, "当前没有待生效或生效中的套餐。")}
-    {table("往期套餐", history, "没有已到期或已终止的套餐。")}
-    {data.notes.length > 0 && <ul className="ops-muted" role="note">{data.notes.map((n) => <li key={n}>{n}</li>)}</ul>}
+  const sections = data && [
+    { id: "current-plans", title: "当前套餐", rows: data.current_rows, icon: Layers3, empty: "当前没有待生效或生效中的套餐。" },
+    { id: "past-plans", title: "往期套餐", rows: data.history_rows, icon: History, empty: "没有已到期或已终止的套餐。" },
+  ];
+
+  return <section className="ops-page portal-plan-page">
+    <header className="ops-heading">
+      <div>
+        <h1>我的套餐</h1>
+        <PageIntro>查看当前和往期套餐的合同金额、使用期间及线路出口。</PageIntro>
+      </div>
+    </header>
+
+    {board.error ? <FetchError message={board.error.message} onRetry={board.reload} />
+      : !data || !sections ? <div className="ops-list-shell portal-plan-state" role="status">
+        {board.loading ? "正在读取套餐…" : "暂未取到套餐数据,请稍后重试或联系运营对接人。"}
+        {!board.loading && <Button type="button" size="sm" variant="outline" onClick={board.reload}>重试</Button>}
+      </div> : <>
+        <dl className="portal-plan-party" aria-label="客户归属">
+          <div><dt>客户</dt><dd>{data.party.customer_name || customerNo || <Tri tone="missing" text={MISSING} />}</dd></div>
+          <div><dt>所属区域</dt><dd>{data.party.region_path ?? <Tri tone="missing" text={MISSING} />}</dd></div>
+          <div><dt>运营商</dt><dd>{data.party.operator_name ?? <Tri tone="missing" text={MISSING} />}</dd></div>
+        </dl>
+
+        <nav className="portal-plan-sections" aria-label="套餐分组">
+          {sections.map(({ id, title, icon: Icon, rows }) => (
+            <a key={id} href={`#${id}`}>
+              <span className="portal-plan-section-icon"><Icon size={18} aria-hidden="true" /></span>
+              <strong>{title}</strong>
+              <span className="portal-plan-count">{rows.length} 条</span>
+              <ArrowDown size={14} aria-hidden="true" />
+            </a>
+          ))}
+        </nav>
+
+        {sections.map(({ id, title, rows, empty }) => (
+          <section key={id} id={id} className="ops-list-shell portal-plan-ledger" aria-labelledby={`${id}-title`}>
+            <header className="ops-list-heading">
+              <h2 id={`${id}-title`}>{title}</h2>
+            </header>
+            <div className="ops-table-wrap portal-plan-scroll" role="region" aria-labelledby={`${id}-title`} tabIndex={0}>
+              <table className="ops-table portal-plan-table">
+                <OpsTableColumns widths={[240, 158, 122, 104, 140, 124, 112]} />
+                <thead><tr>{["套餐 / 合同", "运营商", "总金额", "方式", "线路出口", "期间", "状态"].map((column) => <th key={column} scope="col">{column}</th>)}</tr></thead>
+                <tbody>
+                  {rows.map((row: PortalPlanBoardRow) => (
+                    <tr key={row.subscription_id}>
+                      <td>
+                        <span className="table-cell-title">{row.plan_name}</span>
+                        <small className={row.contract_no ? undefined : "table-placeholder"}>{row.contract_no ?? "—"}</small>
+                        {row.ip_summary && <small>在册 {row.ip_summary.live_ip_count} 个 IP · {row.ip_summary.live_account_count} 个在用账号{row.ip_summary.released_ip_count > 0 ? `(已回收 ${row.ip_summary.released_ip_count})` : ""}</small>}
+                      </td>
+                      <td>{data.party.operator_name ?? <Tri tone="missing" text={MISSING} />}</td>
+                      <td><span className={row.contract_amount_cents == null ? "table-placeholder" : "portal-plan-amount table-number"}>{money(row.contract_amount_cents)}</span></td>
+                      <td>{row.plan_family ? label(PLAN_FAMILY, row.plan_family) : <span className="table-placeholder">—</span>}</td>
+                      <td>{exits(row.line_exits)}</td>
+                      <td>
+                        <div>{row.start_date ?? <span className="table-placeholder">—</span>}</div>
+                        <small>至 {row.end_date ?? <span className="table-placeholder">—</span>}</small>
+                      </td>
+                      <td><OpsStatus tone={row.status.key === "active" ? "success" : ["pending", "expired"].includes(row.status.key) ? "warning" : "neutral"}>{row.status.label}</OpsStatus></td>
+                    </tr>
+                  ))}
+                  {!rows.length && <OpsTableEmpty colSpan={7}>{empty}</OpsTableEmpty>}
+                </tbody>
+              </table>
+            </div>
+            <p className="portal-plan-note" role="note">{data.amount_note}</p>
+          </section>
+        ))}
+        {data.notes.length > 0 && <ul className="portal-plan-notes" role="note">{data.notes.map((note) => <li key={note}>{note}</li>)}</ul>}
+      </>}
   </section>;
   </section>;
 }
 }
 
 

+ 80 - 0
web-scaffold/src/styles/portal-plans.css

@@ -0,0 +1,80 @@
+.portal-plan-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
+.portal-plan-page > .ops-heading { margin-bottom: 0; }
+.portal-plan-party {
+  display: grid;
+  grid-template-columns: repeat(3, minmax(0, 1fr));
+  margin: 0;
+  border: 1px solid var(--border);
+  border-radius: var(--radius-card);
+  background: var(--card);
+}
+.portal-plan-party > div { padding: 11px 16px; }
+.portal-plan-party > div + div { border-inline-start: 1px solid var(--border-subtle); }
+.portal-plan-party dt { color: var(--muted-foreground); font-size: var(--type-meta); }
+.portal-plan-party dd {
+  margin: 4px 0 0;
+  color: var(--text-secondary);
+  font-size: var(--type-body);
+  font-weight: 500;
+  overflow-wrap: anywhere;
+}
+.portal-plan-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
+.portal-plan-sections > a {
+  display: grid;
+  grid-template-columns: auto minmax(0, 1fr) auto auto;
+  align-items: center;
+  gap: 9px;
+  min-height: 54px;
+  padding: 9px 13px;
+  border: 1px solid var(--border);
+  border-radius: var(--radius-control);
+  background: var(--card);
+  color: var(--text-secondary);
+  font-size: var(--type-body);
+}
+.portal-plan-sections > a:first-child { border-color: var(--primary-border); background: var(--primary-soft); }
+.portal-plan-sections > a:hover { border-color: var(--border-hover); color: var(--primary); }
+.portal-plan-sections strong { font-weight: 600; }
+.portal-plan-section-icon {
+  display: grid;
+  place-items: center;
+  width: 34px;
+  height: 34px;
+  border: 1px solid var(--border);
+  border-radius: 7px;
+  background: var(--card);
+  color: var(--primary-soft-foreground);
+}
+.portal-plan-count {
+  padding: 2px 7px;
+  border-radius: 5px;
+  background: var(--card);
+  color: var(--primary);
+  font-size: var(--type-meta);
+  font-variant-numeric: tabular-nums;
+  white-space: nowrap;
+}
+.portal-plan-ledger { scroll-margin-block-start: calc(4rem + 12px); }
+.portal-plan-scroll { max-height: min(460px, 62dvh); overflow: auto; }
+.portal-plan-scroll:focus-visible, .portal-plan-sections > a:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
+.portal-plan-table.ops-table { min-width: 890px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
+.portal-plan-table th { position: sticky; top: 0; z-index: 1; }
+.portal-plan-table td { white-space: normal; overflow-wrap: anywhere; }
+.portal-plan-table tbody tr:hover td { background: var(--surface-subtle); }
+.portal-plan-table td small { display: block; margin-top: 3px; color: var(--muted-foreground); font-size: var(--type-meta); }
+.portal-plan-table :is(th, td):nth-child(3) { text-align: end; }
+.portal-plan-table .portal-plan-amount { color: var(--primary); font-weight: 500; white-space: nowrap; }
+.portal-plan-note, .portal-plan-notes { color: var(--muted-foreground); font-size: var(--type-meta); line-height: 1.55; }
+.portal-plan-note { margin: 0; padding: 11px 24px; background: var(--surface-subtle); }
+.portal-plan-notes { margin: 0; padding-inline-start: 18px; }
+.portal-plan-state { display: grid; min-height: 170px; place-content: center; justify-items: center; gap: 10px; padding: 18px; color: var(--muted-foreground); text-align: center; }
+
+@media (max-width: 600px) {
+  .portal-plan-party { grid-template-columns: minmax(0, 1fr); }
+  .portal-plan-party > div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 8px; align-items: baseline; }
+  .portal-plan-party > div + div { border-inline-start: 0; border-top: 1px solid var(--border-subtle); }
+  .portal-plan-party dd { margin: 0; }
+  .portal-plan-sections > a { grid-template-columns: minmax(0, 1fr) auto auto; padding-inline: 10px; }
+  .portal-plan-section-icon { display: none; }
+  .portal-plan-note { padding-inline: 18px; }
+}