/** * 册 8《合伙人与运营商只读视图》页面族(视图§14 页面契约逐页)。 * * 路由与菜单契约(视图§3.4/§14.1,⛔ 三身份路由前缀不同、组件不复用路由): * partnerAcct ⇒ /bos/pv/*(V-P1 合并页/V-P2 客户/V-P3 合同); * opAcct ⇒ /bos/ov/*(V-P5 对账清单/V-P6 账单明细/V-P7 客户/V-P8 合同); * teamLead ⇒ /bos/tv/recon(V-P1b,复用 V-P1 合并页组件——⚠️ 仅此两页允许共用; * V-P5/V-P6 与合并页内两表「同名不同路由」,⛔ 合并组件靠 props 抹平差异,A51)。 * 变更记录 V-P4/V-P9 三条路由 /bos/{pv,ov,tv}/n 建在册 10:读口就绪位 `audit_read_ready=true` ⇒ 入口渲染(视图§3.4 纪律 1)。 * * 接线状态(2026-11-18):bos.view/partner_recon@v1 已在 openapi.yaml 声明并由 * billing::view_partner_recon 实现(六段一次返回)⇒ 合并页走真数据; * 11001 占位分支仅作契约兜底保留。opAcct 两页复用对账§同名口(R1/R2,reconGetList/billGetList); * 单批导出复用对账§ reconExportDetail(R4,本册⛔ 自立导出口)。 * * 硬纪律:⛔「无权限」字样(U-68/总则§16.4);⛔ history.back()(14.6); * ⛔ 列表级导出/批量操作/人工补跑/已读异议按钮(14.5 白名单); * ⛔「涉及分成方」卡与「同一张应收上其他分成方」面板(14.5,服务端亦不返回); * 金额整数分传输、前端不做浮点运算;月份默认预选 lastClosedMonth()(U-67 定案,三身份同口径)。 */ import { useCallback, useEffect, useRef, useState } from "react"; import { PageIntro } from "../components/PageIntro"; import { Download, Search, X } from "lucide-react"; import { Link, useParams } from "react-router"; import { ServerListPager } from "../components/ListPager"; import { Button } from "../components/ui/button"; import { Input } from "../components/ui/input"; import { FilterSelect } from "../components/ui/filter-select"; import { OpsNotice, OpsStatus, OpsTableEmpty, OpsTag } from "../components/OperationsKit"; import { Tri } from "../components/triState"; import { CONTRACT_TYPE_LABEL } from "../domain/contract-draft"; import { hasBizCode } from "../lib/api/http"; import { billGetDetail, billGetList, contractGet, contractGetList, customerGet, customerGetList, reconExportDetail, reconGetList, reconGetPeriods, viewPartnerRecon, } from "../lib/api/bos"; import type { BillDetailResult, ContractRow, ViewBillDetailRow, ViewPartnerReconResult, ViewReconBatchRow, } from "../lib/api/types"; import { WORD_FETCH_FAILED, WORD_NOT_PROVIDED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy"; import { ACCT_STATUS, SUBJECT_TYPE, label } from "../lib/api/labels"; import { settleTextFromSnapshot } from "../lib/settle-text"; import { lastClosedMonth } from "../lib/recon"; import { ALL_PERIODS_LABEL, BACKEND_NOT_WIRED, BATCH_STATUS_TEXT, EXPORT_EMPTY_NOTE, RECONCILE_STATUS_TEXT, exportResultNote, saveReconExportCsv } from "../lib/copy-billing"; import { BACK_TO_BILL_DETAIL_LIST, BACK_TO_CONTRACT_LIST, BACK_TO_CUSTOMER_LIST, BACK_TO_REGION_RECON, BACK_TO_SELF_RECON, CARD1_TITLE, CARD_SNAPSHOT_TITLE, OWNERSHIP_CHANGED, VIEW_ALL_PERIODS_NOTE, VIEW_BINDING_FAILED, VIEW_CONFIG_UNSET, VIEW_DEFAULT_PAY_CYCLE, VIEW_DETAIL_ONLY_SETTLED, VIEW_EXPORT_EXPIRED, VIEW_FILTER_INCOMPLETE, VIEW_KEYWORD_FILTER_NOTE, VIEW_LIST_EMPTY, VIEW_MONTH_NO_BATCH, VIEW_NOT_FOUND, VIEW_ROLE_FORBIDDEN, VIEW_SNAPSHOT_NOT_READY, VIEW_WIRING_NOTE, viewExportOverLimit, viewMonthTruncated, } from "../lib/copy-views"; import "../styles/operations.css"; import "../styles/settlement-records.css"; /* ── 本地小工具 ─────────────────────────────────────────────────── */ type ViewKind = "partner" | "operator" | "team"; const kindPrefix = (kind: ViewKind) => (kind === "partner" ? "/bos/pv" : kind === "operator" ? "/bos/ov" : "/bos/tv"); /** 金额列以 `_cents`(分)下发;界面统一两位小数元。 */ const moneyFromCents = (cents: number): string => `¥${(cents / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; /** 三态格:null ⇒「取数失败」(KLT-S406 单格语义),⛔ 回落 ¥0(视图§4.6)。 */ const moneyCell = (cents: number | null): string => (cents == null ? WORD_FETCH_FAILED : moneyFromCents(cents)); /** 视图侧失败分类(14.7 全量;11001=未接线占位)。 */ type ViewFail = | { kind: "wiring" } | { kind: "snapshot" } /* KLT-O20703 整页态(月份选择器仍可用) */ | { kind: "binding" } /* KLT-O20701 整页态,⚠️ 不提供重试 */ | { kind: "forbidden" } /* KLT-P301,与 11001 分文案 */ | { kind: "notfound" } /* 11104 详情空态 */ | { kind: "param" } /* 11103 筛选入参 */ | { kind: "fail"; message: string }; function classifyViewError(e: unknown): ViewFail { if (hasBizCode(e, "11001")) return { kind: "wiring" }; if (hasBizCode(e, "KLT-O20703")) return { kind: "snapshot" }; if (hasBizCode(e, "KLT-O20701")) return { kind: "binding" }; if (hasBizCode(e, "KLT-P301")) return { kind: "forbidden" }; if (hasBizCode(e, "11104")) return { kind: "notfound" }; if (hasBizCode(e, "11103")) return { kind: "param" }; return { kind: "fail", message: e instanceof Error && e.message ? e.message : WORD_FETCH_FAILED }; } /** 通用取数 hook(依赖数组由调用方给稳态键)。 */ function useViewFetch(fn: () => Promise, deps: readonly unknown[]): { data: T | null; loading: boolean; fail: ViewFail | null; reload: () => void; } { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [fail, setFail] = useState(null); const [tick, setTick] = useState(0); // eslint-disable-next-line react-hooks/exhaustive-deps const run = useCallback(fn, deps); useEffect(() => { let alive = true; setLoading(true); run() .then((res) => { if (!alive) return; setData(res); setFail(null); }) .catch((e: unknown) => { if (!alive) return; setData(null); setFail(classifyViewError(e)); }) .finally(() => { if (alive) setLoading(false); }); }, [run, tick]); return { data, loading, fail, reload: () => setTick((t) => t + 1) }; } /** 单批导出(三身份唯一写副作用,R4 复用对账§口;O20702 只有一句提示,⛔ 转异步/轮询)。 */ function useExportBatch(setNotice: (m: string) => void) { return (batchId: string) => { reconExportDetail({ batch_id: batchId }) .then((res) => setNotice(saveReconExportCsv(res) ? exportResultNote(res) : EXPORT_EMPTY_NOTE)) .catch((e: unknown) => { if (hasBizCode(e, "KLT-O20702")) setNotice(viewExportOverLimit(null)); else if (hasBizCode(e, "S407")) setNotice(VIEW_EXPORT_EXPIRED); else setNotice(e instanceof Error && e.message ? e.message : WORD_FETCH_FAILED); }); }; } /** 整页态面板(绑定失败⛔重试;快照未建立/角色拒⇒给重试入口)。 */ function FullPageState({ text, retry }: { text: string; retry?: () => void }) { return (
{text} {retry && (

)}
); } /* ── V-P1/V-P1b 合并页(六段一次请求,⛔ 分段懒加载) ────────────────────── */ function PartyReconMergedPage({ kind }: { kind: "partner" | "team" }) { const title = kind === "partner" ? "本运营区域对账" : "本方对账"; const prefix = kindPrefix(kind); const [month, setMonth] = useState(lastClosedMonth()); const [keyword, setKeyword] = useState(""); const [page, setPage] = useState(1); const [notice, setNotice] = useState(""); const detailRef = useRef(null); const exportBatch = useExportBatch(setNotice); const fetchState = useViewFetch( // 对外分页 0 基(总则§16.5;组件页码 1 基,只在请求边界换算)。 () => viewPartnerRecon({ month: month || undefined, keyword, page: Math.max(0, page - 1), page_size: 20 }), [month, keyword, page], ); const { data, fail } = fetchState; const wiring = fail?.kind === "wiring"; // 快照未建立=整页态(KLT-O20703):200 响应仍带数据骨架,⛔ 渲染成空表或 0。 const snapshotNotReady = data?.snapshot_state === "not_ready"; const monthOptions = data && data.month_options !== "failed" ? data.month_options : null; const monthOptionsFailed = data?.month_options === "failed"; // C35:预选月不在 month_options 内 ⇒ 退回首项 month_options[0](⛔ 停在空月份静默成「筛选无结果」)。 useEffect(() => { if (!monthOptions?.length || !month) return; if (!monthOptions.some((o) => o.period === month)) setMonth(monthOptions[0].period); }, [monthOptions, month]); const monthFallback = Boolean(monthOptions?.length && month && !monthOptions.some((o) => o.period === month)); function resetFilter() { setKeyword(""); setMonth(lastClosedMonth()); setPage(1); } /** 表 1「查看明细」=页内锚点定位表 2 并自动填筛选(不跳页,视图§4.1.2)。 */ function drillBatch(batchNo: string) { setKeyword(batchNo); setPage(1); detailRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }); } const config = data?.config ?? null; const settle = data?.settle ?? null; const batches = data?.batches ?? []; const details = data?.details ?? []; const pageSize = 20; return (

READONLY / 只读视图

{title}

从每个账期的对账批次查到本方参与的结算和分成。
{notice && setNotice("")} />} {wiring &&

{VIEW_WIRING_NOTE}

} {/* 一份筛选条,两表共用(视图§4.2 条 5);重置=清关键字+回默认预选 lastClosedMonth()。 */}
{/* 月份选项=两表 distinct 并集(A52);failed/未接线 ⇒ 禁用下拉,⛔ 回落「近 12 个月」。 */} { setMonth(event.target.value); setPage(1); }} > {(monthOptions ?? (month ? [{ period: month, has_batch: false, has_detail: false }] : [])).map((o) => ( ))}

{VIEW_KEYWORD_FILTER_NOTE}

{monthFallback &&

{VIEW_MONTH_NO_BATCH}

} {data?.month_options_truncated &&

{viewMonthTruncated(monthOptions?.length ?? 0)}

} {monthOptionsFailed &&

{WORD_FETCH_FAILED}:月份选项暂不可用。

} {/* 整页态:KLT-O20701(⛔ 重试)/KLT-O20703(筛选条保留,①—⑥ 全替换,⛔ 渲染空表)/KLT-P301。 */} {fail?.kind === "binding" && } {fail?.kind === "snapshot" && } {snapshotNotReady && } {fail?.kind === "forbidden" && } {fail?.kind === "param" && } {fail?.kind === "fail" && } {(wiring || (data && !snapshotNotReady)) && ( <> {/* ① 页顶配置卡(V6,当前):两格都给**生效的具体取值**(✅ 2026-11-18: 付款周期不再渲染「留空=跟随默认」——那不是取值),对账日缺失才回落原标题。 */}
本方对账日 {wiring ? BACKEND_NOT_WIRED : config ? (config.recon_day == null ? VIEW_CONFIG_UNSET : `每月 ${config.recon_day} 日`) : BACKEND_NOT_WIRED} 当前生效配置
付款周期 {wiring ? BACKEND_NOT_WIRED : config ? (config.pay_cycle ?? VIEW_DEFAULT_PAY_CYCLE) : BACKEND_NOT_WIRED} 当前生效配置
{/* ② 卡 1:标题固定(14.2②);未配 ⇒「未配置」,⛔ 显 0/空白。 */}
{CARD1_TITLE} {wiring ? : settle && (settle.mode != null || settle.value != null) ? settleTextFromSnapshot(settle.mode, settle.value) : WORD_UNCONFIGURED} 档案现值,不按客户配
{/* ③ 卡 2/3:标题固定「本期按账期快照」+副标题账期(与②「(现行)」同屏共存=时点口径对外声明)。 */}

{CARD_SNAPSHOT_TITLE}(账期 {month || ALL_PERIODS_LABEL})

本方对账清单 {wiring ? BACKEND_NOT_WIRED : `${data?.batch_total ?? 0} 批`} {wiring ? "—" : `当前显示 ${data?.batch_shown ?? 0} 批`}
本方账单明细 {wiring ? BACKEND_NOT_WIRED : `${data?.detail_total ?? 0} 条`} {wiring ? "—" : `当前显示 ${data?.detail_shown ?? 0} 条`}
{/* ④ 卡 4:当前筛选合计+本方全部合计双值常驻(视图§4.2 条 7);null ⇒ 取数失败 ⛔ 显 ¥0。 */}
本方分成合计 {wiring ? BACKEND_NOT_WIRED : moneyCell(data?.share_sum ?? null)} {wiring ? "—" : `本方全部合计 ${moneyCell(data?.share_sum_all ?? null)}`}
{/* ⑤ 表 1 本方对账清单(出账状态与批次状态两维度两列并排)。 */}
{wiring ? ( ) : ( batches.map((row: ViewReconBatchRow) => ( )) )} {!wiring && !batches.length && ( {VIEW_LIST_EMPTY}{!month && `;${VIEW_ALL_PERIODS_NOTE}`} )}
对账单号自然月出账状态批次状态明细条数本方分成金额操作
{row.batch_no} {row.period} {RECONCILE_STATUS_TEXT[row.reconcile_status]} {BATCH_STATUS_TEXT[row.status]} {row.detail_count} {moneyFromCents(row.share_cents)} {/* 无明细 ⇒ 导出按钮整块不渲染(⚠️ 不是禁用,总则§16.9;KLT-H205xx 仅直调防护)。 */} {row.has_detail && ( )}{" "}
{!wiring && ( )}
{/* ⑥ 表 2 本方账单明细(A18:只列已出账明细;灰底提示必显)。 */}

{VIEW_DETAIL_ONLY_SETTLED}

{wiring ? ( ) : ( details.map((row: ViewBillDetailRow) => ( {/* 批次详情宿主路由未在 14.1 路由表声明(仅 14.6 返回链路提及)⇒ 纯文本,缺口已登记。 */} )) )} {!wiring && !details.length && ( {VIEW_LIST_EMPTY}{!month && `;${VIEW_ALL_PERIODS_NOTE}`} )}
账单明细号客户名称应收单号自然月应结金额对账单号操作
{row.bill_detail_id} {/* C76:当前归属≠我 ⇒ 纯文本无链接+「归属已变更」;teamLead 无客户详情页 ⇒ 恒纯文本。 */} {kind === "partner" && row.customer_visible ? ( {row.customer_name} ) : ( {row.customer_name}{!row.customer_visible && {OWNERSHIP_CHANGED}} )} {row.receivable_no} {row.period} {moneyFromCents(row.receivable_cents)}{row.batch_no} 查看详情
{!wiring && ( )}
)}
); } export function PartnerReconPage() { return ; } export function TeamReconPage() { return ; } /* ── V-P5 运营商「本方对账清单」(⚠️ 独立组件,⛔ 与 V-P1 合并靠 props 抹平,A51) ── */ export function OperatorReconPage() { const [month, setMonth] = useState(lastClosedMonth()); const [keyword, setKeyword] = useState(""); const [page, setPage] = useState(1); const [notice, setNotice] = useState(""); const exportBatch = useExportBatch(setNotice); const periodsFetch = useViewFetch(() => reconGetPeriods(), []); const periods = periodsFetch.data?.periods ?? null; const fetchState = useViewFetch( // 分页器是 1 基、后端 `page` 是 0 基(openapi:页码 0 基索引)⇒ 只在请求边界换算。 () => reconGetList({ page: Math.max(0, page - 1), page_size: 20, period: month || undefined, keyword: keyword.trim() || undefined }), [month, keyword, page], ); const { data, fail } = fetchState; const wiring = fail?.kind === "wiring"; const rows = data?.items ?? []; useEffect(() => { if (!periods?.length || !month) return; if (!periods.includes(month)) setMonth(periods[0]); }, [periods, month]); const monthFallback = Boolean(periods?.length && month && !periods.includes(month)); const selfConfig = data?.self_config ?? null; const total = data?.total ?? 0; const pageSize = 20; return (

READONLY / 只读视图

本方对账清单

核对本方各账期的出账进度和应结分成。
{notice && setNotice("")} />} {wiring &&

{VIEW_WIRING_NOTE}

} {/* V6 页顶两卡(随 recon/list 响应 self_config 附带,只读身份⛔ 授配置读键)。 */}
本方对账日 {wiring ? BACKEND_NOT_WIRED : selfConfig ? `每月 ${selfConfig.recon_day} 日` : BACKEND_NOT_WIRED} 当前生效配置
付款周期 {wiring ? BACKEND_NOT_WIRED : selfConfig ? (selfConfig.pay_cycle ?? VIEW_DEFAULT_PAY_CYCLE) : BACKEND_NOT_WIRED} 当前生效配置
{/* 筛选条:自然月+对账单号关键字(⛔ 分成方/区域等范围类筛选,I30)。 */}
{ setMonth(event.target.value); setPage(1); }} > {(periods ?? (month ? [month] : [])).map((p) => )}
{monthFallback &&

{VIEW_MONTH_NO_BATCH}

} {fail?.kind === "binding" && } {fail?.kind === "forbidden" && } {fail?.kind === "fail" && } {(wiring || data) && (
{wiring ? ( ) : ( rows.map((row) => ( )) )} {!wiring && !rows.length && ( {VIEW_LIST_EMPTY}{!month && `;${VIEW_ALL_PERIODS_NOTE}`} )}
对账单号自然月出账状态批次状态明细条数本方分成金额操作
{row.batch_no} {row.period} {RECONCILE_STATUS_TEXT[row.reconcile_status]} {BATCH_STATUS_TEXT[row.status]} {row.detail_count} {moneyFromCents(row.share_cents)} {/* 本批无明细 ⇒ 按钮整块不渲染;「查看明细」→ V-P6 按对账单号过滤(14.3 筛选行)。 */} {row.detail_count > 0 && ( )}{" "} 查看明细
{!wiring && ( )}
)}
); } /* ── V-P6 运营商「账单明细」(⛔ 导出按钮——导出单位是批次;⛔「涉及分成方」卡) ────── */ export function OperatorBillDetailPage() { const [month, setMonth] = useState(lastClosedMonth()); const [batchKw, setBatchKw] = useState(""); const [customerKw, setCustomerKw] = useState(""); const [page, setPage] = useState(1); const periodsFetch = useViewFetch(() => reconGetPeriods(), []); const periods = periodsFetch.data?.periods ?? null; const fetchState = useViewFetch( () => billGetList({ page: Math.max(0, page - 1), page_size: 20, period: month || undefined, keyword: batchKw.trim() || undefined, customer_kw: customerKw.trim() || undefined }), [month, batchKw, customerKw, page], ); const { data, fail } = fetchState; const wiring = fail?.kind === "wiring"; const rows = data?.items ?? []; const total = data?.total ?? 0; const pageSize = 20; useEffect(() => { if (!periods?.length || !month) return; if (!periods.includes(month)) setMonth(periods[0]); }, [periods, month]); // 表 1「查看明细」跳入:`?batch=` 预选对账单号筛选。 useEffect(() => { const initial = new URLSearchParams(window.location.search).get("batch"); if (initial) setBatchKw(initial); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return (

READONLY / 只读视图

账单明细

沿账单追到具体客户和订阅,核对本方每笔分成。
{wiring &&

{VIEW_WIRING_NOTE}

}
{ setMonth(event.target.value); setPage(1); }} > {(periods ?? (month ? [month] : [])).map((p) => )}

{VIEW_KEYWORD_FILTER_NOTE};{VIEW_DETAIL_ONLY_SETTLED}

{fail?.kind === "binding" && } {fail?.kind === "forbidden" && } {fail?.kind === "fail" && } {(wiring || data) && (
{/* ⚠️ 应收单号/应结金额两列待 R2 真源(对账§6 明细列表口)补列 ⇒ 暂以分成基数/本方分成呈现,缺口已登记。 */} {wiring ? ( ) : ( rows.map((row) => ( )) )} {!wiring && !rows.length && ( {VIEW_LIST_EMPTY}{!month && `;${VIEW_ALL_PERIODS_NOTE}`} )}
账单明细号客户名称自然月分成基数本方分成金额对账单号操作
{row.bill_detail_id} {row.customer_name} {row.period} {moneyFromCents(row.share_base_cents)} {moneyFromCents(row.share_amount_cents)} {row.batch_no} 查看详情
{!wiring && ( )}
)}
); } /* ── V-P2/V-P7 本方客户清单(同组件两路由;形态 D 列待客户§登记) ────────────── */ export function PartyCustomerListPage({ kind }: { kind: "partner" | "operator" }) { const prefix = kindPrefix(kind); const [keyword, setKeyword] = useState(""); const [page, setPage] = useState(1); // ⛔ 前端下传 partner_id/operator_id(总则§16.1:范围在服务端谓词层展开)。 const fetchState = useViewFetch( // 分页器是 1 基、后端 `page` 是 0 基(openapi:页码 0 基索引)⇒ 只在请求边界换算。 () => customerGetList({ page: Math.max(0, page - 1), page_size: 20, keyword: keyword.trim() || undefined }), [keyword, page], ); const { data, fail } = fetchState; const rows = data?.items ?? []; const total = data?.total ?? 0; const pageSize = 20; return (

READONLY / 只读视图

客户清单

查找与本方业务相关的客户,确认客户归属和服务情况。
{fail?.kind === "fail" && } {fail && fail.kind !== "fail" && } {!fail && (
{/* 形态 D 列=客户名称/识别号/服务开通状态/所属区域/生效套餐摘要(视图§5.1); 识别号│区域路径│套餐名均随 `/customer/get_list@v1` 下发(D-71 三态:键缺失=未下发, `null`/空=未登记│未挂载│无在用订阅)。 */} {rows.map((row) => ( {/* 识别号:列表口下发 `identity_no_masked`(keybox 解密后脱敏);`null`=未登记,键缺失才标未下发。 */} {/* 三态原样渲染(客户§2 acct_status,库内英文码 ⇒ 按字典转中文),⛔ 重算/派生第四态。 */} {/* 所属区域:后端 `region_path` 取层级真源 `bos_region_meta.path_name`(未定级回落节点 ID); 键缺失=未下发,空=未挂载(⛔ 把「无挂载」说成「未下发」)。 */} {/* 生效套餐摘要:后端 `plan_names`(在用订阅的套餐名,status ∈ pending/active)。 */} ))} {!rows.length && {VIEW_LIST_EMPTY}}
客户名称客户识别号服务开通状态所属区域生效套餐摘要操作
{row.customer_name}{row.identity_no_masked === undefined ? : row.identity_no_masked ? {row.identity_no_masked} : }{label(ACCT_STATUS, row.acct_status)}{row.region_path === undefined ? : row.region_path ? row.region_path : }{row.plan_names === undefined ? : row.plan_names.length ? row.plan_names.join("、") : } 查看
)}
); } /* ── V-P3/V-P8 本方合同清单(行末只有查看) ─────────────────────────────── */ /** * 「合同名称」列取值:合同数据模型**不存名称列**(第 3 册订阅§5「合同条目不存名」) * ⇒ 按本合同服务条目的套餐现名/派生档名汇总(真值派生,⛔ 造名)。 * 条目存在但两枚名字都取不到(档位被删)=「未配置」,无条目也=「未配置」。 */ function contractNameOf(row: ContractRow) { const items = row.service_items ?? []; const names = items .map((item) => item.plan_name) .filter((name): name is string => Boolean(name && name.trim())); if (!names.length) return ; return ( {[...new Set(names)].join("、")} ); } export function PartyContractListPage({ kind }: { kind: "partner" | "operator" }) { const prefix = kindPrefix(kind); const [keyword, setKeyword] = useState(""); const [page, setPage] = useState(1); // 行集=本方客户集合传导(SQL-2 第二段);⛔ 前端下传范围入参。 const fetchState = useViewFetch( // 分页器是 1 基、后端 `page` 是 0 基(openapi:页码 0 基索引)⇒ 只在请求边界换算。 () => contractGetList({ page: Math.max(0, page - 1), page_size: 20, keyword: keyword.trim() || undefined }), [keyword, page], ); const { data, fail } = fetchState; const rows = data?.items ?? []; const total = data?.total ?? rows.length; const pageSize = 20; return (

READONLY / 只读视图

合同清单

按客户查找与本方业务相关的合同,核对服务期限和开通情况。
{fail?.kind === "fail" && } {fail && fail.kind !== "fail" && } {!fail && (
{/* 合同名称列:合同数据模型**不存名称列**(第 3 册「合同条目不存名」)⇒ 按本合同 服务条目的套餐现名汇总显示(真值派生,⛔ 造名)。无条目时标「未配置」,⛔ 标「后端未下发」。 */} {rows.map((row) => ( ))} {!rows.length && {VIEW_LIST_EMPTY}}
合同编号合同名称客户名称合同期间状态操作
{row.contract_no} {contractNameOf(row)} {row.customer_name ?? } {row.start_date ?? —} ~ {row.end_date ?? —} {row.status} 查看
)}
); } /* ── V-D1 详情宿主层(返回链路固定文案+显式路由,⛔ history.back()) ────────── */ /** 11104 ⇒ 空态卡片「数据不存在或归属已变更」+「刷新列表」(⚠️⛔「无权限」字样)。 */ function DetailNotFound({ backTo, backText }: { backTo: string; backText: string }) { return (
{VIEW_NOT_FOUND}

刷新列表({backText.replace("← ", "")})

); } function DetailHeader({ title, backTo, backText }: { title: string; backTo: string; backText: string }) { return (

READONLY / 只读视图

{title}

{backText}

); } /** V9 客户详情(⛔「关联工单」卡片,14.5 白名单第 2 项)。 */ export function PartyCustomerDetailPage({ kind }: { kind: "partner" | "operator" }) { const prefix = kindPrefix(kind); const { id = "" } = useParams(); const fetchState = useViewFetch(() => customerGet({ customer_id: id }), [id]); const { data, fail } = fetchState; return (
{fail?.kind === "notfound" && } {fail && fail.kind !== "notfound" && } {data && (
客户名称{data.customer.customer_name}
主体类型{label(SUBJECT_TYPE, data.customer.subject_type)}
服务开通状态{label(ACCT_STATUS, data.customer.acct_status)}
归属运营商{data.customer.operator_name ?? —}
归属合伙人{data.customer.partner_name ?? —}
下属分账号{data.sub_account_count}
建档时间{data.customer.created_at ?? —}
)}
); } /** V11 合同详情(⛔「关联工单」卡片;⛔ 编辑入口)。 */ export function PartyContractDetailPage({ kind }: { kind: "partner" | "operator" }) { const prefix = kindPrefix(kind); const { id = "" } = useParams(); const fetchState = useViewFetch(() => contractGet({ contract_id: id }), [id]); const { data, fail } = fetchState; return (
{fail?.kind === "notfound" && } {fail && fail.kind !== "notfound" && } {data && (
合同编号{data.contract_no}
客户名称{data.customer_name ?? —}
合同期间{data.start_date ?? —} ~ {data.end_date ?? —}
状态{data.status}
合同类型{data.contract_type ? (CONTRACT_TYPE_LABEL[data.contract_type] ?? data.contract_type) : —}
签署日期{data.sign_date ?? —}
服务期(月){data.service_months ?? —}
合同金额{moneyFromCents(data.contract_amount_cents)}
)}
); } /** * V12 账单明细详情(对账§14.3 七段同源一个接口); * ⛔「同一张应收上其他分成方」面板——三身份一律不渲染(14.5 第 3 项,服务端亦不返回)。 */ export function PartyBillDetailPage({ kind }: { kind: ViewKind }) { const { id = "" } = useParams(); const back = kind === "partner" ? { to: "/bos/pv/recon", text: BACK_TO_REGION_RECON } : kind === "team" ? { to: "/bos/tv/recon", text: BACK_TO_SELF_RECON } : { to: "/bos/ov/bill-detail", text: BACK_TO_BILL_DETAIL_LIST }; const fetchState = useViewFetch(() => billGetDetail(id), [id]); const { data, fail } = fetchState; return (
{fail?.kind === "notfound" && } {fail && fail.kind !== "notfound" && ( )} {data && (
{/* ① 尾月对齐前后两值同屏 */} {/* ② 计费区间与天数 */} {/* ④ 分成基数 */} {/* ⑤ 当时冻结的分成方式与取值(⛔ 读档案现值,I22) */} {/* ⑥ 本方分成金额 */} {/* ⑦ 逐账号在期天数:failed ⇒ 取数失败(⛔ 回落「无开停记录」) */}
账单明细号{data.bill_detail_id}
所属对账单号{data.batch_no}
自然月{data.period}
客户名称{data.customer_name}
套餐{data.subscription_label}
计费标准单价{data.settle_std_cents == null ? — : moneyFromCents(data.settle_std_cents)}
订阅份数{data.quantity == null ? — : data.quantity}
尾月对齐前{moneyFromCents(data.pre_align_cents)}
应结金额(对齐后){moneyFromCents(data.receivable_cents)}
计费区间{(data.bill_from || data.bill_to) ? `${data.bill_from || "—"} ~ ${data.bill_to || "—"}` : —}({data.billing_days} 天{data.month_days != null ? `/${data.month_days}` : ""}{data.partial_month ? ",不满月" : ""})
成本实扣{moneyFromCents(data.cost_deduct_cents ?? (data.receivable_cents - data.share_base_cents))}{(data.cost_should_deduct_cents != null && data.cost_deduct_cents != null && data.cost_should_deduct_cents > data.cost_deduct_cents) || data.base_floor_protected ? "(已按应收封顶)" : ""}
分成基数{moneyFromCents(data.share_base_cents)}{data.base_floor_protected ? "(已按下限保护取 0)" : ""}
分成方式与取值{settleTextFromSnapshot(data.share_mode, data.share_value)}
本方分成金额{moneyFromCents(data.share_amount_cents)}
逐账号在期天数 {data.account_days_failed ? WORD_FETCH_FAILED : data.account_days == null ? WORD_NOT_PROVIDED : data.account_days.length ? data.account_days.map((a) => `${a.sub_account_label} ${a.in_period_days} 天`).join(";") : —}
)}
); }