/** * 订阅详情(路由 `subs/:id`)—— 页面契约 14.3/14.4。 * * 面板顺序照契约 §3.3:基础信息/订阅周期/金额/线路出口/额度; * `original`/`replaced_by` 任一非空时追加「关联订阅」面板(⛔ 并入基础信息面板)。 * 跨册面板(计费与出账=第6册、关联工单=第5册)未接线 ⇒ **整面板「未配置」**,⛔ 渲染 0/空态。 * * 禁止入口清单(逐条不渲染):额度有效期、按使用率调整额度、额度调整原因、月成本与成本构成输入、 * 状态列按钮与批量、暂停/恢复/到期不续约/取消/改结束日/提前终止。 */ import { useState } from "react"; import { Link, useParams } from "react-router-dom"; import { contractGet, subscriptionGet } from "../api/bos"; import { label, ITEM_KIND, PAY_CYCLE, SUB_STATUS, TERM } from "../api/labels"; import { NOT_GROSS_PROFIT, OPERATOR_ONLY_CONFIG, SUB_AMOUNT_TITLE, SUB_END_DATE_READONLY, SUB_STATUS_DAILY_NOTE, SUBS_READONLY_ENTRY, UPGRADE_CUTOFF_RULE, WORD_FETCH_FAILED, WORD_UNCONFIGURED, } from "../api/lockedCopy"; import { Card, Panel, Pill, Btn, ErrorBox, Loading, Notice, day, datetime, money } from "../components/ui"; import { Tri, triTone } from "../components/triState"; import { Shell } from "../layout/Shell"; import { useSession } from "../auth/session"; import { useLoad } from "../hooks/useLoad"; import { SubscriptionDeleteDialog, SubscriptionFormDialog } from "./SubscriptionFormDialog"; export default function SubscriptionDetailPage() { const { id = "" } = useParams(); const { ctx } = useSession(); const canWrite = ["admin", "opsMain", "opsSub", "teamLead", "ops"].includes(ctx?.role_code ?? ""); const [dialog, setDialog] = useState<{ mode: "change" | "edit" } | null>(null); const [del, setDel] = useState(false); const d = useLoad(() => subscriptionGet({ subscription_id: id }), [id]); const s = d.data; const ct = useLoad(() => (s?.contract_id ? contractGet({ contract_id: s.contract_id }) : Promise.resolve(null)), [s?.contract_id]); if (d.loading && !s) return ( ); if (!s) return ( 重新加载 ); const costTone = triTone(s.plan_cost_state, s.plan_cost_cents !== null && s.plan_cost_cents !== undefined); const related = s.related ?? null; const hasRelated = !!related?.original || !!related?.replaced_by; const editBlocked = s.editable === false; const showProfitNote = s.annual_price_cents !== null && s.annual_price_cents !== undefined && s.plan_cost_cents !== null && s.plan_cost_cents !== undefined; return (
{showProfitNote ? 「年订阅价格」与「月成本」是两条独立口径:{NOT_GROSS_PROFIT}。 : null} {canWrite ? ( <> setDialog({ mode: "edit" })} > 编辑 setDialog({ mode: "change" })} > 升降配 setDel(true)}> 删除 ) : null} 刷新 } note={`状态由服务端按日终刷新:${SUB_STATUS_DAILY_NOTE};跨零点滞后的解释不另写第二段。`} >
订阅编号
{s.subscription_id}
归属客户
{s.customer_name ?? s.customer_id}
关联合同
{s.contract_no ?? s.contract_id}
合同条目
{s.contract_item_id ?? "—"}
套餐
{s.plan_name ?? "—"}
订阅方式
{s.sub_mode_label ?? s.sub_mode ?? "—"}
状态
订单号
{s.order_no || "—"}
实际开通日
{s.actual_opened_at ? datetime(s.actual_opened_at) : "—"} {s.status === "pending" ? ( 回填前保持待开通 ) : null}
创建时间
{datetime(s.created_at)}
订阅时长
{label(TERM, s.term) || "—"}
开始日
{day(s.start_date)}
结束日
{day(s.end_date)}
试用月数
{s.trial_months ?? 0}
生效日
{s.effective_date ? day(s.effective_date) : "—"}
到期日
{s.expire_date ? day(s.expire_date) : "—"}
年订阅价格
{money(s.annual_price_cents)}
月结算标准金额
{money(s.monthly_settle_cents)}
月折让金额
{s.discount_monthly_cents === null || s.discount_monthly_cents === undefined ? "—" : money(s.discount_monthly_cents)}
月成本
{showProfitNote ?

{NOT_GROSS_PROFIT}

: null}
{(s.line_exits ?? []).length === 0 ? ( {WORD_UNCONFIGURED} ) : (
{(s.line_exits ?? []).map((x) => )}
)}
计入额度
{s.quota_slots}
额度来源
{s.plan_kind === "custom" ? "自定义档(含合同条目派生)" : "固定档快照"}
{hasRelated ? ( {related?.original ? ( ) : null} {related?.replaced_by ? ( ) : null}
关系 订阅编号 套餐 状态 起止 结束日
被本订阅替换的原订阅 {related.original.subscription_id} {related.original.plan_name ?? "—"} {day(related.original.start_date)} ~ {day(related.original.end_date)} {day(related.original.end_date)}
由本订阅派生的新订阅 {related.replaced_by.subscription_id} {related.replaced_by.plan_name ?? "—"} {day(related.replaced_by.start_date)} ~ {day(related.replaced_by.end_date)} {day(related.replaced_by.end_date)}

{UPGRADE_CUTOFF_RULE}

) : null} {WORD_UNCONFIGURED}——该面板口径属第6册(出账与对账),本册未接线;整面板按「未配置」呈现,⛔ 以 0 元/0 期冒充真实数值。 {WORD_UNCONFIGURED}——工单口径属第5册,本册未接线;「是否已开通」的实际开通日由工单回填,本页只读。 {ct.loading ? : null} {ct.error ? : null} {ct.data ? (
合同编号
{ct.data.contract_no}
合同扫描件
{ct.data.attachment_url ? 查看扫描件 : "—"}
付款周期
{label(PAY_CYCLE, ct.data.pay_cycle) || "—"}
条目形态
{ct.data.service_items?.length ? label(ITEM_KIND, ct.data.service_items[0].item_kind) : "—"}
) : null}

合同扫描件随合同留档,⛔ 复制到订阅侧。

{dialog ? ( setDialog(null)} onDone={d.reload} /> ) : null} {del ? setDel(false)} onDeleted={d.reload} /> : null}
); }