|
@@ -10,18 +10,18 @@
|
|
|
* `bos.customer.view`,且行集由后端按主体收窄,客户看不到别家档案。
|
|
* `bos.customer.view`,且行集由后端按主体收窄,客户看不到别家档案。
|
|
|
*/
|
|
*/
|
|
|
import { useState, type FormEvent } from "react";
|
|
import { useState, type FormEvent } from "react";
|
|
|
-import { useNavigate, useParams } from "react-router";
|
|
|
|
|
|
|
+import { Link, useParams } from "react-router";
|
|
|
import { FetchError } from "../components/fetchError";
|
|
import { FetchError } from "../components/fetchError";
|
|
|
-import { ArrowDownRight, ArrowRight, Building2, History, Info, KeyRound, Layers3, MapPin, PencilLine, Search, UserRound, UsersRound } from "lucide-react";
|
|
|
|
|
|
|
+import { ArrowDownRight, ArrowRight, Building2, History, Info, Layers3, MapPin, PencilLine, Search, UserRound, UsersRound, X } 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 { SearchInput } from "../components/ui/search-input";
|
|
import { SearchInput } from "../components/ui/search-input";
|
|
|
|
|
+import { PageIntro } from "../components/PageIntro";
|
|
|
import { ListPager } from "../components/ListPager";
|
|
import { ListPager } from "../components/ListPager";
|
|
|
import { OpsDialog, OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty } from "../components/OperationsKit";
|
|
import { OpsDialog, 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";
|
|
|
-import { useProfileOverlay } from "../components/layout/ProfileOverlay";
|
|
|
|
|
import { useLoad } from "../lib/useLoad";
|
|
import { useLoad } from "../lib/useLoad";
|
|
|
import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
|
|
import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
|
|
|
import { ApiError } from "../lib/api/http";
|
|
import { ApiError } from "../lib/api/http";
|
|
@@ -31,7 +31,8 @@ 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";
|
|
import "../styles/portal-plans.css";
|
|
|
-import "../styles/record-detail.css";
|
|
|
|
|
|
|
+import "../styles/orders.css";
|
|
|
|
|
+import "../styles/work-order-ledger.css";
|
|
|
import "../styles/portal-accounts.css";
|
|
import "../styles/portal-accounts.css";
|
|
|
|
|
|
|
|
const MISSING = "后端未下发";
|
|
const MISSING = "后端未下发";
|
|
@@ -143,8 +144,6 @@ export function CustomerPlanPage() {
|
|
|
export function CustomerAccountsPage() {
|
|
export function CustomerAccountsPage() {
|
|
|
const { customerNo: customerNoParam = "" } = useParams();
|
|
const { customerNo: customerNoParam = "" } = useParams();
|
|
|
const identity = useDemoIdentity();
|
|
const identity = useDemoIdentity();
|
|
|
- const navigate = useNavigate();
|
|
|
|
|
- const { openProfile } = useProfileOverlay();
|
|
|
|
|
const customerNo = customerNoParam || identity?.customerNo || "";
|
|
const customerNo = customerNoParam || identity?.customerNo || "";
|
|
|
const detail = useLoad(
|
|
const detail = useLoad(
|
|
|
() => (customerNo ? customerGet({ customer_id: customerNo }) : Promise.resolve(null)),
|
|
() => (customerNo ? customerGet({ customer_id: customerNo }) : Promise.resolve(null)),
|
|
@@ -162,8 +161,9 @@ export function CustomerAccountsPage() {
|
|
|
const rows = state.data?.items ?? [];
|
|
const rows = state.data?.items ?? [];
|
|
|
const total = state.data?.total ?? 0;
|
|
const total = state.data?.total ?? 0;
|
|
|
const safePage = clampPage(page, total, pageSize);
|
|
const safePage = clampPage(page, total, pageSize);
|
|
|
- const ownerName = customer?.customer.customer_name || customerNo || "下属分账号";
|
|
|
|
|
|
|
+ const ownerName = customer?.customer.customer_name;
|
|
|
const regions = customer?.region_mounts.map((mount) => mount.path_name || mount.parent_node_id).join("、");
|
|
const regions = customer?.region_mounts.map((mount) => mount.path_name || mount.parent_node_id).join("、");
|
|
|
|
|
+ const missingDetail = detail.loading ? "读取中…" : detail.error ? "暂未获取" : "未配置";
|
|
|
const [editing, setEditing] = useState<SubAccountRow | null>(null);
|
|
const [editing, setEditing] = useState<SubAccountRow | null>(null);
|
|
|
const [name, setName] = useState("");
|
|
const [name, setName] = useState("");
|
|
|
const [notice, setNotice] = useState("");
|
|
const [notice, setNotice] = useState("");
|
|
@@ -192,47 +192,58 @@ export function CustomerAccountsPage() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return <section className="ops-page portal-accounts-page page-fill page-fill-window">
|
|
|
|
|
- <header className="customer-record-masthead portal-accounts-masthead">
|
|
|
|
|
- <span className="portal-accounts-emblem"><UsersRound size={26} strokeWidth={1.6} aria-hidden="true" /></span>
|
|
|
|
|
|
|
+ return <section className="order-page work-order-ledger portal-accounts-page page-fill page-fill-window">
|
|
|
|
|
+ <header className="order-heading">
|
|
|
<div>
|
|
<div>
|
|
|
- <p className="customer-record-id">下属分账号</p>
|
|
|
|
|
- <h1 className="customer-record-title">{ownerName}</h1>
|
|
|
|
|
- <p className="portal-accounts-intro">查看分账号的使用情况,维护账号与使用人的对应关系。</p>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="portal-accounts-actions">
|
|
|
|
|
- <Button variant="outline" onClick={openProfile}><KeyRound size={14} />修改登录密码</Button>
|
|
|
|
|
- <Button variant="ghost" onClick={() => navigate("/workspace/plan")}>查看我的套餐<ArrowRight size={15} /></Button>
|
|
|
|
|
|
|
+ <h1>下属分账号</h1>
|
|
|
|
|
+ <PageIntro>{ownerName ? `查看${ownerName}的分账号,维护使用人姓名。` : "查看本公司的分账号,维护使用人姓名。"}</PageIntro>
|
|
|
</div>
|
|
</div>
|
|
|
</header>
|
|
</header>
|
|
|
|
|
|
|
|
{detail.error && <FetchError message={detail.error.message} onRetry={detail.reload} />}
|
|
{detail.error && <FetchError message={detail.error.message} onRetry={detail.reload} />}
|
|
|
- <dl className="customer-record-metrics portal-accounts-metrics" aria-label="分账号概况">
|
|
|
|
|
- <div>
|
|
|
|
|
- <dt><UsersRound size={16} aria-hidden="true" />分账号总数</dt>
|
|
|
|
|
- <dd>{customer ? <><strong>{customer.sub_account_count}</strong><span>个</span></> : <span className="table-placeholder">{detail.loading ? "读取中…" : "暂未获取"}</span>}</dd>
|
|
|
|
|
|
|
+ <div className="work-order-ledger-summary work-order-queue-summary portal-accounts-metrics" role="group" aria-label="分账号概况" data-count="3">
|
|
|
|
|
+ <div className="work-order-metric work-order-metric-total">
|
|
|
|
|
+ <span className="work-order-metric-icon"><UsersRound size={18} aria-hidden="true" /></span>
|
|
|
|
|
+ <span className="work-order-metric-body">
|
|
|
|
|
+ <span>分账号总数</span>
|
|
|
|
|
+ <strong>{customer?.sub_account_count?.toLocaleString("zh-CN") ?? (detail.loading ? "…" : "—")}</strong>
|
|
|
|
|
+ </span>
|
|
|
</div>
|
|
</div>
|
|
|
- <div>
|
|
|
|
|
- <dt><MapPin size={16} aria-hidden="true" />所属区域</dt>
|
|
|
|
|
- <dd className={regions ? "portal-accounts-meta" : "portal-accounts-meta table-placeholder"}>{regions || (detail.loading ? "读取中…" : "未配置")}</dd>
|
|
|
|
|
|
|
+ <div className="work-order-metric">
|
|
|
|
|
+ <span className="work-order-metric-icon"><MapPin size={18} aria-hidden="true" /></span>
|
|
|
|
|
+ <span className="work-order-metric-body">
|
|
|
|
|
+ <span>所属区域</span>
|
|
|
|
|
+ <span className="portal-accounts-meta">{regions || missingDetail}</span>
|
|
|
|
|
+ </span>
|
|
|
</div>
|
|
</div>
|
|
|
- <div>
|
|
|
|
|
- <dt><Building2 size={16} aria-hidden="true" />运营商</dt>
|
|
|
|
|
- <dd className={customer?.customer.operator_name ? "portal-accounts-meta" : "portal-accounts-meta table-placeholder"}>{customer?.customer.operator_name || (detail.loading ? "读取中…" : "未配置")}</dd>
|
|
|
|
|
|
|
+ <div className="work-order-metric">
|
|
|
|
|
+ <span className="work-order-metric-icon"><Building2 size={18} aria-hidden="true" /></span>
|
|
|
|
|
+ <span className="work-order-metric-body">
|
|
|
|
|
+ <span>运营商</span>
|
|
|
|
|
+ <span className="portal-accounts-meta">{customer?.customer.operator_name || missingDetail}</span>
|
|
|
|
|
+ </span>
|
|
|
</div>
|
|
</div>
|
|
|
- </dl>
|
|
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <div className="ops-list-shell list-shell-fill">
|
|
|
|
|
- <div className="ops-toolbar">
|
|
|
|
|
- <label className="ops-search portal-accounts-search">
|
|
|
|
|
|
|
+ <section className="order-list-shell list-shell-fill" aria-label="下属分账号">
|
|
|
|
|
+ <div className="ops-toolbar order-filters">
|
|
|
|
|
+ <label className="ops-search order-search portal-accounts-search">
|
|
|
<Search size={17} aria-hidden="true" />
|
|
<Search size={17} aria-hidden="true" />
|
|
|
<SearchInput aria-label="搜索登录名、使用人或网络侧账号" placeholder="搜索账号或使用人" value={query} onCommit={search} />
|
|
<SearchInput aria-label="搜索登录名、使用人或网络侧账号" placeholder="搜索账号或使用人" value={query} onCommit={search} />
|
|
|
|
|
+ {query && <button type="button" aria-label="清空搜索" onClick={() => search("")}><X size={15} /></button>}
|
|
|
</label>
|
|
</label>
|
|
|
{query && <Button variant="ghost" size="sm" onClick={() => search("")}>重置筛选</Button>}
|
|
{query && <Button variant="ghost" size="sm" onClick={() => search("")}>重置筛选</Button>}
|
|
|
|
|
+ <Link className="ops-table-action portal-accounts-plan-link" to="/workspace/plan">查看我的套餐<ArrowRight size={15} /></Link>
|
|
|
</div>
|
|
</div>
|
|
|
{state.error && <FetchError message={state.error.message} onRetry={state.reload} />}
|
|
{state.error && <FetchError message={state.error.message} onRetry={state.reload} />}
|
|
|
- <div ref={tableOverflow.ref} tabIndex={0} role="region" aria-label="下属分账号列表" className={`ops-table-wrap measured-table-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}`}>
|
|
|
|
|
- <table className="ops-table ops-table-sticky-action portal-accounts-table">
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ ref={tableOverflow.ref}
|
|
|
|
|
+ tabIndex={0}
|
|
|
|
|
+ role="region"
|
|
|
|
|
+ aria-label="下属分账号列表"
|
|
|
|
|
+ className={`ops-table-wrap measured-table-scroll order-ledger-scroll${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`}
|
|
|
|
|
+ >
|
|
|
|
|
+ <table className="order-table order-ledger portal-accounts-table">
|
|
|
<OpsTableColumns widths={[245, 170, 190, 235, 110, 122]} />
|
|
<OpsTableColumns widths={[245, 170, 190, 235, 110, 122]} />
|
|
|
<thead><tr>{["登录账号", "使用人", "用途", "网络侧账号", "状态", "操作"].map((column) => <th key={column} scope="col">{column}</th>)}</tr></thead>
|
|
<thead><tr>{["登录账号", "使用人", "用途", "网络侧账号", "状态", "操作"].map((column) => <th key={column} scope="col">{column}</th>)}</tr></thead>
|
|
|
<tbody>
|
|
<tbody>
|
|
@@ -243,7 +254,7 @@ export function CustomerAccountsPage() {
|
|
|
{row.username?.trim() || (row.status === "not_opened" ? "未开通" : row.status === "stopped" ? "已停用" : "未配置")}
|
|
{row.username?.trim() || (row.status === "not_opened" ? "未开通" : row.status === "stopped" ? "已停用" : "未配置")}
|
|
|
</span>
|
|
</span>
|
|
|
</td>
|
|
</td>
|
|
|
- <td>
|
|
|
|
|
|
|
+ <td title={row.display_name || undefined}>
|
|
|
<span className={!seatDisplayName(row) || isSeatPlaceholder(row) ? "table-placeholder" : undefined}>{seatDisplayName(row) || (row.status === "not_opened" ? "未开通" : "未填写")}</span>
|
|
<span className={!seatDisplayName(row) || isSeatPlaceholder(row) ? "table-placeholder" : undefined}>{seatDisplayName(row) || (row.status === "not_opened" ? "未开通" : "未填写")}</span>
|
|
|
{isSeatPlaceholder(row) && <small>姓名待填写</small>}
|
|
{isSeatPlaceholder(row) && <small>姓名待填写</small>}
|
|
|
</td>
|
|
</td>
|
|
@@ -251,7 +262,7 @@ export function CustomerAccountsPage() {
|
|
|
<td title={row.net_account || undefined}>{row.net_account || <span className="table-placeholder">未配置</span>}</td>
|
|
<td title={row.net_account || undefined}>{row.net_account || <span className="table-placeholder">未配置</span>}</td>
|
|
|
<td><OpsStatus tone={row.status === "active" || row.status === "normal" ? "success" : row.status === "stopped" || row.status === "disabled" ? "neutral" : "warning"}>{label(ACCT_STATUS, row.status) || MISSING}</OpsStatus></td>
|
|
<td><OpsStatus tone={row.status === "active" || row.status === "normal" ? "success" : row.status === "stopped" || row.status === "disabled" ? "neutral" : "warning"}>{label(ACCT_STATUS, row.status) || MISSING}</OpsStatus></td>
|
|
|
<td><div className="ops-inline-actions">
|
|
<td><div className="ops-inline-actions">
|
|
|
- <button type="button" onClick={() => { setEditing(row); setName(row.display_name ?? ""); setError(""); }}><PencilLine size={14} />修改姓名</button>
|
|
|
|
|
|
|
+ <button className="ops-table-action" type="button" onClick={() => { setEditing(row); setName(row.display_name ?? ""); setError(""); }}><PencilLine size={14} />修改姓名</button>
|
|
|
</div></td>
|
|
</div></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
))}
|
|
))}
|
|
@@ -260,7 +271,7 @@ export function CustomerAccountsPage() {
|
|
|
</table>
|
|
</table>
|
|
|
</div>
|
|
</div>
|
|
|
<ListPager total={total} page={safePage} pageSize={pageSize} onPageChange={setPage} onPageSizeChange={(size) => { setPageSize(size); setPage(0); }} unit="个" />
|
|
<ListPager total={total} page={safePage} pageSize={pageSize} onPageChange={setPage} onPageSizeChange={(size) => { setPageSize(size); setPage(0); }} unit="个" />
|
|
|
- </div>
|
|
|
|
|
|
|
+ </section>
|
|
|
|
|
|
|
|
{editing && <OpsDialog title="修改使用人姓名" onClose={() => { if (!busy) setEditing(null); }} className="portal-account-dialog">
|
|
{editing && <OpsDialog title="修改使用人姓名" onClose={() => { if (!busy) setEditing(null); }} className="portal-account-dialog">
|
|
|
<form onSubmit={(event) => void save(event)}>
|
|
<form onSubmit={(event) => void save(event)}>
|