/** * 客户自助侧页面(第 3 册 6.13 / 6.14)—— 真源=klt-bos。 * * 分账号读写:`POST /sub_account/get_list@v1` + `POST /sub_account/update@v1`; * [实] `/sub_account/*` ⛔ 新增与删除路由 ⇒ 只保留「修改真实姓名」; * 客户身份展示走 `/customer/get@v1`(**自读**,主体号取自会话),⛔ 下发项标「后端未下发」。 * * ⚠️ 本页此前取的是 `/customer/get_list@v1`——那是**运营侧**名录读口(权限键 `bos.customer.list`), * 客户角色本就不该拿到它(2026-11-14「我的套餐/分账号」整页空态的根因)。自读口只要求 * `bos.customer.view`,且行集由后端按主体收窄,客户看不到别家档案。 */ 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 { Button } from "../components/ui/button"; import { Input } from "../components/ui/input"; import { ListPager } from "../components/ListPager"; import { OpsNotice, OpsStatus, OpsTableEmpty } from "../components/OperationsKit"; import { Tri } from "../components/triState"; import { slicePage, useLocalPage } from "../lib/list-paging"; import { useDemoIdentity } from "../lib/demo-session"; import { useProfileOverlay } from "../components/layout/ProfileOverlay"; import { useLoad } from "../lib/useLoad"; import { ApiError } from "../lib/api/http"; import { customerGet, portalPlanBoard, subAccountGetList, subAccountUpdate } from "../lib/api/bos"; 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"; const MISSING = "后端未下发"; /** 金额分 → 「¥1,234.56」;`null` 不可用 ⇒ 显「—」(§4.3 列 3 不许拿订阅价顶替)。 */ function money(cents: number | null): string { if (cents === null || !Number.isFinite(cents)) return "—"; return `¥${(cents / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; } /** 线路出口列:数组逐项一行,空集 ⇒「—」。 */ function exits(exitsValue: string[] | null) { if (!exitsValue || exitsValue.length === 0) return —; return <>{exitsValue.map((e) =>
{e}
)}; } /** * 门户 4「我的套餐」(第 9 册 §4)——真源=`/portal/plan_board@v1`。 * * 两表一次取数、由**服务端**切分与排序(C79):⛔ 前端分两次查询再自行归类, * 那会让两次查询之间的状态翻转把同一行摆进两张表。 * 主体号一律由会话派生(`/portal/plan_board@v1` 硬拒载荷里的 `customer_id`), * 所以本页⛔ 传主体号;`useParams().customerNo` 只用来做会话回退比对。 */ export function CustomerPlanPage() { const { customerNo: customerNoParam = "" } = useParams(); const identity = useDemoIdentity(); const customerNo = customerNoParam || identity?.customerNo || ""; const board = useLoad(() => portalPlanBoard({ view: "board" }), []); const data = board.data; if (board.error) { return

企业门户 · 我的套餐

我的套餐

; } if (board.loading && !data) { return

企业门户 · 我的套餐

我的套餐

套餐加载中…

正在按会话主体号读取当前套餐与往期套餐。

; } if (!data) { return

企业门户 · 我的套餐

我的套餐

套餐暂不可读

{customerNo ? `会话主体号 ${customerNo}` : "当前会话未带客户主体号"} 未取到套餐数据,请稍后重试或联系运维核实账号权限。

; } const current = data.current_rows; const history = data.history_rows; const table = (title: string, rows: PortalPlanBoardRow[], empty: string) =>

{title}

共 {rows.length} 条
{rows.map((row) => )} {!rows.length && {empty}}
套餐 / 合同运营商总金额方式线路出口期间状态
{row.plan_name}
{row.contract_no ?? "—"}
{/* 交付现状摘要(第 9 册 §4.3 行内摘要):台账口径,只读;⛔ 不占列、不开详情口 */} {row.ip_summary &&
在册 {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})` : ""}
}
{data.party.operator_name ?? } {money(row.contract_amount_cents)} {row.plan_family ? label(PLAN_FAMILY, row.plan_family) : "—"} {exits(row.line_exits)} {row.start_date ?? "—"} 至 {row.end_date ?? "—"} {row.status.label}

{data.amount_note}

; return

企业门户 · 我的套餐

{data.party.customer_name || customerNo}

所属区域:{data.party.region_path ?? } · 运营商:{data.party.operator_name ?? }

{table("当前套餐", current, "当前没有待生效或生效中的套餐。")} {table("往期套餐", history, "没有已到期或已终止的套餐。")} {data.notes.length > 0 && }
; } export function CustomerAccountsPage() { const { customerNo: customerNoParam = "" } = useParams(); const identity = useDemoIdentity(); const navigate = useNavigate(); const { openProfile } = useProfileOverlay(); const customerNo = customerNoParam || identity?.customerNo || ""; // 额度与主体名走自读口 `/customer/get@v1`(`sub_account_count`/`customer_name`),⛔ 运营侧名录。 const detail = useLoad( () => (customerNo ? customerGet({ customer_id: customerNo }) : Promise.resolve(null)), [customerNo], ); const customer = detail.data; const state = useLoad(() => subAccountGetList({ customer_id: customerNo, page: 0, page_size: 100 }), [customerNo]); const rows: SubAccountRow[] = state.data?.items ?? []; const paging = useLocalPage(rows.length); const pageRows = slicePage(rows, paging.safePage); const [editing, setEditing] = useState(null); const [name, setName] = useState(""); const [notice, setNotice] = useState(""); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); const quota = customer?.sub_account_count ?? null; const used = state.data?.total ?? null; const remaining = quota !== null && used !== null ? Math.max(0, quota - used) : null; const ownerName = useMemo(() => customer?.customer.customer_name ?? customerNo, [customer, customerNo]); async function save() { if (!editing) return; setBusy(true); setError(""); try { await subAccountUpdate({ sub_account_id: editing.sub_account_id, display_name: name }); setEditing(null); setNotice("分账号真实姓名已更新(后端回执为准)。"); state.reload(); } catch (e) { setError((e as ApiError).message || "取数失败"); } finally { setBusy(false); } } return

企业门户 · 分账号管理

{ownerName}

看看企业的分账号额度还剩多少,并为已开通的账号更新使用人姓名。
分账号额度{quota ?? } · 已用 {used ?? } · 剩余 {remaining ?? }

后端不提供分账号新增/删除路由,本页仅支持修改真实姓名。

{state.error && }
{pageRows.map((row) => {/* 三态(巡检 P1-D2):未开通/已停用的席位没有登录名属正常态,⛔ 标「后端未下发」。 */} )}{!rows.length && !state.loading && {state.error ? "分账号取数失败。" : "暂无分账号。"}}{!rows.length && state.loading && 分账号加载中…}
登录名真实姓名状态操作
{row.username?.trim() ? row.username : row.status === "not_opened" ? 未开通 : row.status === "stopped" ? 已停用 : } {seatDisplayName(row) ? <>{seatDisplayName(row)}{isSeatPlaceholder(row) && (席位占位·姓名待填)} : row.status === "not_opened" ? 未开通(开通后填写) : } {label(ACCT_STATUS, row.status) || MISSING}
{editing &&
setEditing(null)}>
event.stopPropagation()} role="dialog" aria-modal="true">

修改真实姓名

{editing.username ?? editing.sub_account_id}

{error &&

{error}

}
} {notice && setNotice("")} />}
; }