|
|
@@ -1,13 +1,14 @@
|
|
|
import { FilterSelect } from "../components/ui/filter-select";
|
|
|
import { PageIntro } from "../components/PageIntro";
|
|
|
-import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, Fragment } from "react";
|
|
|
+import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, Fragment, type ReactNode } from "react";
|
|
|
import { createPortal } from "react-dom";
|
|
|
-import { CircleHelp, LockKeyhole, PencilLine, Plus, Search, Trash2, X } from "lucide-react";
|
|
|
+import { CircleHelp, Globe2, Layers3, LockKeyhole, PencilLine, Plus, Search, SlidersHorizontal, Trash2, X } from "lucide-react";
|
|
|
import { Button } from "../components/ui/button";
|
|
|
import { Input } from "../components/ui/input";
|
|
|
import { TableValueText, Tri } from "../components/triState";
|
|
|
import { NOTICE_DISMISS_MS, OpsTag, OpsTableColumns, OpsTableEmpty } from "../components/OperationsKit";
|
|
|
import { ListPager } from "../components/ListPager";
|
|
|
+import { RecordTabs } from "../components/RecordTabs";
|
|
|
import { COST_BY_COMBINATION, OPERATOR_ONLY_CONFIG, WORD_FETCH_FAILED, WORD_NOT_PROVIDED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
|
|
|
import { catalogDelete, ipBandwidthTierSave, lineExitSave } from "../lib/api/bos";
|
|
|
import type { CatalogPlanRow, IpBandwidthTierListResult, LineExitListResult } from "../lib/api/types";
|
|
|
@@ -17,7 +18,6 @@ import { familyLabel, planFamilies, useCatalogLedger, useIpBandwidthTiers, useLi
|
|
|
import { exitKey, IP_TIER_UNCOMMITTED, splitExitInput } from "../domain/contract-items";
|
|
|
import type { Load } from "../lib/useLoad";
|
|
|
import { LIST_PAGE_SIZE, useLocalPage } from "../lib/list-paging";
|
|
|
-import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
|
|
|
import { isImeComposing } from "../lib/ime";
|
|
|
import { PackagePlanEditor, type EditorState } from "../components/PackagePlanEditor";
|
|
|
import "../styles/operations.css";
|
|
|
@@ -125,84 +125,69 @@ function PlanDescNote({ name, desc }: { name: string; desc: string }) {
|
|
|
|
|
|
/** 台账列宽:序号/操作列固定,其余按阅读需求分配(同合同台账口径)。
|
|
|
* 套餐说明已收进名称旁问号图标,不再单列;用途分类改由表体内分组行承载,两 Tab 同列(2026-11-15)。 */
|
|
|
-const PLAN_COLUMNS = [58, 250, 122, 122, 108, 96, 168, 84, 118] as const;
|
|
|
+const PLAN_COLUMNS = [58, 246, 114, 114, 96, 86, 150, 78, 100] as const;
|
|
|
/** 自定义档台账多两列:建档人/建档团队(固定档不加)。 */
|
|
|
-const CUSTOM_PLAN_COLUMNS = [...PLAN_COLUMNS, 132, 132] as const;
|
|
|
+const CUSTOM_PLAN_COLUMNS = [...PLAN_COLUMNS.slice(0, -1), 106, 112, 100] as const;
|
|
|
|
|
|
-/**
|
|
|
- * 自定义档台账行:与固定档同形的精简行(⛔ 档位编号/类型标签/单位后缀/货币符号)。
|
|
|
- * 列=序号/套餐(含归属客户)/年订阅价格/月结算标准/月成本/分账号额度/总带宽/订阅量/操作——
|
|
|
- * 用途分类恒为「定制化」,⛔ 再占一列;套餐说明收进名称右侧问号图标。
|
|
|
- * 三态:字段缺失=取数失败,null=未配置,⛔ 用 0/「—」冒充。
|
|
|
- */
|
|
|
-function CustomPlanRow({ plan, index, writable, readOnlyNote, onEdit, onDelete }: {
|
|
|
- plan: CatalogPlanRow; index: number; writable: boolean; readOnlyNote: string; onEdit: () => void; onDelete: () => void;
|
|
|
+/** 小屏将同一行的数据排成卡片,使用独立的可见字段名。 */
|
|
|
+function CatalogField({ label, children, className, title }: {
|
|
|
+ label: string; children: ReactNode; className?: string; title?: string;
|
|
|
+}) {
|
|
|
+ return (
|
|
|
+ <td role="cell" className={className} title={title}>
|
|
|
+ <span className="catalog-field-label" aria-hidden="true">{label}</span>
|
|
|
+ {children}
|
|
|
+ </td>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+function PlanRow({ plan, index, custom, writable, readOnlyNote, onEdit, onDelete }: {
|
|
|
+ plan: CatalogPlanRow; index: number; custom?: boolean; writable: boolean; readOnlyNote: string; onEdit: () => void; onDelete: () => void;
|
|
|
}) {
|
|
|
- return <tr>
|
|
|
- <td className="table-number">{index}</td>
|
|
|
- <td>
|
|
|
+ return <tr className="catalog-plan-row" role="row">
|
|
|
+ <td role="cell" className="catalog-sequence table-number">{index}</td>
|
|
|
+ <td role="cell" className="catalog-identity">
|
|
|
<span className="catalog-plan-name">
|
|
|
<strong className="table-cell-title" title={plan.plan_name || undefined}>{plan.plan_name || <Tri tone="missing" text={WORD_UNCONFIGURED} />}</strong>
|
|
|
- {plan.plan_desc ? <PlanDescNote name={plan.plan_name || plan.plan_id} desc={plan.plan_desc} /> : null}
|
|
|
- {plan.plan_family ? <OpsTag tone="brand">{familyLabel(plan.plan_family)}</OpsTag> : null}
|
|
|
+ {plan.plan_desc && <PlanDescNote name={plan.plan_name || plan.plan_id} desc={plan.plan_desc} />}
|
|
|
+ {plan.plan_family && <OpsTag tone="brand">{familyLabel(plan.plan_family)}</OpsTag>}
|
|
|
</span>
|
|
|
- <small className="catalog-plan-owner" title={plan.customer_name ?? undefined}>归属客户 · {plan.customer_name || WORD_UNCONFIGURED}</small>
|
|
|
+ {custom && <small className="catalog-plan-owner" title={plan.customer_name ?? undefined}>归属客户 · <TableValueText>{plan.customer_name || WORD_UNCONFIGURED}</TableValueText></small>}
|
|
|
+ </td>
|
|
|
+ <CatalogField label="年订阅价格" className="catalog-ledger-price">{ledgerMoney(plan.annual_price_cents, true)}</CatalogField>
|
|
|
+ <CatalogField label="月结算标准">{ledgerMoney(plan.monthly_settle_cents)}</CatalogField>
|
|
|
+ <CatalogField label="月成本">{ledgerCostCell(plan)}</CatalogField>
|
|
|
+ <CatalogField label="分账号额度">{intCell(plan.sub_account_quota)}</CatalogField>
|
|
|
+ <CatalogField label="总带宽">{ledgerBandwidth(plan)}</CatalogField>
|
|
|
+ <CatalogField label="订阅量" title="被合同条目或订阅引用的数量">{intCell(plan.referred_count)}</CatalogField>
|
|
|
+ {custom && <>
|
|
|
+ <CatalogField label="建档人" title={plan.created_by ?? undefined}>{plan.created_by_name || <Tri tone="missing" text={WORD_UNCONFIGURED} />}</CatalogField>
|
|
|
+ <CatalogField label="建档团队" title={plan.created_team_id ?? undefined}>{plan.created_team_name || <Tri tone="missing" text={WORD_UNCONFIGURED} />}</CatalogField>
|
|
|
+ </>}
|
|
|
+ <td role="cell" className="catalog-actions-cell">
|
|
|
+ {writable ? (
|
|
|
+ <div className="catalog-row-actions">
|
|
|
+ <button type="button" aria-label="编辑套餐" onClick={onEdit} title="编辑套餐"><PencilLine size={15} /></button>
|
|
|
+ <button type="button" className="is-danger" aria-label="删除套餐" onClick={onDelete} title="删除套餐(引用拦截由服务端判定)"><Trash2 size={15} /></button>
|
|
|
+ </div>
|
|
|
+ ) : <span className="catalog-readonly-note" title={readOnlyNote}>只读</span>}
|
|
|
</td>
|
|
|
- <td className="catalog-ledger-price">{ledgerMoney(plan.annual_price_cents, true)}</td>
|
|
|
- <td>{ledgerMoney(plan.monthly_settle_cents)}</td>
|
|
|
- <td>{ledgerCostCell(plan)}</td>
|
|
|
- <td>{intCell(plan.sub_account_quota)}</td>
|
|
|
- <td>{ledgerBandwidth(plan)}</td>
|
|
|
- <td title="后端 referred_count:被合同条目/订阅引用数">{intCell(plan.referred_count)}</td>
|
|
|
- <td title={plan.created_by ?? undefined}>{plan.created_by_name || <Tri tone="missing" text={WORD_UNCONFIGURED} />}</td>
|
|
|
- <td title={plan.created_team_id ?? undefined}>{plan.created_team_name || <Tri tone="missing" text={WORD_UNCONFIGURED} />}</td>
|
|
|
- <td>{writable
|
|
|
- ? <div className="catalog-row-actions"><button type="button" aria-label="编辑套餐" onClick={onEdit} title="编辑套餐"><PencilLine size={15} /></button><button type="button" className="is-danger" aria-label="删除套餐" onClick={onDelete} title="删除套餐(引用拦截由服务端判定)"><Trash2 size={15} /></button></div>
|
|
|
- : <small className="catalog-readonly-note">{readOnlyNote}</small>}</td>
|
|
|
</tr>;
|
|
|
}
|
|
|
|
|
|
-/** 固定档按用途分类分组的一行表头(分组落在表体内,与原型同形):分类名+「X · 口径说明」(X 为订阅方式值,不再冠「订阅方式:」)。
|
|
|
- * 用途分类由本行承载,档位行不再单列该字段(2026-11-15)。 */
|
|
|
-function PlanGroupRow({ title, hint, colSpan }: { title: string; hint?: string; colSpan: number }) {
|
|
|
- return <tr className="catalog-group-row"><td colSpan={colSpan}><strong><TableValueText>{title}</TableValueText></strong>{hint && <span>{hint}</span>}</td></tr>;
|
|
|
+function PlanGroupRow({ title, hint, colSpan }: { title: string; hint: string; colSpan: number }) {
|
|
|
+ return <tr className="catalog-group-row" role="row">
|
|
|
+ <td role="cell" colSpan={colSpan}>
|
|
|
+ <div className="catalog-group-label"><strong><TableValueText>{title}</TableValueText></strong><span>{hint}</span></div>
|
|
|
+ </td>
|
|
|
+ </tr>;
|
|
|
}
|
|
|
|
|
|
-/** 交付形态对应的订阅方式提示(`link` 可升降配、`addon` 可叠加)。 */
|
|
|
function orderModeOf(family: string) {
|
|
|
return family === "addon" ? "可叠加" : "可升降配";
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 固定档台账行:与原型「套餐配置」同形——9 列只出值,⛔ 档位编号/类型标签/单位后缀/货币符号;
|
|
|
- * 用途分类已由分组行承载,档位行不再重复出列;套餐说明收进名称右侧问号图标(`PlanDescNote`)。
|
|
|
- * 三态词照 14.4(字段缺失=取数失败,null=未配置,⛔ 用 0 冒充),金额与带宽文字口径同原型。
|
|
|
- */
|
|
|
-function FixedPlanRow({ plan, index, writable, readOnlyNote, onEdit, onDelete }: {
|
|
|
- plan: CatalogPlanRow; index: number; writable: boolean; readOnlyNote: string; onEdit: () => void; onDelete: () => void;
|
|
|
-}) {
|
|
|
- return <tr>
|
|
|
- <td className="table-number">{index}</td>
|
|
|
- <td>
|
|
|
- <span className="catalog-plan-name">
|
|
|
- <strong className="table-cell-title">{plan.plan_name || <Tri tone="missing" text={WORD_UNCONFIGURED} />}</strong>
|
|
|
- {plan.plan_desc ? <PlanDescNote name={plan.plan_name || plan.plan_id} desc={plan.plan_desc} /> : null}
|
|
|
- {plan.plan_family ? <OpsTag tone="brand">{familyLabel(plan.plan_family)}</OpsTag> : null}
|
|
|
- </span>
|
|
|
- </td>
|
|
|
- <td className="catalog-ledger-price">{ledgerMoney(plan.annual_price_cents, true)}</td>
|
|
|
- <td>{ledgerMoney(plan.monthly_settle_cents)}</td>
|
|
|
- <td>{ledgerCostCell(plan)}</td>
|
|
|
- <td>{intCell(plan.sub_account_quota)}</td>
|
|
|
- <td>{ledgerBandwidth(plan)}</td>
|
|
|
- <td title="后端 referred_count:被合同条目/订阅引用数">{intCell(plan.referred_count)}</td>
|
|
|
- <td>{writable
|
|
|
- ? <div className="catalog-row-actions"><button type="button" aria-label="编辑套餐" onClick={onEdit} title="编辑套餐"><PencilLine size={15} /></button><button type="button" className="is-danger" aria-label="删除套餐" onClick={onDelete} title="删除套餐(引用拦截由服务端判定)"><Trash2 size={15} /></button></div>
|
|
|
- : <small className="catalog-readonly-note">{readOnlyNote}</small>}</td>
|
|
|
- </tr>;
|
|
|
-}
|
|
|
-
|
|
|
-/** 配置级线路出口:出口在这里维护,合同条目只做选择(2026-11-15 裁定)。 */
|
|
|
+/** 配置级线路出口。 */
|
|
|
const CATALOG_EXIT_MAX = 200;
|
|
|
|
|
|
type ExitDraftRow = { exit_name: string; price_factor: string };
|
|
|
@@ -313,23 +298,24 @@ function LineExitPanel({ writable, exits, onNotice }: { writable: boolean; exits
|
|
|
setSaving(false);
|
|
|
}
|
|
|
}
|
|
|
- return <div className="catalog-exits">
|
|
|
- <div className="ops-toolbar catalog-exits-toolbar">
|
|
|
- <span className="catalog-exits-count">共 <b>{rows.length}</b> 条出口</span>
|
|
|
- {writable && <>
|
|
|
- <Input aria-label="新增线路出口" className="catalog-exits-input" placeholder="国家/地区名称原文,回车添加;用、,,; 可一次分隔多个" value={input} onChange={(event) => { setInput(event.target.value); setError(""); }} onKeyDown={(event) => { if (isImeComposing(event)) return; if (event.key === "Enter") { event.preventDefault(); add(); } }} />
|
|
|
+ return <section className="catalog-resource" aria-labelledby="catalog-exit-heading">
|
|
|
+ <div className="catalog-resource-heading">
|
|
|
+ <div><h2 id="catalog-exit-heading">线路出口清单</h2><p>维护合同可选的国家或地区及对应计费系数。</p></div>
|
|
|
+ {!exits.error && !(exits.loading && draft === null) && <span className="catalog-exits-count"><b>{rows.length}</b> 条</span>}
|
|
|
+ </div>
|
|
|
+ {writable && <div className="catalog-resource-controls">
|
|
|
+ <Input aria-label="新增线路出口" className="catalog-exits-input" placeholder="输入国家或地区,可用逗号分隔" value={input} onChange={(event) => { setInput(event.target.value); setError(""); }} onKeyDown={(event) => { if (isImeComposing(event)) return; if (event.key === "Enter") { event.preventDefault(); add(); } }} />
|
|
|
<Button variant="outline" size="sm" onClick={add}><Plus size={15} />添加</Button>
|
|
|
<Button size="sm" disabled={!dirty || saving} onClick={save}>{saving ? "保存中…" : "保存出口清单"}</Button>
|
|
|
- </>}
|
|
|
- </div>
|
|
|
+ </div>}
|
|
|
<div className="catalog-exits-body">
|
|
|
<div className="catalog-exits-list">
|
|
|
{exits.error ? <Tri tone="fail" text={WORD_FETCH_FAILED} title={exits.error.message} />
|
|
|
: exits.loading && draft === null ? <Tri tone="missing" text="正在载入…" />
|
|
|
: rows.length ? rows.map((row, index) => {
|
|
|
const refCount = refOf(row.exit_name)?.ref_count ?? 0;
|
|
|
- return <span key={`${exitKey(row.exit_name)}-${index}`} className={refCount > 0 ? "is-referenced" : undefined}>
|
|
|
- {row.exit_name}
|
|
|
+ return <div key={`${exitKey(row.exit_name)}-${index}`} className="catalog-exit-row">
|
|
|
+ <span className="catalog-exit-name">{row.exit_name}</span>
|
|
|
<label className="catalog-exits-factor">
|
|
|
<span>计费系数</span>
|
|
|
<input
|
|
|
@@ -351,13 +337,18 @@ function LineExitPanel({ writable, exits, onNotice }: { writable: boolean; exits
|
|
|
{writable && (refCount > 0
|
|
|
? <button type="button" className="is-locked" aria-label={`${row.exit_name} 已被引用,不能删除`} title={`${refOf(row.exit_name)?.ref_summary || "已被业务数据"}引用,不能删除;请先到合同/订阅侧处理引用`} disabled><LockKeyhole size={15} /></button>
|
|
|
: <button type="button" aria-label={`删除线路出口 ${row.exit_name}`} title="删除需二次输入确认" onClick={() => askRemove(index)}><X size={15} /></button>)}
|
|
|
- </span>;
|
|
|
+ </div>;
|
|
|
})
|
|
|
: <Tri tone="missing" text="尚未配置线路出口" />}
|
|
|
</div>
|
|
|
- <p className="catalog-exits-note">线路出口在这里维护一份清单,合同的服务构成条目<strong>只从这里选择</strong>,不再自由录入。每条出口可配<strong>计费系数</strong>(默认 1,取值大于 0 且不超过 1,最多两位小数;最终订阅价=档位价×系数)。<strong>已被合同、存量 IP 备案、派生档或订阅引用的出口不允许删除</strong>(删除入口置灰并标出引用份数);未被引用的出口删除时须<strong>手打出口名称二次确认</strong>。改系数不回写已冻结订阅。工单竣工回填不读本清单,只认该订阅合同条目的核定出口。</p>
|
|
|
+
|
|
|
{error && <p className="catalog-editor-error" role="alert">{error}</p>}
|
|
|
- <small>{writable ? "数组顺序即合同页的选择顺序;保存为整段全量替换。" : "当前账号只读;线路出口由总运营/运营主账号维护。"}</small>
|
|
|
+ {!writable && <p className="catalog-resource-note">线路出口由总运营或运营主账号维护。</p>}
|
|
|
+ <details className="catalog-resource-guide">
|
|
|
+ <summary>计费与引用规则</summary>
|
|
|
+ <p>合同条目按清单顺序列出可选出口。计费系数默认 1,取值大于 0 且不超过 1,最多两位小数。订阅价按档位价乘以系数计算,调整系数只影响后续定价。工单竣工按合同条目的核定出口回填。</p>
|
|
|
+ <p>合同、存量 IP 备案、派生档或订阅引用中的出口不可删除。删除未引用出口需输入原名称确认,保存后整份清单生效。</p>
|
|
|
+ </details>
|
|
|
</div>
|
|
|
{confirm && <div className="catalog-confirm-backdrop"><div className="catalog-confirm" role="alertdialog" aria-modal="true" aria-labelledby="catalog-exit-confirm-title">
|
|
|
<span className="catalog-confirm-icon"><Trash2 size={20} /></span>
|
|
|
@@ -368,7 +359,7 @@ function LineExitPanel({ writable, exits, onNotice }: { writable: boolean; exits
|
|
|
</label>
|
|
|
<div><button type="button" className="catalog-button catalog-button-secondary" onClick={() => setConfirm(null)}>取消</button><button type="button" className="catalog-button catalog-button-danger" disabled={confirm.typed.trim() !== confirm.name.trim()} onClick={confirmRemove}>确认删除</button></div>
|
|
|
</div></div>}
|
|
|
- </div>;
|
|
|
+ </section>;
|
|
|
}
|
|
|
|
|
|
/** 带宽档位目录(2026-11-16 业主裁定,2026-11-17 改用途)。
|
|
|
@@ -497,40 +488,47 @@ function BandwidthTierPanel({ writable, tiers, onNotice }: { writable: boolean;
|
|
|
setSaving(false);
|
|
|
}
|
|
|
}
|
|
|
- const readonlyNote = tiers.loading && !tiers.data ? "正在载入…" : tiers.error ? WORD_FETCH_FAILED : "";
|
|
|
- return <div className="catalog-tiers">
|
|
|
- <div className="catalog-tiers-head">
|
|
|
- <h2>带宽档位</h2>
|
|
|
- <span className="catalog-exits-count">共 <b>{rows.length}</b> 档</span>
|
|
|
- {writable && <div className="catalog-tier-add">
|
|
|
+
|
|
|
+ return <section className="catalog-resource" aria-labelledby="catalog-tier-heading">
|
|
|
+ <div className="catalog-resource-heading">
|
|
|
+ <div><h2 id="catalog-tier-heading">带宽档位</h2><p>设置套餐编辑时可直接选用的带宽预设。</p></div>
|
|
|
+ {!tiers.error && !(tiers.loading && draft === null) && <span className="catalog-exits-count"><b>{rows.length}</b> 档</span>}
|
|
|
+ </div>
|
|
|
+ {writable && <div className="catalog-resource-controls">
|
|
|
<Input aria-label="新增档位名称" className="catalog-tier-name-input" placeholder="档位名称,如「10 兆」" value={name} onChange={(event) => { setName(event.target.value); setError(""); }} onKeyDown={(event) => { if (isImeComposing(event)) return; if (event.key === "Enter") { event.preventDefault(); add(); } }} />
|
|
|
- <Input aria-label="新增档位兆数" className="catalog-tier-mbps-input" inputMode="numeric" placeholder={`兆数 1–${TIER_MBPS_MAX}(留空=不承诺带宽)`} value={mbps} onChange={(event) => { setMbps(event.target.value); setError(""); }} onKeyDown={(event) => { if (isImeComposing(event)) return; if (event.key === "Enter") { event.preventDefault(); add(); } }} />
|
|
|
+ <Input aria-label="新增档位兆数" className="catalog-tier-mbps-input" inputMode="numeric" placeholder="兆数(可留空)" value={mbps} onChange={(event) => { setMbps(event.target.value); setError(""); }} onKeyDown={(event) => { if (isImeComposing(event)) return; if (event.key === "Enter") { event.preventDefault(); add(); } }} />
|
|
|
<Button variant="outline" size="sm" onClick={add}><Plus size={15} />添加</Button>
|
|
|
<Button size="sm" disabled={!dirty || saving} onClick={save}>{saving ? "保存中…" : "保存档位清单"}</Button>
|
|
|
- </div>}
|
|
|
- </div>
|
|
|
- <div className="catalog-tier-list">
|
|
|
- {tiers.error ? <Tri tone="fail" text={WORD_FETCH_FAILED} title={tiers.error.message} />
|
|
|
- : tiers.loading && draft === null ? <Tri tone="missing" text="正在载入…" />
|
|
|
- : rows.length ? rows.map((row, index) => {
|
|
|
- const ref = refOf(row.bandwidth_tier_mbps);
|
|
|
- const refCount = ref?.ref_count ?? 0;
|
|
|
- return <div key={tierKeyOf(row.bandwidth_tier_mbps)} className={`catalog-tier-row${refCount > 0 ? " is-referenced" : ""}`}>
|
|
|
- {writable
|
|
|
- ? <input aria-label={`档位名称 ${index + 1}`} className="catalog-tier-rename" value={row.tier_name} maxLength={TIER_NAME_MAX} onChange={(event) => rename(index, event.target.value)} />
|
|
|
- : <span className="catalog-tier-name">{row.tier_name}</span>}
|
|
|
- <small className="catalog-tier-mbps">{row.bandwidth_tier_mbps === null ? "不承诺带宽" : `${row.bandwidth_tier_mbps} 兆`}</small>
|
|
|
- {refCount > 0 && <small className="catalog-exits-ref" title={ref?.ref_summary ?? undefined}>{`被 ${refCount} 处引用`}</small>}
|
|
|
- {writable && (refCount > 0
|
|
|
- ? <button type="button" className="is-locked" aria-label={`${row.tier_name} 已被引用,不能删除`} title={`${ref?.ref_summary || "已被存量 IP 备案"}引用,不能删除;该表已停写,需运维清理历史行后再删`} disabled><LockKeyhole size={15} /></button>
|
|
|
- : <button type="button" aria-label={`删除档位 ${row.tier_name}`} title="删除需二次输入确认" onClick={() => askRemove(index)}><X size={15} /></button>)}
|
|
|
- </div>;
|
|
|
- })
|
|
|
- : <Tri tone="missing" text="尚未配置带宽档位" />}
|
|
|
+ </div>}
|
|
|
+ <div className="catalog-exits-body">
|
|
|
+ <div className="catalog-tier-list">
|
|
|
+ {tiers.error ? <Tri tone="fail" text={WORD_FETCH_FAILED} title={tiers.error.message} />
|
|
|
+ : tiers.loading && draft === null ? <Tri tone="missing" text="正在载入…" />
|
|
|
+ : rows.length ? rows.map((row, index) => {
|
|
|
+ const ref = refOf(row.bandwidth_tier_mbps);
|
|
|
+ const refCount = ref?.ref_count ?? 0;
|
|
|
+ return <div key={tierKeyOf(row.bandwidth_tier_mbps)} className="catalog-tier-row">
|
|
|
+ {writable
|
|
|
+ ? <input aria-label={`档位名称 ${index + 1}`} className="catalog-tier-rename" value={row.tier_name} maxLength={TIER_NAME_MAX} onChange={(event) => rename(index, event.target.value)} />
|
|
|
+ : <span className="catalog-tier-name">{row.tier_name}</span>}
|
|
|
+ <small className="catalog-tier-mbps">{row.bandwidth_tier_mbps === null ? "不承诺带宽" : `${row.bandwidth_tier_mbps} 兆`}</small>
|
|
|
+ {refCount > 0 && <small className="catalog-exits-ref" title={ref?.ref_summary ?? undefined}>{`被 ${refCount} 处引用`}</small>}
|
|
|
+ {writable && (refCount > 0
|
|
|
+ ? <button type="button" className="is-locked" aria-label={`${row.tier_name} 已被引用,不能删除`} title={`${ref?.ref_summary || "已被存量 IP 备案"}引用,不能删除;该表已停写,需运维清理历史行后再删`} disabled><LockKeyhole size={15} /></button>
|
|
|
+ : <button type="button" aria-label={`删除档位 ${row.tier_name}`} title="删除需二次输入确认" onClick={() => askRemove(index)}><X size={15} /></button>)}
|
|
|
+ </div>;
|
|
|
+ })
|
|
|
+ : <Tri tone="missing" text="尚未配置带宽档位" />}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {error && <p className="catalog-editor-error" role="alert">{error}</p>}
|
|
|
+ {!writable && <p className="catalog-resource-note">带宽档位由总运营或运营主账号维护。</p>}
|
|
|
+ <details className="catalog-resource-guide">
|
|
|
+ <summary>档位取值与引用规则</summary>
|
|
|
+ <p>套餐编辑器按清单顺序提供预设。兆数取值 1–{TIER_MBPS_MAX},同一兆数只能配置一条,留空表示不承诺带宽。工单施工回填仍使用 5、10、30 兆三个固定值。</p>
|
|
|
+ <p>存量 IP 备案引用中的档位不可删除。删除未引用档位需输入原名称确认,保存后整份清单生效。</p>
|
|
|
+ </details>
|
|
|
</div>
|
|
|
- <p className="catalog-exits-note">带宽档位清单是<strong>套餐带宽权益录入的快捷预设</strong>——固定档/自定义档编辑器的「03 带宽与权益」可一键带出该档的上/下行(2026-11-17 改用途:合同级「固定 IP 条目」已下线,合同不再选档位);<strong>兆数是档位的身份,同一兆数只允许一条</strong>(改名不改身份);<strong>留空兆数=「不承诺带宽」,全表只能有一条</strong>。<strong>仍被存量 IP 备案引用的档位不允许删除</strong>(删除入口置灰,该表已停写);未被引用的档位删除时须<strong>手打档位名称二次确认</strong>。⚠️ 本清单<strong>不联动工单回填</strong>:施工回填的「带宽档位」仍是 5/10/30 封闭三值。</p>
|
|
|
- {error && <p className="catalog-editor-error" role="alert">{error}</p>}
|
|
|
- <small>{writable ? "数组顺序即档位快捷的显示顺序;保存为整段全量替换。" : `当前账号只读;带宽档位由总运营/运营主账号维护。${readonlyNote}`}</small>
|
|
|
{confirm && <div className="catalog-confirm-backdrop"><div className="catalog-confirm" role="alertdialog" aria-modal="true" aria-labelledby="catalog-tier-confirm-title">
|
|
|
<span className="catalog-confirm-icon"><Trash2 size={20} /></span>
|
|
|
<h2 id="catalog-tier-confirm-title">删除带宽档位?</h2>
|
|
|
@@ -540,7 +538,7 @@ function BandwidthTierPanel({ writable, tiers, onNotice }: { writable: boolean;
|
|
|
</label>
|
|
|
<div><button type="button" className="catalog-button catalog-button-secondary" onClick={() => setConfirm(null)}>取消</button><button type="button" className="catalog-button catalog-button-danger" disabled={confirm.typed.trim() !== confirm.name.trim()} onClick={confirmRemove}>确认删除</button></div>
|
|
|
</div></div>}
|
|
|
- </div>;
|
|
|
+ </section>;
|
|
|
}
|
|
|
|
|
|
export function PackageManagementPage() {
|
|
|
@@ -582,7 +580,6 @@ export function PackageManagementPage() {
|
|
|
/** 线路出口/带宽档:仅 exits tab 预拉;编辑器打开时再拉带宽预设(⛔ 进页三请求)。 */
|
|
|
const exits = useLineExits({ enabled: tab === "exits" });
|
|
|
const tiers = useIpBandwidthTiers({ enabled: tab === "exits" || editor !== null });
|
|
|
- const tableOverflow = useHorizontalOverflow();
|
|
|
/**
|
|
|
* 切 fixed/custom 时 useLoad 会短暂保留上一档应答(reload 不闪 loading)。
|
|
|
* 只画与当前 tab 同 `plan_kind` 的行;异种旧行一律丢掉,⛔ 闪成「假 mock」。
|
|
|
@@ -699,48 +696,56 @@ export function PackageManagementPage() {
|
|
|
setDeleteBlocks(null);
|
|
|
setDeleteError("");
|
|
|
}
|
|
|
- const planRow = (plan: CatalogPlanRow, position: number) => <CustomPlanRow
|
|
|
+ const canCreate = isCustomTab ? canWrite : canWriteFixed;
|
|
|
+ const readOnlyNote = isCustomTab ? "自定义套餐由总运营或运营主账号维护。" : OPERATOR_ONLY_CONFIG;
|
|
|
+ const planRow = (plan: CatalogPlanRow, position: number) => <PlanRow
|
|
|
key={plan.plan_id}
|
|
|
plan={plan}
|
|
|
index={rowIndexBase + position + 1}
|
|
|
- writable={canWrite}
|
|
|
- readOnlyNote="当前账号只读;自定义套餐由总运营/运营主账号维护。"
|
|
|
- onEdit={() => setEditor({ plan, owner: plan.customer_id ?? "" })}
|
|
|
- onDelete={() => { setDeleteError(""); setDeleteBlocks(null); setDeleteTarget(plan); }}
|
|
|
- />;
|
|
|
- /** 固定档:与原型同形的精简行(⛔ 档位编号/类型标签/单位后缀),分组由 fixedGroups 插在表体内。 */
|
|
|
- const fixedRow = (plan: CatalogPlanRow, position: number) => <FixedPlanRow
|
|
|
- key={plan.plan_id}
|
|
|
- plan={plan}
|
|
|
- index={rowIndexBase + position + 1}
|
|
|
- writable={canWriteFixed}
|
|
|
- readOnlyNote={OPERATOR_ONLY_CONFIG}
|
|
|
- onEdit={() => setEditor({ plan, owner: null })}
|
|
|
+ custom={isCustomTab}
|
|
|
+ writable={canCreate}
|
|
|
+ readOnlyNote={readOnlyNote}
|
|
|
+ onEdit={() => setEditor({ plan, owner: isCustomTab ? plan.customer_id ?? "" : null })}
|
|
|
onDelete={() => { setDeleteError(""); setDeleteBlocks(null); setDeleteTarget(plan); }}
|
|
|
/>;
|
|
|
+ const hasFilters = Boolean(search || (isCustomTab ? createdBy !== "all" || createdTeam !== "all" : category !== "all"));
|
|
|
+ const tabs = [
|
|
|
+ { id: "fixed", title: "固定套餐", description: "签约时均可选用的公共档位", icon: Layers3, count: catalog.error ? "—" : fixedCount },
|
|
|
+ { id: "custom", title: "自定义套餐", description: "归属指定客户的专属档位", icon: SlidersHorizontal, count: catalog.error ? "—" : customCount },
|
|
|
+ { id: "exits", title: "线路出口", description: "出口清单与带宽预设", icon: Globe2, count: !exits.error && exits.data ? exits.data.items.length : "—" },
|
|
|
+ ] as const;
|
|
|
const emptyMessage = catalog.error
|
|
|
- ? `套餐配置取数失败:${catalog.error.message}(失败关闭,不回退成演示档位)`
|
|
|
+ ? `无法加载套餐:${catalog.error.message}`
|
|
|
: awaitingTab
|
|
|
- ? "正在从目录接口读取档位…"
|
|
|
- : search || category !== "all" || createdBy !== "all" || createdTeam !== "all"
|
|
|
+ ? "正在加载套餐…"
|
|
|
+ : hasFilters
|
|
|
? "没有符合筛选条件的套餐档,可重置筛选后再看。"
|
|
|
: tab === "custom" ? "目录里还没有自定义套餐档。" : "目录里还没有固定套餐档。";
|
|
|
- return <section className="ops-page ops-page--packages package-catalog page-fill page-fill-window">
|
|
|
- <header className="catalog-page-head"><div><span className="catalog-eyebrow">PRODUCT CATALOG / 产品与订阅</span><h1>套餐配置</h1><PageIntro>准备签约时可选的公共套餐和客户专属套餐,统一维护线路出口和带宽预设。</PageIntro></div></header>
|
|
|
- <div className="ops-list-shell list-shell-fill">
|
|
|
- <div className="ops-tabs catalog-tabs" role="tablist" aria-label="套餐配置视图">
|
|
|
- <button role="tab" aria-selected={tab === "fixed"} aria-controls="catalog-fixed-panel" id="catalog-fixed-tab" className={tab === "fixed" ? "active" : ""} onClick={() => switchTab("fixed")}>固定套餐 <span>{catalog.error ? "—" : fixedCount}</span></button>
|
|
|
- <button role="tab" aria-selected={tab === "custom"} aria-controls="catalog-custom-panel" id="catalog-custom-tab" className={tab === "custom" ? "active" : ""} onClick={() => switchTab("custom")}>自定义套餐 <span>{catalog.error ? "—" : customCount}</span></button>
|
|
|
- <button role="tab" aria-selected={tab === "exits"} aria-controls="catalog-exits-panel" id="catalog-exits-tab" className={tab === "exits" ? "active" : ""} onClick={() => switchTab("exits")}>线路出口 <span>{exits.error ? "—" : exits.data ? exits.data.items.length : "—"}</span></button>
|
|
|
+ return <section className="ops-page ops-page--packages package-catalog">
|
|
|
+ <header className="catalog-page-head">
|
|
|
+ <h1>套餐配置</h1>
|
|
|
+ <PageIntro>管理签约可选的套餐、订阅价格和交付配置。</PageIntro>
|
|
|
+ </header>
|
|
|
+ <RecordTabs prefix="catalog" className="catalog-tabs" label="套餐配置视图" active={tab} onChange={switchTab}
|
|
|
+ tabs={tabs.map(({ id, title, description, count, icon: Icon }) => ({
|
|
|
+ id, count, label: <>
|
|
|
+ <span className="catalog-tab-icon"><Icon size={18} aria-hidden="true" /></span>
|
|
|
+ <span className="catalog-tab-copy"><strong>{title}</strong><small>{description}</small></span>
|
|
|
+ </>,
|
|
|
+ }))}
|
|
|
+ />
|
|
|
+ {tabs.filter(({ id }) => id !== tab).map(({ id }) => (
|
|
|
+ <div key={id} id={`catalog-panel-${id}`} role="tabpanel" aria-labelledby={`catalog-tab-${id}`} hidden />
|
|
|
+ ))}
|
|
|
+ {tab === "exits"
|
|
|
+ ? <div id="catalog-panel-exits" role="tabpanel" aria-labelledby="catalog-tab-exits" className="catalog-exits-panel">
|
|
|
+ <LineExitPanel writable={canWriteExits} exits={exits} onNotice={(message) => { setFailure(""); setNotice(message); }} />
|
|
|
+ <BandwidthTierPanel writable={canWriteExits} tiers={tiers} onNotice={(message) => { setFailure(""); setNotice(message); }} />
|
|
|
</div>
|
|
|
- {tab === "exits"
|
|
|
- ? <div id="catalog-exits-panel" role="tabpanel" aria-labelledby="catalog-exits-tab" className="catalog-exits-panel">
|
|
|
- <LineExitPanel writable={canWriteExits} exits={exits} onNotice={(message) => { setFailure(""); setNotice(message); }} />
|
|
|
- <BandwidthTierPanel writable={canWriteExits} tiers={tiers} onNotice={(message) => { setFailure(""); setNotice(message); }} />
|
|
|
- </div>
|
|
|
- : <div id={tab === "custom" ? "catalog-custom-panel" : "catalog-fixed-panel"} role="tabpanel" aria-labelledby={tab === "custom" ? "catalog-custom-tab" : "catalog-fixed-tab"} className="catalog-tabpanel">
|
|
|
- <div className="ops-toolbar">
|
|
|
- <label className="ops-search"><Search size={17} /><Input aria-label="搜索套餐" placeholder={isCustomTab ? "搜索名称、带宽、说明或归属客户" : "搜索名称、分类、带宽、说明或归属客户"} value={search} onChange={(event) => { setSearch(event.target.value); resetPage(); }} />{search && <button type="button" aria-label="清空搜索" onClick={() => { setSearch(""); resetPage(); }}><X size={15} /></button>}</label>
|
|
|
+ : <div id={`catalog-panel-${tab}`} role="tabpanel" aria-labelledby={`catalog-tab-${tab}`} className="catalog-tabpanel">
|
|
|
+ <div className="catalog-ledger-toolbar">
|
|
|
+ <div className="catalog-filters">
|
|
|
+ <label className="ops-search"><Search size={17} aria-hidden="true" /><Input aria-label="搜索套餐" placeholder={isCustomTab ? "搜索套餐名称或归属客户" : "搜索套餐名称、带宽或说明"} value={search} onChange={(event) => { setSearch(event.target.value); resetPage(); }} />{search && <button type="button" aria-label="清空搜索" onClick={() => { setSearch(""); resetPage(); }}><X size={15} aria-hidden="true" /></button>}</label>
|
|
|
{/* 自定义档恒为「定制化」,没有可选项 ⇒ 该 Tab 不出分类筛选(⛔ 给一个筛完必空的控件)。 */}
|
|
|
{!isCustomTab && <FilterSelect icon="type" aria-label="交付形态筛选" value={category} onChange={(event) => { setCategory(event.target.value); resetPage(); }}><option value="all">全部交付形态</option>{planFamilies.map((item) => <option key={item.code} value={item.code}>{item.name}</option>)}</FilterSelect>}
|
|
|
{/* R-14:自定义档越滚越多 ⇒ 按建档团队/建档人收敛。选项取服务端 facets,⛔ 当前页行。
|
|
|
@@ -755,33 +760,34 @@ export function PackageManagementPage() {
|
|
|
{creatorOptions.map((item) => <option key={item.value} value={item.value}>{item.label}({item.count})</option>)}
|
|
|
</FilterSelect>
|
|
|
</>}
|
|
|
- {(search || (!isCustomTab && category !== "all") || (isCustomTab && (createdBy !== "all" || createdTeam !== "all"))) && <Button variant="ghost" size="sm" onClick={resetFilters}>重置筛选</Button>}
|
|
|
- <span className="catalog-ledger-note">{tab === "custom" ? "自定义套餐只属于一个客户,不进公共目录" : "固定套餐为公共档,所有客户可选"}</span>
|
|
|
- {/* 新增入口跟着 Tab 走:固定档只有总运营能新建,自定义套餐由总运营/运营主账号建。 */}
|
|
|
- {tab === "fixed"
|
|
|
- ? (canWriteFixed
|
|
|
- ? <button type="button" className="catalog-button catalog-button-primary catalog-toolbar-action" onClick={() => setEditor({ owner: null })}><Plus size={17} />新增固定套餐</button>
|
|
|
- : <span className="catalog-head-note catalog-toolbar-action">区域运营不能配置公共固定档</span>)
|
|
|
- : (canWrite
|
|
|
- ? <button type="button" className="catalog-button catalog-button-primary catalog-toolbar-action" onClick={() => setEditor({ owner: "", planKind: "custom" })}><Plus size={17} />新增自定义套餐</button>
|
|
|
- : <span className="catalog-head-note catalog-toolbar-action">当前账号只读;自定义套餐由总运营/运营主账号维护。</span>)}
|
|
|
+ {hasFilters && <Button variant="ghost" size="sm" onClick={resetFilters}>重置筛选</Button>}
|
|
|
</div>
|
|
|
- <div ref={tableOverflow.ref} tabIndex={0} role="region" aria-label="套餐档位台账,可横向滚动查看字段" className={`measured-table-scroll ops-table-wrap catalog-table-wrap${tableOverflow.overflow ? " has-horizontal-overflow" : ""}${tableOverflow.canScrollLeft ? " can-scroll-left" : ""}${tableOverflow.canScrollRight ? " can-scroll-right" : ""}`}>
|
|
|
- <table className="ops-table catalog-ledger">
|
|
|
- <OpsTableColumns widths={isCustomTab ? CUSTOM_PLAN_COLUMNS : PLAN_COLUMNS} />
|
|
|
- <thead><tr><th>序号</th><th>套餐</th><th>年订阅价格</th><th>月结算标准</th><th>月成本</th><th>分账号额度</th><th>总带宽</th><th>订阅量</th>{isCustomTab && <><th>建档人</th><th>建档团队</th></>}<th>操作</th></tr></thead>
|
|
|
- <tbody>
|
|
|
- {tab === "fixed"
|
|
|
- ? fixedGroups.map((group) => <Fragment key={group.name}><PlanGroupRow title={group.name} hint={group.hint} colSpan={ledgerColSpan} />{group.entries.map(({ plan, position }) => fixedRow(plan, position))}</Fragment>)
|
|
|
- : pageRows.map((plan, index) => planRow(plan, index))}
|
|
|
- {(!catalog.error && visible.length === 0) && <OpsTableEmpty colSpan={ledgerColSpan}>{emptyMessage}</OpsTableEmpty>}
|
|
|
- {catalog.error && <OpsTableEmpty colSpan={ledgerColSpan}>{emptyMessage}</OpsTableEmpty>}
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- </div>
|
|
|
- <ListPager total={listTotal} page={paging.safePage} pageSize={paging.pageSize} onPageChange={setPage} unit="档" />
|
|
|
- </div>}
|
|
|
- </div>
|
|
|
+ {canCreate ? (
|
|
|
+ <button type="button" className="catalog-button catalog-button-primary" onClick={() => setEditor(isCustomTab ? { owner: "", planKind: "custom" } : { owner: null })}>
|
|
|
+ <Plus size={16} aria-hidden="true" />{isCustomTab ? "新增自定义套餐" : "新增固定套餐"}
|
|
|
+ </button>
|
|
|
+ ) : <span className="catalog-head-note"><LockKeyhole size={14} aria-hidden="true" />{readOnlyNote}</span>}
|
|
|
+ </div>
|
|
|
+ <div tabIndex={0} role="region" aria-label="套餐档位列表" className="ops-table-wrap catalog-table-wrap">
|
|
|
+ <table role="table" className={`ops-table catalog-ledger${isCustomTab ? " catalog-ledger-custom" : ""}`} aria-busy={awaitingTab && !catalog.error}>
|
|
|
+ <OpsTableColumns widths={isCustomTab ? CUSTOM_PLAN_COLUMNS : PLAN_COLUMNS} />
|
|
|
+ <thead role="rowgroup"><tr role="row">{[
|
|
|
+ "序号", "套餐", "年订阅价格", "月结算标准", "月成本", "分账号额度", "总带宽", "订阅量",
|
|
|
+ ...(isCustomTab ? ["建档人", "建档团队"] : []),
|
|
|
+ "操作",
|
|
|
+ ].map((column) => <th role="columnheader" scope="col" key={column}>{column}</th>)}</tr></thead>
|
|
|
+ <tbody role="rowgroup">
|
|
|
+ {tab === "fixed"
|
|
|
+ ? fixedGroups.map((group) => <Fragment key={group.name}><PlanGroupRow title={group.name} hint={group.hint} colSpan={ledgerColSpan} />{group.entries.map(({ plan, position }) => planRow(plan, position))}</Fragment>)
|
|
|
+ : pageRows.map((plan, index) => planRow(plan, index))}
|
|
|
+ {(catalog.error || visible.length === 0) && <OpsTableEmpty colSpan={ledgerColSpan}>
|
|
|
+ <div className="catalog-empty"><span>{emptyMessage}</span>{catalog.error && <Button variant="outline" size="sm" onClick={catalog.reload}>重试</Button>}</div>
|
|
|
+ </OpsTableEmpty>}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ <ListPager total={listTotal} page={paging.safePage} pageSize={paging.pageSize} onPageChange={setPage} unit="档" />
|
|
|
+ </div>}
|
|
|
{notice && <div className="catalog-toast" role="status"><span>{notice}</span><button aria-label="关闭提示" onClick={() => setNotice("")}><X size={16} /></button></div>}
|
|
|
{failure && <div className="catalog-toast" role="alert"><span>{failure}</span><button aria-label="关闭提示" onClick={() => setFailure("")}><X size={16} /></button></div>}
|
|
|
{editor && <PackagePlanEditor key={editor.plan?.plan_id ?? `new-${editor.owner ?? "fixed"}`} state={editor} tiers={tiers} onClose={() => setEditor(null)} onSaved={saved} />}
|