|
@@ -9,7 +9,7 @@ import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
|
|
|
import { FilterIcon, FilterSelect } from "../components/ui/filter-select";
|
|
import { FilterIcon, FilterSelect } from "../components/ui/filter-select";
|
|
|
import { useLayoutEffect, useEffect, useMemo, useRef, useState, type CSSProperties, type FormEvent, type ReactNode } from "react";
|
|
import { useLayoutEffect, useEffect, useMemo, useRef, useState, type CSSProperties, type FormEvent, type ReactNode } from "react";
|
|
|
import { createPortal } from "react-dom";
|
|
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 { Link, useParams, useSearchParams } from "react-router";
|
|
|
import { Button as FilterResetButton } from "../components/ui/button";
|
|
import { Button as FilterResetButton } from "../components/ui/button";
|
|
|
import { TreeSelect } from "../components/ui/tree-select";
|
|
import { TreeSelect } from "../components/ui/tree-select";
|
|
@@ -1011,16 +1011,11 @@ export function RegionManagementPage() {
|
|
|
export function OperatorManagementPage() {
|
|
export function OperatorManagementPage() {
|
|
|
const data = useOrganizationData(["regions", "operators", "enterprises"]);
|
|
const data = useOrganizationData(["regions", "operators", "enterprises"]);
|
|
|
const tableOverflow = useHorizontalOverflow();
|
|
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 [query, setQuery] = useState("");
|
|
|
const regionIds = useMemo(() => new Set(data.regions.map((item) => item.id)), [data.regions]);
|
|
const regionIds = useMemo(() => new Set(data.regions.map((item) => item.id)), [data.regions]);
|
|
|
const [region, setRegion, invalidRegion] = useRegionQueryFilter(regionIds);
|
|
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 || ""]),
|
|
...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">
|
|
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>} />
|
|
<PageHead eyebrow="组织与区域 / 02" title="运营商管理" description="按所属区域建立结算对手方档案,集中核对对账口径。" action={<Button onClick={() => setEditor({ kind: "operator" })}><Plus size={16} /> 新增运营商</Button>} />
|
|
|
<OrgFetchState status={status} collections={["operators"]} />
|
|
<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>
|
|
<FilterResetButton variant="ghost" size="sm" disabled={!rows.length} onClick={exportRows}><Download size={14} /> 导出 CSV</FilterResetButton>
|
|
|
</div>
|
|
</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" : ""}`}>
|
|
<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) => {
|
|
<tbody>{!status.partial.operators && pageRows.map((o) => {
|
|
|
const shareLabel = o.sharePending ? "未配置" : `${shareText(o)} · ${o.shareMode}`;
|
|
const shareLabel = o.sharePending ? "未配置" : `${shareText(o)} · ${o.shareMode}`;
|
|
|
const accountOpened = o.account !== "未开通";
|
|
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)}>
|
|
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 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,悬停可见。 */}
|
|
<td>{/* 账号列只显示状态徽标;登录名/手机号挂 title,悬停可见。 */}
|
|
|
<OrganizationAccountStatus
|
|
<OrganizationAccountStatus
|
|
|
status={o.account}
|
|
status={o.account}
|
|
@@ -1107,8 +1128,8 @@ export function OperatorManagementPage() {
|
|
|
/>
|
|
/>
|
|
|
</td>
|
|
</td>
|
|
|
<td className="org-table-actions-cell"><div className="org-table-actions is-icons">
|
|
<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: "编辑", 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); } },
|
|
{ label: "删除", danger: true, icon: <Trash2 size={15} />, onSelect: () => { setSelected(o.id); setDeleteId(o.id); } },
|
|
|
]} />
|
|
]} />
|