| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- /**
- * 施工指导只读区:开户见套餐权益;停机见开机施工参数;变更见前后对照+原施工参数。
- */
- import type { ConstructionGuide, PriorActivation, ConstructionPlanSummary } from "../../lib/api/ticket";
- import { PLAN_FAMILY, PLAN_KIND, label } from "../../lib/api/labels";
- function exitsText(v: ConstructionPlanSummary["line_exits"]): string {
- if (Array.isArray(v)) return v.filter(Boolean).join("、") || "—";
- if (typeof v === "string" && v.trim()) {
- try {
- const parsed = JSON.parse(v) as unknown;
- if (Array.isArray(parsed)) return parsed.filter(Boolean).join("、") || "—";
- } catch { /* plain csv */ }
- return v;
- }
- return "—";
- }
- function PlanCard({ title, plan }: { title: string; plan: ConstructionPlanSummary | null | undefined }) {
- if (!plan) return null;
- return (
- <div className="wo-guide-card">
- <h4 className="work-order-subhead">{title}</h4>
- {plan.summary ? <p className="wo-guide-summary">{plan.summary}</p> : null}
- <div className="work-order-summary-grid">
- <div><span>套餐</span><strong>{plan.plan_name ?? "—"}</strong></div>
- <div><span>交付形态</span><strong>{plan.plan_family ? label(PLAN_FAMILY, plan.plan_family) : "—"}</strong></div>
- <div><span>档位类型</span><strong>{plan.plan_kind ? label(PLAN_KIND, plan.plan_kind) : "—"}</strong></div>
- <div><span>份数</span><strong>{plan.quantity ?? "—"}</strong></div>
- <div><span>分账号额度</span><strong>{plan.quota_slots ?? plan.sub_account_quota ?? "—"}</strong></div>
- <div><span>承诺带宽</span><strong>
- {[plan.bandwidth_down_mbps != null && `↓${plan.bandwidth_down_mbps}`, plan.bandwidth_up_mbps != null && `↑${plan.bandwidth_up_mbps}`]
- .filter(Boolean).join(" / ") || "—"}
- {plan.bandwidth_committed === false ? "(不承诺)" : ""}
- </strong></div>
- <div className="wide"><span>线路出口</span><strong>{exitsText(plan.line_exits)}</strong></div>
- </div>
- </div>
- );
- }
- function PriorBlock({ prior }: { prior: PriorActivation }) {
- return (
- <div className="wo-guide-card">
- <h4 className="work-order-subhead">开机时施工参数</h4>
- <p className="wo-guide-summary">
- 来源开户单 {prior.ticket_no ?? prior.ticket_id ?? "—"}
- {prior.actual_opened_date ? ` · 实际开通 ${prior.actual_opened_date.slice(0, 10)}` : ""}
- (PIN/CPID 仅显示是否已登记)
- </p>
- {(prior.routes?.length ?? 0) > 0 && (
- <div className="work-order-table-wrap compact">
- <table>
- <thead><tr>
- <th>分账号</th><th>网络账户</th><th>内网 IP</th><th>VLAN/VNI</th><th>出口 PoP</th><th>带宽</th>
- </tr></thead>
- <tbody>
- {prior.routes!.map((r) => (
- <tr key={r.id}>
- <td>{r.sub_account_id ?? "—"}</td>
- <td>{r.network_account_name ?? "—"}</td>
- <td>{[r.intranet_ip, r.subnet_mask].filter(Boolean).join(" / ") || "—"}</td>
- <td>{[r.vlan, r.vni].filter(Boolean).join(" / ") || "—"}</td>
- <td>{r.egress_pop ?? "—"}</td>
- <td>{[r.down_mbps && `↓${r.down_mbps}`, r.up_mbps && `↑${r.up_mbps}`].filter(Boolean).join(" / ") || "—"}</td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- )}
- {(prior.ips?.length ?? 0) > 0 && (
- <div className="work-order-table-wrap compact">
- <table>
- <thead><tr><th>出境口岸</th><th>境外 IP</th><th>类型</th><th>带宽档</th><th>凭据</th></tr></thead>
- <tbody>
- {prior.ips!.map((r) => (
- <tr key={r.id}>
- <td>{r.egress ?? "—"}</td>
- <td>{r.overseas_ip ?? "—"}</td>
- <td>{r.ip_type ?? "—"}</td>
- <td>{r.bandwidth_mbps ?? "—"}</td>
- <td>PIN {r.pin_registered === "true" ? "✓" : "—"} / CPID {r.cpid_registered === "true" ? "✓" : "—"}</td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- )}
- {!prior.routes?.length && !prior.ips?.length && <p className="work-order-detail-footnote">暂无历史开通明细。</p>}
- </div>
- );
- }
- export function ConstructionGuidePanel({ guide }: { guide: ConstructionGuide | null | undefined }) {
- if (!guide || typeof guide !== "object") return null;
- const t = guide.ticket_type ?? "";
- const isStop = t === "expiry_stop" || t === "service_stop";
- const isUpdown = t === "updown";
- return (
- <section className="wo-guide" aria-label="施工指导">
- <h3 className="work-order-section-title">施工指导</h3>
- {isUpdown ? (
- <>
- <PlanCard title="变更前" plan={guide.plan_before} />
- <PlanCard title="变更后" plan={guide.plan_after ?? guide.plan} />
- </>
- ) : (
- <PlanCard title="相关套餐" plan={guide.plan} />
- )}
- {(guide.member_plans?.length ?? 0) > 0 && (
- <div className="wo-guide-card">
- <h4 className="work-order-subhead">并单成员订阅</h4>
- <ul className="wo-guide-members">
- {guide.member_plans!.map((m) => (
- <li key={m.subscription_id ?? m.plan_name ?? Math.random()}>
- {m.plan_name ?? m.subscription_id}
- {m.plan_family ? ` · ${label(PLAN_FAMILY, m.plan_family)}` : ""}
- </li>
- ))}
- </ul>
- </div>
- )}
- {(isStop || isUpdown) && guide.prior_activation && <PriorBlock prior={guide.prior_activation} />}
- {guide.defaults && (guide.defaults.suggest_down_mbps != null || (guide.defaults.line_exits?.length ?? 0) > 0) && (
- <p className="work-order-detail-footnote">
- 系统建议(可改):出口 {exitsText(guide.defaults.line_exits)}
- {guide.defaults.suggest_down_mbps != null ? ` · 下行 ${guide.defaults.suggest_down_mbps} Mbps` : ""}
- {guide.defaults.suggest_up_mbps != null ? ` · 上行 ${guide.defaults.suggest_up_mbps} Mbps` : ""}
- {guide.defaults.suggest_ip_bandwidth_mbps != null ? ` · IP 档 ${guide.defaults.suggest_ip_bandwidth_mbps}` : ""}
- {guide.defaults.suggest_seat_count != null ? ` · 席位约 ${guide.defaults.suggest_seat_count}` : ""}
- </p>
- )}
- </section>
- );
- }
|