/** * 施工回填「一账号一通路」行模型与校验/提交适配。 * 通路=客户侧接入(含接入口令)→ 路径/出口 → 境外出口资源;共享=挂靠前序境外资源(可选再共用口令)。 */ import type { BackfillInIp, BackfillInRoute, ConstructionGuide, IpRow, RouteRow, } from "./api/ticket"; export const BANDWIDTH_TIERS = [5, 10, 30]; export const IP_TYPES: { code: string; label: string }[] = [ { code: "fixed_ip", label: "固定 IP" }, { code: "nat_forward", label: "NAT 共享出口" }, ]; export const OVERSEAS_IP_MAX_ROWS = 4; export const ROUTE_MAX_ROWS = 12; export const PATH_MAX_ROWS = ROUTE_MAX_ROWS; export type PathDraft = { key: string; open_this_time: boolean; /** 空=独立境外资源;非空=挂靠主通路 key */ share_egress_of: string; /** 与 share_egress_of 联用:同时共用主通路接入口令 */ share_credential: boolean; require_cpid: boolean; tunnel_encap: "none" | "vxlan"; sub_account_id: string; network_account_name: string; intranet_ip: string; subnet_mask: string; gateway: string; vlan: string; pin: string; cpid: string; proxy_host: string; proxy_port: string; vni: string; src_endpoint: string; dst_endpoint: string; egress_pop: string; down_mbps: string; up_mbps: string; overseas_ip: string; ip_type: string; bandwidth_mbps: string; pin_registered?: boolean; cpid_registered?: boolean; }; /** @deprecated 兼容旧调用;新代码用 PathDraft */ export type RouteRowDraft = PathDraft & { /* alias shape */ }; export type BackfillIpRowDraft = { key: string; egress: string; overseas_ip: string; ip_type: string; bandwidth_mbps: string; pin: string; cpid: string; sub_account_ids?: string[]; }; let seq = 0; const key = (p: string) => `${p}-${(seq += 1)}`; export const newPathDraft = (): PathDraft => ({ key: key("path"), open_this_time: true, share_egress_of: "", share_credential: false, require_cpid: false, tunnel_encap: "none", sub_account_id: "", network_account_name: "", intranet_ip: "", subnet_mask: "", gateway: "", vlan: "", pin: "", cpid: "", proxy_host: "", proxy_port: "", vni: "", src_endpoint: "", dst_endpoint: "", egress_pop: "", down_mbps: "", up_mbps: "", overseas_ip: "", ip_type: "fixed_ip", bandwidth_mbps: "5", }); export const newRouteRow = newPathDraft; export const newBackfillIpRow = (ip_type = "fixed_ip", bandwidth_mbps = "5"): BackfillIpRowDraft => ({ key: key("bip"), egress: "", overseas_ip: "", ip_type, bandwidth_mbps, pin: "", cpid: "", }); export function exitNormKey(s: string): string { return s.replace(/\s+/g, "").toLowerCase(); } const blank = (v: string | undefined | null) => !v || !v.trim(); const posNum = (v: string) => /^\d+(\.\d+)?$/.test(v.trim()) && Number(v) > 0; function isIpLike(v: string): boolean { const raw = v.trim().replace(/\/\d+$/, ""); if (raw.includes(":")) return true; const m = raw.split("."); return m.length === 4 && m.every((o) => /^\d{1,3}$/.test(o) && Number(o) <= 255); } function isVoidPath(r: PathDraft): boolean { return blank(r.sub_account_id) && blank(r.intranet_ip) && blank(r.overseas_ip) && blank(r.proxy_host); } /** 套餐账号数 → 预生成通路行数(1‥PATH_MAX_ROWS)。 */ export function suggestPathCount(guide: ConstructionGuide | null | undefined): number { const raw = Number( guide?.defaults?.suggest_seat_count ?? guide?.plan?.quota_slots ?? guide?.plan?.sub_account_quota ?? 0, ); const n = Number.isFinite(raw) ? Math.trunc(raw) : 0; if (n < 1) return 1; return Math.min(n, PATH_MAX_ROWS); } /** 按套餐席位数预生成空白通路(可带核定出口/建议带宽)。 */ export function seedPathRows( count: number, opts?: { egress_pop?: string; down_mbps?: string; up_mbps?: string; bandwidth_mbps?: string; }, ): PathDraft[] { const n = Math.max(1, Math.min(Math.trunc(count) || 1, PATH_MAX_ROWS)); return Array.from({ length: n }, () => { const d = newPathDraft(); if (opts?.egress_pop) d.egress_pop = opts.egress_pop; if (opts?.down_mbps) d.down_mbps = opts.down_mbps; if (opts?.up_mbps) d.up_mbps = opts.up_mbps; if (opts?.bandwidth_mbps) d.bandwidth_mbps = opts.bandwidth_mbps; return d; }); } /** 通路卡片收起时的一行摘要(展示用 1 基序号由调用方拼)。 */ export function pathCardSummary(r: PathDraft, paths: PathDraft[]): string { const bits: string[] = []; const acct = r.network_account_name.trim() || r.sub_account_id.trim(); bits.push(acct || "未填账号"); if (r.intranet_ip.trim()) bits.push(r.intranet_ip.trim()); if (r.share_egress_of.trim()) { const p = paths.find((x) => x.key === r.share_egress_of); const n = p ? paths.indexOf(p) + 1 : 0; bits.push(n > 0 ? `挂靠通路 ${n}` : "挂靠前序"); if (p?.overseas_ip.trim()) bits.push(p.overseas_ip.trim()); } else { if (r.overseas_ip.trim()) bits.push(r.overseas_ip.trim()); else if (r.egress_pop.trim()) bits.push(r.egress_pop.trim()); } if (r.pin.trim() || r.pin_registered) bits.push("PIN 已填"); return bits.join(" · "); } /** 通路几乎空白:默认展开;已有内容且多条时默认收起。 */ export function isPathSparse(r: PathDraft): boolean { return !r.sub_account_id.trim() && !r.intranet_ip.trim() && !r.overseas_ip.trim() && !r.network_account_name.trim() && !r.share_egress_of.trim(); } /** 主通路=未挂靠前序境外资源的独立通路(席位须全开,不再按「本次开通」过滤)。 */ export function primaryPaths(paths: PathDraft[]): PathDraft[] { return paths.filter((p) => !p.share_egress_of.trim()); } export function validatePathRows( paths: PathDraft[], require: boolean, allowedExits: string[] = [], involveOverseasIp = true, ): string | null { if (paths.length > PATH_MAX_ROWS) return `网络通路最多 ${PATH_MAX_ROWS} 条。`; /** * 2026-11-23 定案:套餐席位=网络侧必须开通的通路;成功/部分成功回填须**全席填齐**。 * 「一次只开一部分账号」原口径混淆了系统登录分账号与网络侧席位,已废止。 */ if (require) { for (let i = 0; i < paths.length; i++) { if (isVoidPath(paths[i]) || isPathSparse(paths[i])) { return `套餐 ${paths.length} 席须全部开通回填,第 ${i + 1} 条通路尚未填写。`; } } } const kept = require ? paths : paths.filter((r) => !isVoidPath(r)); const allowKeys = new Set(allowedExits.map(exitNormKey)); const byKey = new Map(paths.map((p) => [p.key, p])); const seenIp = new Set(); for (const r of kept) { const n = paths.indexOf(r) + 1; const shareKey = r.share_egress_of.trim(); const primary = shareKey ? byKey.get(shareKey) : null; if (shareKey) { if (!primary || primary.share_egress_of.trim()) { return `第 ${n} 条通路的挂靠目标无效(须为独立主通路)。`; } if (paths.indexOf(primary) >= paths.indexOf(r)) { return `第 ${n} 条通路只能挂靠更靠前的主通路。`; } } const miss: string[] = []; if (blank(r.sub_account_id)) miss.push("分账号编号"); if (blank(r.network_account_name)) miss.push("网络接入账号"); if (blank(r.intranet_ip)) miss.push("内网 IP"); if (blank(r.subnet_mask)) miss.push("子网掩码"); if (blank(r.gateway)) miss.push("默认网关"); if (blank(r.vlan)) miss.push("接入 VLAN"); if (blank(r.proxy_host)) miss.push("正向代理地址"); if (blank(r.proxy_port)) miss.push("正向代理端口"); if (blank(r.egress_pop)) miss.push("出口 PoP"); if (blank(r.down_mbps)) miss.push("下行实测"); if (blank(r.up_mbps)) miss.push("上行实测"); if (!shareKey || !r.share_credential) { if (blank(r.pin) && !r.pin_registered) miss.push("接入口令(PIN)"); } if (r.require_cpid && !shareKey && blank(r.cpid) && !r.cpid_registered) miss.push("CPID"); if (r.tunnel_encap === "vxlan") { if (blank(r.vni)) miss.push("VNI"); if (blank(r.src_endpoint)) miss.push("隧道本端"); if (blank(r.dst_endpoint)) miss.push("隧道对端"); } if (involveOverseasIp && !shareKey) { if (blank(r.overseas_ip)) miss.push("境外出口 IP"); if (blank(r.ip_type)) miss.push("接入方式"); if (blank(r.bandwidth_mbps)) miss.push("申报带宽档位"); } if (miss.length) return `第 ${n} 条通路缺${miss.join("、")}。`; for (const f of ["intranet_ip", "subnet_mask", "gateway"] as const) { if (!isIpLike(r[f])) return `第 ${n} 条通路的${f}「${r[f]}」不是合法 IP。`; } const port = Number(r.proxy_port); if (!Number.isInteger(port) || port < 1 || port > 65535) { return `第 ${n} 条通路的代理端口「${r.proxy_port}」须在 1~65535。`; } if (!posNum(r.down_mbps) || !posNum(r.up_mbps)) { return `第 ${n} 条通路的上下行实测须为正数。`; } if (allowKeys.size && r.egress_pop.trim() && !allowKeys.has(exitNormKey(r.egress_pop))) { return `第 ${n} 条通路出口 PoP「${r.egress_pop}」不在本单订阅核定出口内(须为:${allowedExits.join("、")})。`; } if (involveOverseasIp && !shareKey) { if (!isIpLike(r.overseas_ip)) return `第 ${n} 条通路境外 IP「${r.overseas_ip}」不是合法 IP。`; if (seenIp.has(r.overseas_ip.trim())) return `境外 IP「${r.overseas_ip}」重复登记。`; seenIp.add(r.overseas_ip.trim()); if (!BANDWIDTH_TIERS.includes(Number(r.bandwidth_mbps))) { return `第 ${n} 条通路带宽档位只能是 5/10/30 Mbps。`; } } } if (require && !kept.length) return "套餐席位通路尚未填写。"; return null; } /** 兼容旧名。 */ export function validateRouteRows( rows: PathDraft[], require: boolean, allowedExits: string[] = [], ): string | null { return validatePathRows(rows, require, allowedExits, true); } export function validateBackfillIpRows( _rows: BackfillIpRowDraft[], _allowedExits: string[] = [], ): string | null { return null; // 境外资源已并入通路校验 } export function normalizeBuilderUserId(raw: string | undefined | null): string | null { const v = (raw ?? "").trim(); return /^\d+$/.test(v) ? v : null; } export function parseLineExits(raw: string | string[] | null | undefined): string[] { if (Array.isArray(raw)) return raw.map((x) => String(x).trim()).filter(Boolean); if (!raw || !String(raw).trim()) return []; try { const v = JSON.parse(String(raw)); return Array.isArray(v) ? v.map((x) => String(x).trim()).filter(Boolean) : []; } catch { return []; } } export function resolveApprovedLineExits(detail: { order?: { line_exits?: string | string[] | null } | null; construction_guide?: { plan?: { line_exits?: string | string[] | null } | null; defaults?: { line_exits?: string[] | null } | null; } | null; }): string[] { const fromOrder = parseLineExits(detail.order?.line_exits); if (fromOrder.length) return fromOrder; const fromPlan = parseLineExits(detail.construction_guide?.plan?.line_exits); if (fromPlan.length) return fromPlan; return parseLineExits(detail.construction_guide?.defaults?.line_exits); } export function derivePinBindMode(paths: PathDraft[]): "shared" | "per_account" { return paths.some((p) => !isVoidPath(p) && p.share_credential && p.share_egress_of.trim()) ? "shared" : "per_account"; } /** 通路 → 后端 route_rows + ip_rows + pin_bind_mode(提交行一律 open_this_time=true)。 */ export function buildPathSubmit(paths: PathDraft[]): { route_rows: BackfillInRoute[]; ip_rows: Array; pin_bind_mode: "shared" | "per_account"; } { const opened = paths.filter((r) => !isVoidPath(r)); const byKey = new Map(opened.map((p) => [p.key, p])); const pin_bind_mode = derivePinBindMode(opened); const route_rows: BackfillInRoute[] = opened.map((r) => { const primary = r.share_egress_of.trim() ? byKey.get(r.share_egress_of.trim()) : null; const shareCredOf = r.share_credential && primary ? (primary.sub_account_id.trim() || null) : null; return { sub_account_id: r.sub_account_id.trim(), network_account_name: r.network_account_name.trim() || null, intranet_ip: r.intranet_ip.trim(), subnet_mask: r.subnet_mask.trim(), gateway: r.gateway.trim(), vlan: r.vlan.trim(), tunnel_encap: r.tunnel_encap, vni: r.tunnel_encap === "vxlan" ? r.vni.trim() : "", src_endpoint: r.tunnel_encap === "vxlan" ? r.src_endpoint.trim() : "", dst_endpoint: r.tunnel_encap === "vxlan" ? r.dst_endpoint.trim() : "", egress_pop: r.egress_pop.trim(), down_mbps: Number(r.down_mbps), up_mbps: Number(r.up_mbps), proxy_host: r.proxy_host.trim(), proxy_port: Number(r.proxy_port), pin: shareCredOf ? "" : r.pin, cpid: shareCredOf ? "" : r.cpid.trim(), require_cpid: r.require_cpid, share_credential_of: shareCredOf, open_this_time: true, }; }); /** 按境外 IP 聚合:独立通路各一条;挂靠行并入主通路 IP。 */ type Acc = { egress: string; overseas_ip: string; ip_type: string; bandwidth_mbps: number; sub_account_ids: string[]; pin: string; cpid: string; }; const groups = new Map(); for (const r of opened) { const primary = r.share_egress_of.trim() ? byKey.get(r.share_egress_of.trim()) : r; if (!primary || blank(primary.overseas_ip)) continue; const ipKey = primary.overseas_ip.trim(); let g = groups.get(ipKey); if (!g) { const multi = opened.some( (x) => x.share_egress_of && byKey.get(x.share_egress_of.trim())?.overseas_ip.trim() === ipKey, ); g = { egress: primary.egress_pop.trim(), overseas_ip: ipKey, ip_type: multi || primary.ip_type === "nat_forward" ? "nat_forward" : (primary.ip_type || "fixed_ip"), bandwidth_mbps: Number(primary.bandwidth_mbps) || 5, sub_account_ids: [], pin: primary.pin, cpid: primary.cpid.trim(), }; groups.set(ipKey, g); } const acc = r.sub_account_id.trim(); if (acc && !g.sub_account_ids.includes(acc)) g.sub_account_ids.push(acc); } const ip_rows = [...groups.values()].map((g) => ({ egress: g.egress, overseas_ip: g.overseas_ip, ip_type: g.sub_account_ids.length > 1 ? "nat_forward" : g.ip_type, bandwidth_mbps: g.bandwidth_mbps, pin: g.pin || undefined, cpid: g.cpid || undefined, action: "allocate" as const, sub_account_ids: g.sub_account_ids, })); return { route_rows, ip_rows, pin_bind_mode }; } export function buildRouteRows(rows: PathDraft[]): BackfillInRoute[] { return buildPathSubmit(rows).route_rows; } export function buildBackfillIpRows(rows: BackfillIpRowDraft[]): BackfillInIp[] { return rows.filter((r) => !blank(r.overseas_ip)).map((r) => ({ egress: r.egress.trim(), overseas_ip: r.overseas_ip.trim(), ip_type: r.ip_type, bandwidth_mbps: Number(r.bandwidth_mbps), pin: r.pin, cpid: r.cpid.trim(), })); } export function pathsFromDetail( routes: RouteRow[], ips: IpRow[], ): PathDraft[] { if (!routes.length) return [newPathDraft()]; const ipByAcc = new Map(); const multiOwners = new Map(); for (const ip of ips) { const accs = [...(ip.sub_account_ids ?? [])]; if (!accs.length && routes.length === 1 && ips.length === 1) { const only = routes[0].sub_account_id ?? ""; if (only) accs.push(only); } for (const a of accs) { if (a) ipByAcc.set(a, ip); } if (accs.length > 1 && ip.overseas_ip) { multiOwners.set(ip.overseas_ip, accs); } } const pathKeys = new Map(); const drafts: PathDraft[] = routes.map((r) => { const d = newPathDraft(); pathKeys.set(r.sub_account_id ?? "", d.key); const ip = ipByAcc.get(r.sub_account_id ?? ""); const owners = ip?.overseas_ip ? multiOwners.get(ip.overseas_ip) : undefined; const isPrimary = !owners || owners[0] === r.sub_account_id; const primaryAcc = owners?.[0]; return { ...d, sub_account_id: r.sub_account_id ?? "", network_account_name: r.network_account_name ?? "", intranet_ip: r.intranet_ip ?? "", subnet_mask: r.subnet_mask ?? "", gateway: r.gateway ?? "", vlan: r.vlan ?? "", tunnel_encap: (r as RouteRow & { tunnel_encap?: string }).tunnel_encap === "vxlan" ? "vxlan" : "none", vni: r.vni ?? "", src_endpoint: r.src_endpoint ?? "", dst_endpoint: r.dst_endpoint ?? "", egress_pop: r.egress_pop ?? "", down_mbps: r.down_mbps ?? "", up_mbps: r.up_mbps ?? "", proxy_host: (r as RouteRow & { proxy_host?: string }).proxy_host ?? "", proxy_port: (r as RouteRow & { proxy_port?: string }).proxy_port ?? "", pin_registered: (r as RouteRow & { pin_registered?: string }).pin_registered === "true" || (r as RouteRow & { pin_registered?: string }).pin_registered === "1", cpid_registered: (r as RouteRow & { cpid_registered?: string }).cpid_registered === "true" || (r as RouteRow & { cpid_registered?: string }).cpid_registered === "1", overseas_ip: isPrimary ? (ip?.overseas_ip ?? "") : "", ip_type: ip?.ip_type || "fixed_ip", bandwidth_mbps: ip?.bandwidth_mbps || "5", share_egress_of: !isPrimary && primaryAcc ? (pathKeys.get(primaryAcc) || "") : "", share_credential: false, open_this_time: true, }; }); // 第二遍:挂靠 key(第一遍时 primary 的 key 可能尚未写入 map 顺序问题——按账号再补) for (const d of drafts) { if (!d.share_egress_of && d.overseas_ip === "") { const ip = ipByAcc.get(d.sub_account_id); const owners = ip?.overseas_ip ? multiOwners.get(ip.overseas_ip) : undefined; if (owners && owners[0] !== d.sub_account_id) { const pk = drafts.find((x) => x.sub_account_id === owners[0])?.key; if (pk) d.share_egress_of = pk; } } } return drafts; } export function routeRowsFromDetail(rows: RouteRow[]): PathDraft[] { return pathsFromDetail(rows, []); } const txt = (v: unknown) => (v == null ? "" : String(v)); const flagOn = (v: unknown) => v === true || v === "true" || v === "1"; /** * 服务端回填草稿 → 通路表单。PIN/CPID 明文不回,只带 registered 标记; * `share_credential_of`(账号 ID)还原为表单内挂靠 key。 */ export function pathsFromDraft( routeRows: Array & { pin_registered?: string | boolean | null; cpid_registered?: string | boolean | null; pin_cipher?: string | null; cpid_cipher?: string | null; open_this_time?: boolean | null; }> | null | undefined, ipRows?: Array & { pin_registered?: string | boolean | null; cpid_registered?: string | boolean | null; }> | null, ): PathDraft[] { const routes = routeRows ?? []; if (!routes.length) return [newPathDraft()]; const asRoutes: RouteRow[] = routes.map((r, i) => ({ id: `draft-r-${i}`, sub_account_id: txt(r.sub_account_id) || null, network_account_name: txt(r.network_account_name) || null, intranet_ip: txt(r.intranet_ip) || null, subnet_mask: txt(r.subnet_mask) || null, gateway: txt(r.gateway) || null, vlan: txt(r.vlan) || null, tunnel_encap: r.tunnel_encap === "vxlan" ? "vxlan" : "none", vni: txt(r.vni) || null, src_endpoint: txt(r.src_endpoint) || null, dst_endpoint: txt(r.dst_endpoint) || null, egress_pop: txt(r.egress_pop) || null, down_mbps: txt(r.down_mbps) || null, up_mbps: txt(r.up_mbps) || null, proxy_host: txt(r.proxy_host) || null, proxy_port: txt(r.proxy_port) || null, pin_registered: flagOn(r.pin_registered) || Boolean(txt(r.pin_cipher)) ? "true" : "false", cpid_registered: flagOn(r.cpid_registered) || Boolean(txt(r.cpid_cipher)) ? "true" : "false", })); const asIps: IpRow[] = (ipRows ?? []).map((ip, i) => ({ id: `draft-ip-${i}`, row_no: String(i + 1), egress: txt(ip.egress) || null, overseas_ip: txt(ip.overseas_ip) || null, ip_type: txt(ip.ip_type) || "fixed_ip", bandwidth_mbps: txt(ip.bandwidth_mbps) || "5", pin_registered: flagOn(ip.pin_registered) ? "true" : "false", cpid_registered: flagOn(ip.cpid_registered) ? "true" : "false", sub_account_ids: Array.isArray(ip.sub_account_ids) ? ip.sub_account_ids.map((x) => txt(x)).filter(Boolean) : [], })); const drafts = pathsFromDetail(asRoutes, asIps); // share_credential_of=主通路账号 ID → 表单挂靠 key for (let i = 0; i < drafts.length; i++) { const credOf = txt(routes[i]?.share_credential_of); if (!credOf) continue; const primary = drafts.find((x) => x.sub_account_id === credOf); if (!primary) continue; drafts[i].share_egress_of = primary.key; drafts[i].share_credential = true; } for (let i = 0; i < drafts.length; i++) { drafts[i].open_this_time = true; if (flagOn(routes[i]?.require_cpid)) drafts[i].require_cpid = true; } return drafts; } export function backfillIpRowsFromDetail(rows: IpRow[]): BackfillIpRowDraft[] { return rows.map((r) => ({ key: key("bip"), egress: r.egress ?? "", overseas_ip: r.overseas_ip ?? "", ip_type: r.ip_type || "fixed_ip", bandwidth_mbps: r.bandwidth_mbps || "5", pin: "", cpid: "", sub_account_ids: r.sub_account_ids, })); } /** 字段元数据(通路卡分段渲染)。 */ export const PATH_CPE_FIELDS: { key: keyof PathDraft; label: string; ph?: string; hint?: string; scannable?: boolean; type?: string }[] = [ { key: "sub_account_id", label: "分账号编号", ph: "ACC-0001", scannable: true, hint: "本系统分账号主键" }, { key: "network_account_name", label: "网络接入账号", ph: "proxy-user-01", scannable: true, hint: "正向代理/网管侧认证用户名" }, { key: "intranet_ip", label: "客户侧内网 IP", ph: "10.20.30.11", hint: "CPE/LAN 侧地址" }, { key: "subnet_mask", label: "子网掩码", ph: "255.255.255.0" }, { key: "gateway", label: "默认网关", ph: "10.20.30.1" }, { key: "vlan", label: "接入 VLAN", ph: "120", hint: "客户侧 L2 分段,与 VNI 无包含关系" }, { key: "pin", label: "接入口令(PIN)", ph: "只写不读", type: "password", hint: "与网络接入账号配对的口令;一账号一 PIN" }, { key: "cpid", label: "CPID", ph: "选填", hint: "有则录;默认非必填" }, { key: "proxy_host", label: "正向代理地址", ph: "proxy.example.com", hint: "客户侧接入点" }, { key: "proxy_port", label: "正向代理端口", ph: "8080" }, ]; export const PATH_TUNNEL_FIELDS: { key: keyof PathDraft; label: string; ph?: string; hint?: string }[] = [ { key: "vni", label: "隧道 VNI", ph: "50120", hint: "VXLAN 网络标识(与 VLAN 不同层)" }, { key: "src_endpoint", label: "隧道本端(VTEP/PE)", hint: "客户侧隧道端点" }, { key: "dst_endpoint", label: "隧道对端(VTEP/PE)", hint: "对端/PoP 侧隧道端点" }, { key: "egress_pop", label: "出口 PoP", ph: "请选择核定出口", hint: "须∈订阅核定出口(KLT-G20406)" }, { key: "down_mbps", label: "下行实测 Mbps", ph: "100", hint: "开通实测,非申报档位" }, { key: "up_mbps", label: "上行实测 Mbps", ph: "50" }, ]; // 旧 ROUTE_FIELDS 兼容(部分页面可能仍引用) export type RouteFieldDef = { key: keyof PathDraft; label: string; ph?: string; group: "cpe" | "tunnel"; scannable?: boolean; hint?: string; }; export const ROUTE_FIELDS: RouteFieldDef[] = [ ...PATH_CPE_FIELDS.filter((f) => !["pin", "cpid", "proxy_host", "proxy_port"].includes(f.key as string)).map((f) => ({ ...f, group: "cpe" as const })), ...PATH_TUNNEL_FIELDS.map((f) => ({ ...f, group: "tunnel" as const })), ]; export const ROUTE_GROUP_LABELS = { cpe: "客户侧接入", tunnel: "路径与出口", }; export const IP_ROW_FIELDS: { key: keyof BackfillIpRowDraft; label: string; ph?: string; hint?: string }[] = [ { key: "overseas_ip", label: "境外出口 IP", ph: "203.0.113.7" }, { key: "ip_type", label: "接入方式" }, { key: "bandwidth_mbps", label: "申报带宽档位" }, ]; export const IP_TYPE_LABELS: Record = { fixed_ip: "固定 IP", nat_forward: "NAT 共享出口", };