|
|
@@ -13,11 +13,11 @@ import { useMemo, useState } from "react";
|
|
|
import { PageIntro } from "../components/PageIntro";
|
|
|
import { useNavigate, useParams } from "react-router";
|
|
|
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 { Input } from "../components/ui/input";
|
|
|
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 { LIST_PAGE_SIZE, clampPage } from "../lib/list-paging";
|
|
|
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 { isSeatPlaceholder, seatDisplayName } from "../lib/customer-subaccounts";
|
|
|
import "../styles/operations.css";
|
|
|
+import "../styles/portal-plans.css";
|
|
|
|
|
|
const MISSING = "后端未下发";
|
|
|
|
|
|
@@ -59,52 +60,78 @@ export function CustomerPlanPage() {
|
|
|
const board = useLoad(() => portalPlanBoard({ view: "board" }), []);
|
|
|
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>;
|
|
|
}
|
|
|
|