Sfoglia il codice sorgente

feat(web): 统一合伙人只读详情布局

sy 3 giorni fa
parent
commit
c66463b76c

+ 4 - 3
web-scaffold/src/app/App.tsx

@@ -307,17 +307,18 @@ function Workspace() {
         <Route path="/bos/tv/n" element={<AppShell pageTitle="本方变更记录"><AuditLogPage pageTitle="本方变更记录" partyView /></AppShell>} />
         {/* V-P1 合伙人本运营区域对账(合并页) */}
         <Route path="/bos/pv/recon" element={<AppShell pageTitle="本运营区域对账"><PartnerReconPage /></AppShell>} />
+        <Route path="/bos/pv/recon/:no" element={<NavAllowed><AppShell pageTitle="对账清单详情"><SettlementStatementRecordPage partnerView /></AppShell></NavAllowed>} />
         {/* V-P2 合伙人客户清单 */}
         <Route path="/bos/pv/customer" element={<AppShell pageTitle="客户清单"><PartyCustomerListPage kind="partner" /></AppShell>} />
         {/* V-D1 客户详情宿主 */}
-        <Route path="/bos/pv/customer/:id" element={<AppShell pageTitle="客户详情"><PartyCustomerDetailPage kind="partner" /></AppShell>} />
+        <Route path="/bos/pv/customer/:id" element={<NavAllowed><AppShell pageTitle="客户详情"><PartyCustomerDetailPage kind="partner" /></AppShell></NavAllowed>} />
         {/* V-P3 合伙人合同清单(行末只有查看) */}
         <Route path="/bos/pv/contract" element={<AppShell pageTitle="合同清单"><PartyContractListPage kind="partner" /></AppShell>} />
-        <Route path="/bos/pv/contract/:id" element={<AppShell pageTitle="合同详情"><PartyContractDetailPage kind="partner" /></AppShell>} />
+        <Route path="/bos/pv/contract/:id" element={<NavAllowed><AppShell pageTitle="合同详情"><PartyContractDetailPage kind="partner" /></AppShell></NavAllowed>} />
         {/* V-D1 账单明细详情宿主 */}
         {/* 裸路径兜底:明细列表并进「本运营区域对账」合并页,没有独立列表页 ⇒ 重定向,⛔ 落到 404。 */}
         <Route path="/bos/pv/bill-detail" element={<Navigate to="/bos/pv/recon" replace />} />
-        <Route path="/bos/pv/bill-detail/:id" element={<AppShell pageTitle="账单明细详情"><PartyBillDetailPage kind="partner" /></AppShell>} />
+        <Route path="/bos/pv/bill-detail/:index" element={<NavAllowed><AppShell pageTitle="账单明细详情"><SettlementBillRecordPage partnerView /></AppShell></NavAllowed>} />
         {/* V-P5 运营商本方对账清单(页顶两卡) */}
         <Route path="/bos/ov/recon" element={<AppShell pageTitle="本方对账清单"><OperatorReconPage /></AppShell>} />
         {/* V-P6 运营商账单明细 */}

+ 3 - 0
web-scaffold/src/lib/detail-navigation.ts

@@ -59,6 +59,7 @@ const detailPages: readonly (readonly [RegExp, string])[] = [
   [/^\/organization\/maintenance-teams\/[^/]+\/accounts$/, "返回运维团队账号"],
   [/^\/settlement-batches\/[^/]+\/[^/]+$/, "返回批次详情"],
   [/^\/settlement-bills\/[^/]+$/, "返回账单明细详情"],
+  [/^\/bos\/pv\/recon\/[^/]+$/, "返回对账清单详情"],
   [/^\/bos\/(?:pv|ov)\/customer$/, "返回客户清单"],
   [/^\/bos\/(?:pv|ov)\/customer\/[^/]+$/, "返回客户详情"],
   [/^\/bos\/(?:pv|ov)\/contract$/, "返回合同清单"],
@@ -67,6 +68,8 @@ const detailPages: readonly (readonly [RegExp, string])[] = [
   [/^\/bos\/(?:pv|ov|tv)\/n$/, "返回本方变更记录"],
 ];
 
+export const partnerReconDetailPath = (batchNo: string) => `/bos/pv/recon/${encodeURIComponent(batchNo)}`;
+
 const pathOf = (url: string) => url.split(/[?#]/, 1)[0].replace(/\/$/, "") || "/";
 
 export function detailLinkState(pathname: string, previousState: unknown): DetailLinkState {

+ 166 - 0
web-scaffold/src/pages/PartnerReadOnlyRecords.tsx

@@ -0,0 +1,166 @@
+import { useState, type ReactNode } from "react";
+import { ArrowLeft, Building2, CalendarDays, CircleDollarSign, FileSignature, Gauge, Layers, MapPin, ScrollText, UsersRound } from "lucide-react";
+import { Link } from "react-router";
+import { OpsStatus, OpsTableEmpty, OpsTag } from "../components/OperationsKit";
+import { RecordTabs } from "../components/RecordTabs";
+import { CONTRACT_TYPE_LABEL } from "../domain/contract-draft";
+import { ACCT_STATUS, ITEM_FAMILY, ORDER_STATUS, SUBJECT_TYPE, label } from "../lib/api/labels";
+import type { ContractGetResult, CustomerDetail } from "../lib/api/types";
+import { contractStatusOf, contractStatusTone } from "../lib/contract-demo";
+import { useDetailLinkState, type detailBack } from "../lib/detail-navigation";
+
+type RecordBack = ReturnType<typeof detailBack>;
+type RecordSection = { id: string; label: string; count?: number; content: ReactNode };
+type RecordMetric = { label: string; icon: ReactNode; value: ReactNode };
+
+const empty = <span className="table-placeholder">—</span>;
+const money = (cents: number) => `¥${(cents / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
+
+function RecordFacts({ fields }: { fields: readonly (readonly [string, ReactNode])[] }) {
+  return <dl className="ops-record-summary">
+    {fields.map(([name, value]) => <div key={name}><dt>{name}</dt><dd>{value == null || value === "" ? empty : value}</dd></div>)}
+  </dl>;
+}
+
+function PartnerRecordLayout({ back, type, number, title, icon, context, metrics, sections }: {
+  back: RecordBack;
+  type: string;
+  number: string;
+  title: string;
+  icon: ReactNode;
+  context: ReactNode;
+  metrics: readonly RecordMetric[];
+  sections: readonly [RecordSection, ...RecordSection[]];
+}) {
+  const [active, setActive] = useState(sections[0].id);
+  const prefix = `partner-${type.toLowerCase()}`;
+  return <article className="ops-page ops-record-page record-detail">
+    <Link className="ops-back-link" to={back.to} state={back.state}><ArrowLeft size={16} aria-hidden="true" />{back.label.replace(/^←\s*/, "")}</Link>
+    <header className="customer-record-masthead">
+      <div className="customer-hero-symbol" aria-hidden="true">{icon}</div>
+      <div className="customer-hero-copy">
+        <p className="customer-record-id">{type} <span aria-hidden="true">·</span> <span>{number}</span></p>
+        <h1 className="customer-record-title">{title}</h1>
+        <div className="customer-record-tags">{context}</div>
+      </div>
+    </header>
+    <dl className="customer-record-metrics partner-record-metrics" aria-label="业务摘要">
+      {metrics.map((metric) => <div key={metric.label}>
+        <dt>{metric.icon}{metric.label}</dt><dd><strong>{metric.value}</strong></dd>
+      </div>)}
+    </dl>
+    <div className="record-tabs-frame">
+      <RecordTabs prefix={prefix} label="详情视图" tabs={sections} active={active} onChange={setActive} />
+      {sections.map((section) => <section key={section.id} className="ops-record-card record-summary-panel record-tab-panel"
+        id={`${prefix}-panel-${section.id}`} role="tabpanel" aria-labelledby={`${prefix}-tab-${section.id}`} hidden={active !== section.id} tabIndex={0}>
+        {section.content}
+      </section>)}
+    </div>
+  </article>;
+}
+
+export function PartnerCustomerRecord({ data, back }: { data: CustomerDetail; back: RecordBack }) {
+  const customer = data.customer;
+  const region = data.region_mounts?.[0]?.path_name;
+  const subject = customer.subject_type ? label(SUBJECT_TYPE, customer.subject_type) : null;
+  const status = customer.acct_status;
+  const tone = status === "stopped" || status === "disabled" ? "danger"
+    : ["active", "normal", "in_use"].includes(status) ? "success" : "neutral";
+
+  return <PartnerRecordLayout back={back} type="CUSTOMER" number={customer.customer_id} title={customer.customer_name}
+    icon={<Building2 size={26} />}
+    context={<>
+      {subject && <OpsTag tone="brand">{subject}</OpsTag>}
+      {status && <OpsStatus tone={tone}>{label(ACCT_STATUS, status)}</OpsStatus>}
+      {region && <span className="customer-record-meta"><MapPin size={14} aria-hidden="true" />{region}</span>}
+    </>}
+    metrics={[
+      { label: "分账号", icon: <UsersRound size={16} aria-hidden="true" />, value: data.sub_account_count ?? empty },
+      { label: "订阅额度", icon: <Gauge size={16} aria-hidden="true" />, value: customer.quota_cents != null && customer.quota_cents !== "" ? `${customer.quota_cents} 个` : empty },
+    ]}
+    sections={[
+      { id: "profile", label: "主体资料", content: <RecordFacts fields={[
+        ["客户编号", customer.customer_id], ["客户名称", customer.customer_name], ["主体类型", subject],
+        ["识别号 / 统一社会信用代码", customer.identity_no_masked], ["联系人", customer.contact_name],
+        ["联系电话", customer.contact_mobile], ["地址", customer.address], ["建档时间", customer.created_at],
+      ]} /> },
+      { id: "ownership", label: "归属关系", content: <RecordFacts fields={[
+        ["所属区域", region], ["运营商", customer.operator_name], ["合伙人", customer.partner_name],
+      ]} /> },
+    ]} />;
+}
+
+function PartnerRecordTable({ caption, columns, children }: { caption: string; columns: readonly string[]; children: ReactNode }) {
+  return <div className="ops-table-wrap record-table-scroll" role="region" aria-label={caption} tabIndex={0}>
+    <table className="ops-table" aria-label={caption}>
+      <thead><tr>{columns.map((column) => <th scope="col" key={column}>{column}</th>)}</tr></thead>
+      <tbody>{children}</tbody>
+    </table>
+  </div>;
+}
+
+export function PartnerContractRecord({ data, back }: { data: ContractGetResult; back: RecordBack }) {
+  const linkState = useDetailLinkState();
+  const profile = data.customer_profile;
+  const items = data.service_items;
+  const subscriptions = data.subscriptions;
+  const status = data.start_date && data.end_date ? contractStatusOf(data.start_date, data.end_date) : null;
+  const months = data.service_months == null ? null : `${data.service_months} 个月`;
+  const amount = data.contract_amount_cents == null ? null : money(data.contract_amount_cents);
+  const customerName = profile?.customer_name || data.customer_name;
+  const customerLink = profile && data.customer_id && customerName
+    ? <Link className="contract-ref-link" to={`/bos/pv/customer/${encodeURIComponent(data.customer_id)}`} state={linkState}>{customerName}</Link>
+    : customerName;
+  return <PartnerRecordLayout back={back} type="CONTRACT" number={data.contract_id} title={data.contract_no}
+    icon={<FileSignature size={26} />}
+    context={<>
+      {status && <OpsStatus tone={contractStatusTone[status]}>{status}</OpsStatus>}
+      {data.opened != null && <OpsStatus tone={data.opened ? "success" : "warning"}>{data.opened ? "已开通" : "未开通"}</OpsStatus>}
+      {customerName && <span className="customer-record-meta"><Building2 size={14} aria-hidden="true" />{customerName}</span>}
+      {data.external_no && <span className="customer-record-meta">外部单号 {data.external_no}</span>}
+    </>}
+    metrics={[
+      { label: "合同总额", icon: <CircleDollarSign size={16} aria-hidden="true" />, value: amount ?? empty },
+      { label: "服务期", icon: <CalendarDays size={16} aria-hidden="true" />, value: months ?? empty },
+      { label: "服务条目", icon: <Layers size={16} aria-hidden="true" />, value: items?.length ?? empty },
+      { label: "关联订阅", icon: <ScrollText size={16} aria-hidden="true" />, value: subscriptions?.length ?? empty },
+    ]}
+    sections={[
+      { id: "profile", label: "客户资料", content: <RecordFacts fields={[
+        ["客户编号", data.customer_id], ["客户名称", customerLink],
+        ["主体类型", profile?.subject_type && label(SUBJECT_TYPE, profile.subject_type)],
+        ["识别号 / 统一社会信用代码", profile?.identity_no_masked], ["所属区域", profile?.region_path],
+        ["运营商", profile?.operator_name], ["合伙人", profile?.partner_name],
+        ["联系人", profile?.contact_name], ["联系电话", profile?.contact_mobile], ["地址", profile?.address],
+      ]} /> },
+      { id: "business", label: "商务信息", content: <RecordFacts fields={[
+        ["合同编号", data.contract_no], ["外部单号", data.external_no],
+        ["合同类型", data.contract_type && (CONTRACT_TYPE_LABEL[data.contract_type] ?? data.contract_type)],
+        ["签署日期", data.sign_date], ["生效日期", data.start_date], ["到期日期", data.end_date],
+        ["实际开通日", data.actual_opened_at], ["服务期", months], ["合同总额", amount],
+        ["折扣率", data.discount_rate_pct == null ? null : `${data.discount_rate_pct}%`],
+      ]} /> },
+      { id: "services", label: "服务构成", count: items?.length, content: <PartnerRecordTable caption="服务构成"
+        columns={["套餐名称", "交付形态", "线路出口", "订阅份数", "分账号额度"]}>
+        {items?.map((item, index) => <tr key={item.item_id ?? index}>
+          <td><span className="table-cell-title">{item.plan_name || empty}</span></td>
+          <td>{item.item_family ? label(ITEM_FAMILY, item.item_family) : empty}</td>
+          <td>{item.line_exits?.join("、") || empty}</td>
+          <td className="table-number">{item.quantity == null ? empty : `${item.quantity} 份`}</td>
+          <td className="table-number">{item.sub_account_quota == null ? empty : `${item.sub_account_quota} 个`}</td>
+        </tr>)}
+        {!items?.length && <OpsTableEmpty colSpan={5}>{items ? "暂无服务条目" : "服务构成未下发"}</OpsTableEmpty>}
+      </PartnerRecordTable> },
+      { id: "subscriptions", label: "关联订阅", count: subscriptions?.length, content: <PartnerRecordTable caption="关联订阅"
+        columns={["套餐 / 订阅编号", "订阅期间", "年订阅价格", "月结算标准", "状态"]}>
+        {subscriptions?.map((order) => <tr key={order.subscription_id}>
+          <td><div className="table-cell-title">{order.plan_name || empty}</div><small>{order.subscription_id}</small></td>
+          <td>{order.start_date || order.end_date ? `${order.start_date || "—"} ~ ${order.end_date || "—"}` : empty}</td>
+          <td className="table-number">{order.annual_price_cents == null ? empty : money(order.annual_price_cents)}</td>
+          <td className="table-number">{order.monthly_settle_cents == null ? empty : money(order.monthly_settle_cents)}</td>
+          <td>{order.status ? <OpsStatus tone={order.status === "active" ? "success" : order.status === "expired" ? "warning" : "neutral"}>{label(ORDER_STATUS, order.status)}</OpsStatus> : empty}</td>
+        </tr>)}
+        {!subscriptions?.length && <OpsTableEmpty colSpan={5}>{subscriptions ? "暂无关联订阅" : "关联订阅未下发"}</OpsTableEmpty>}
+      </PartnerRecordTable> },
+    ]} />;
+}

+ 21 - 11
web-scaffold/src/pages/PartyViewPages.tsx

@@ -22,7 +22,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
 import { PageIntro } from "../components/PageIntro";
 import { ArrowDown, ArrowRight, CalendarDays, Download, Info, Search, X } from "lucide-react";
 import { Link, useLocation, useParams } from "react-router";
-import { detailBack, detailLinkState } from "../lib/detail-navigation";
+import { detailBack, detailLinkState, partnerReconDetailPath } from "../lib/detail-navigation";
 import { ServerListPager } from "../components/ListPager";
 import { Button } from "../components/ui/button";
 import { Input } from "../components/ui/input";
@@ -60,7 +60,6 @@ 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,
@@ -82,6 +81,7 @@ import {
   viewExportOverLimit,
   viewMonthTruncated,
 } from "../lib/copy-views";
+import { PartnerContractRecord, PartnerCustomerRecord } from "./PartnerReadOnlyRecords";
 import "../styles/operations.css";
 import "../styles/settlement-records.css";
 
@@ -359,6 +359,7 @@ function PartyReconMergedPage({ kind }: { kind: "partner" | "team" }) {
                             </button>
                           )}{" "}
                           <button type="button" className="ops-table-action" onClick={() => drillBatch(row.batch_no)}>查看明细<ArrowDown size={14} aria-hidden="true" /></button>
+                          {kind === "partner" && <>{" "}<Link className="ops-table-action" to={partnerReconDetailPath(row.batch_no)} state={linkState}>查看详情<ArrowRight size={14} aria-hidden="true" /></Link></>}
                         </td>
                       </tr>
                     ))
@@ -413,7 +414,6 @@ function PartyReconMergedPage({ kind }: { kind: "partner" | "team" }) {
                         <td className="ops-mono" title={row.receivable_no}>{row.receivable_no}</td>
                         <td>{row.period}</td>
                         <td><strong className="reconcile-money table-number">{moneyFromCents(row.receivable_cents)}</strong></td>
-                        {/* 批次详情宿主路由未在 14.1 路由表声明(仅 14.6 返回链路提及)⇒ 纯文本,缺口已登记。 */}
                         <td className="ops-mono" title={row.batch_no}>{row.batch_no}</td>
                         <td><Link className="ops-table-action" to={`${prefix}/bill-detail/${encodeURIComponent(row.bill_detail_id)}`} state={linkState}>查看详情<ArrowRight size={14} aria-hidden="true" /></Link></td>
                       </tr>
@@ -898,15 +898,21 @@ function DetailHeader({ title, back }: { title: string; back: ReturnType<typeof
 
 /** V9 客户详情(⛔「关联工单」卡片,14.5 白名单第 2 项)。 */
 export function PartyCustomerDetailPage({ kind }: { kind: "partner" | "operator" }) {
-  const prefix = kindPrefix(kind);
   const { id = "" } = useParams();
+  return <PartyCustomerDetail key={id} kind={kind} id={id} />;
+}
+
+function PartyCustomerDetail({ kind, id }: { kind: "partner" | "operator"; id: string }) {
+  const prefix = kindPrefix(kind);
   const location = useLocation();
   const back = detailBack(location.state, `${prefix}/customer`, BACK_TO_CUSTOMER_LIST);
   const fetchState = useViewFetch(() => customerGet({ customer_id: id }), [id]);
   const { data, fail } = fetchState;
+  if (kind === "partner" && data) return <PartnerCustomerRecord data={data} back={back} />;
   return (
     <section className="ops-page reconcile-index">
       <DetailHeader title="客户详情" back={back} />
+      {kind === "partner" && fetchState.loading && <p role="status">正在读取客户详情…</p>}
       {fail?.kind === "notfound" && <DetailNotFound back={back} />}
       {fail && fail.kind !== "notfound" && <FullPageState text={fail.kind === "fail" ? fail.message : VIEW_WIRING_NOTE} retry={fail.kind === "fail" ? fetchState.reload : undefined} />}
       {data && (
@@ -930,15 +936,21 @@ export function PartyCustomerDetailPage({ kind }: { kind: "partner" | "operator"
 
 /** V11 合同详情(⛔「关联工单」卡片;⛔ 编辑入口)。 */
 export function PartyContractDetailPage({ kind }: { kind: "partner" | "operator" }) {
-  const prefix = kindPrefix(kind);
   const { id = "" } = useParams();
+  return <PartyContractDetail key={id} kind={kind} id={id} />;
+}
+
+function PartyContractDetail({ kind, id }: { kind: "partner" | "operator"; id: string }) {
+  const prefix = kindPrefix(kind);
   const location = useLocation();
   const back = detailBack(location.state, `${prefix}/contract`, BACK_TO_CONTRACT_LIST);
   const fetchState = useViewFetch(() => contractGet({ contract_id: id }), [id]);
   const { data, fail } = fetchState;
+  if (kind === "partner" && data) return <PartnerContractRecord data={data} back={back} />;
   return (
     <section className="ops-page reconcile-index">
       <DetailHeader title="合同详情" back={back} />
+      {kind === "partner" && fetchState.loading && <p role="status">正在读取合同详情…</p>}
       {fail?.kind === "notfound" && <DetailNotFound back={back} />}
       {fail && fail.kind !== "notfound" && <FullPageState text={fail.kind === "fail" ? fail.message : VIEW_WIRING_NOTE} retry={fail.kind === "fail" ? fetchState.reload : undefined} />}
       {data && (
@@ -965,15 +977,13 @@ export function PartyContractDetailPage({ kind }: { kind: "partner" | "operator"
  * V12 账单明细详情(对账§14.3 七段同源一个接口);
  * ⛔「同一张应收上其他分成方」面板——三身份一律不渲染(14.5 第 3 项,服务端亦不返回)。
  */
-export function PartyBillDetailPage({ kind }: { kind: ViewKind }) {
+export function PartyBillDetailPage({ kind }: { kind: "operator" | "team" }) {
   const { id = "" } = useParams();
   const location = useLocation();
   const fallback =
-    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 };
+    kind === "team"
+      ? { to: "/bos/tv/recon", text: BACK_TO_SELF_RECON }
+      : { to: "/bos/ov/bill-detail", text: BACK_TO_BILL_DETAIL_LIST };
   const back = detailBack(location.state, fallback.to, fallback.text);
   const fetchState = useViewFetch<BillDetailResult>(() => billGetDetail(id), [id]);
   const { data, fail } = fetchState;

+ 42 - 32
web-scaffold/src/pages/SettlementRecordPages.tsx

@@ -26,7 +26,7 @@ import type { StatusTone } from "../domain/statuses";
 import { WORD_FETCH_FAILED } from "../lib/api/lockedCopy";
 import { settleTextFromSnapshot } from "../lib/settle-text";
 import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
-import { detailBack, detailLinkState, useDetailLinkState, type DetailLinkState } from "../lib/detail-navigation";
+import { detailBack, detailLinkState, partnerReconDetailPath, useDetailLinkState, type DetailLinkState } from "../lib/detail-navigation";
 import {
   lastClosedMonth, submitReconRerun,
   useBillDetail, useBillList, useReconDetail, useReconList,
@@ -63,6 +63,7 @@ import {
   VOIDED_BY_PREFIX,
   ZERO_NOTE_TEXT,
 } from "../lib/copy-billing";
+import { BACK_TO_REGION_RECON } from "../lib/copy-views";
 import "../styles/operations.css";
 import "../styles/settlement-records.css";
 
@@ -552,16 +553,18 @@ const batchRecordTabs = [
 ] as const;
 type BatchRecordTab = typeof batchRecordTabs[number]["id"];
 
-export function SettlementStatementRecordPage() {
+export function SettlementStatementRecordPage({ partnerView = false }: { partnerView?: boolean }) {
   const { no } = useParams();
-  return <BatchRecordPage key={no} no={no} />;
+  return <BatchRecordPage key={no} no={no} partnerView={partnerView} />;
 }
 
-function BatchRecordPage({ no }: { no?: string }) {
+function BatchRecordPage({ no, partnerView }: { no?: string; partnerView: boolean }) {
   const identity = useDemoIdentity();
   const navigate = useNavigate();
   const location = useLocation();
-  const back = detailBack(location.state, "/settlement-batches", BACK_TO_RECON_LIST);
+  const back = partnerView
+    ? detailBack(location.state, "/bos/pv/recon", BACK_TO_REGION_RECON)
+    : detailBack(location.state, "/settlement-batches", BACK_TO_RECON_LIST);
   const [tab, setTab] = useState<BatchRecordTab>(() =>
     batchRecordTabs.find(({ id }) => id === location.state?.statementTab)?.id ?? "overview");
   const outgoingState = detailLinkState(location.pathname + location.search + location.hash, { ...location.state, statementTab: tab });
@@ -569,8 +572,9 @@ function BatchRecordPage({ no }: { no?: string }) {
   const detail = useReconDetail(no ?? null);
   const batch = detail.data;
   const wiring = detail.fail?.kind === "wiring";
-  const isAdmin = !identity || identity.role === "admin";
-  const flagsPending = batch != null && (batch.can_export == null || (isAdmin && (batch.can_rerun == null || batch.can_correct == null)));
+  const isAdmin = !partnerView && (!identity || identity.role === "admin");
+  const flagsPending = !partnerView && batch != null && (batch.can_export == null || (isAdmin && (batch.can_rerun == null || batch.can_correct == null)));
+  const showExport = batch != null && (!partnerView || batch.can_export === true);
 
   const [confirmRerun, setConfirmRerun] = useState(false);
   const [rerunError, setRerunError] = useState("");
@@ -629,11 +633,11 @@ function BatchRecordPage({ no }: { no?: string }) {
             <span className="customer-record-meta"><CalendarDays size={14} aria-hidden="true" /><span>自然月 {batch.period}</span></span>
           </div>}
         </div>
-        {batch && <div className="batch-record-actions">
-          <Button variant="outline" className="batch-record-export" onClick={exportDetail} disabled={batch.can_export !== true || exporting}
+        {batch && (showExport || isAdmin) && <div className="batch-record-actions">
+          {showExport && <Button variant="outline" className="batch-record-export" onClick={exportDetail} disabled={batch.can_export !== true || exporting}
             title={batch.can_export == null ? ACTION_FLAG_PENDING_NOTE : undefined}>
             <Download size={15} aria-hidden="true" />{exporting ? "正在导出…" : "导出本批账单明细"}
-          </Button>
+          </Button>}
           {isAdmin && <>
             <Button disabled={batch.can_rerun !== true}
               title={batch.can_rerun == null ? ACTION_FLAG_PENDING_NOTE : undefined}
@@ -654,7 +658,7 @@ function BatchRecordPage({ no }: { no?: string }) {
         {detail.fail.message} <Button variant="ghost" size="sm" onClick={detail.reload}>重试</Button>
       </p>}
       {!batch && detail.loading && !wiring && <p className="batch-record-note" role="status">正在读取对账批次…</p>}
-      {batch && <BatchRecordContent batch={batch} tab={tab} onTabChange={setTab} linkState={outgoingState} flagsPending={flagsPending} />}
+      {batch && <BatchRecordContent batch={batch} tab={tab} onTabChange={setTab} linkState={outgoingState} flagsPending={flagsPending} partnerView={partnerView} />}
 
       {confirmRerun && batch && <OpsDialog title={RERUN_DIALOG_TITLE} className="statement-run-dialog" onClose={closeRerun}>
         <form onSubmit={runRerun} aria-busy={rerunning}>
@@ -686,19 +690,20 @@ function BatchRecordPanel({ tab, active, children }: { tab: BatchRecordTab; acti
   </section>;
 }
 
-function BatchRecordContent({ batch, tab, onTabChange, linkState, flagsPending }: {
+function BatchRecordContent({ batch, tab, onTabChange, linkState, flagsPending, partnerView }: {
   batch: ReconDetailResult;
   tab: BatchRecordTab;
   onTabChange: (tab: BatchRecordTab) => void;
   linkState: DetailLinkState;
   flagsPending: boolean;
+  partnerView: boolean;
 }) {
   const missing = <span className="table-placeholder">—</span>;
   const gapText = batch.ticket_gap_failed ? WORD_FETCH_FAILED : BACKEND_NOT_WIRED;
   const gapCount = batch.ticket_gap_failed ? null : batch.ticket_gap_count;
   const tabs = batchRecordTabs.map((item) => ({ ...item, count: item.id === "bills" ? batch.detail_count : undefined }));
   return <>
-    <dl className="customer-record-metrics batch-record-metrics" aria-label="批次统计">
+    <dl className={`customer-record-metrics batch-record-metrics${partnerView ? " partner-record-metrics" : ""}`} aria-label="批次统计">
       <div>
         <dt><ClipboardList size={16} aria-hidden="true" />明细条数</dt>
         <dd><strong>{batch.detail_count}</strong><span className="batch-record-unit">条</span></dd>
@@ -708,14 +713,14 @@ function BatchRecordContent({ batch, tab, onTabChange, linkState, flagsPending }
         <dd><strong>{moneyFromCents(batch.base_cents)}</strong><small>本批有效账单的分成基数合计</small></dd>
       </div>
       <div className="batch-record-metric-primary">
-        <dt><CircleDollarSign size={16} aria-hidden="true" />分成金额</dt>
+        <dt><CircleDollarSign size={16} aria-hidden="true" />{partnerView ? "本方分成金额" : "分成金额"}</dt>
         <dd><strong>{moneyFromCents(batch.share_cents)}</strong></dd>
       </div>
-      <div>
+      {!partnerView && <div>
         <dt><ScrollText size={16} aria-hidden="true" />{TICKET_GAP_LABEL}</dt>
         <dd>{gapCount == null ? <span className="batch-record-unavailable">{gapText}</span>
           : <><strong>{gapCount}</strong><span className="batch-record-unit">个</span></>}</dd>
-      </div>
+      </div>}
     </dl>
 
     <div className="record-tabs-frame">
@@ -734,21 +739,21 @@ function BatchRecordContent({ batch, tab, onTabChange, linkState, flagsPending }
       </BatchRecordPanel>
 
       <BatchRecordPanel tab="bills" active={tab}>
-        <BatchBillingTable items={batch.items} linkState={linkState} />
+        <BatchBillingTable items={batch.items} linkState={linkState} billListPath={partnerView ? "/bos/pv/bill-detail" : "/settlement-bills"} />
       </BatchRecordPanel>
 
       <BatchRecordPanel tab="execution" active={tab}>
         <dl className="ops-record-summary batch-record-facts">
           <div><dt>批次状态</dt><dd><OpsStatus tone={batchTone[batch.status]}>{BATCH_STATUS_TEXT[batch.status]}</OpsStatus></dd></div>
           <div><dt>触发方式</dt><dd>{TRIGGER_TYPE_TEXT[batch.trigger_type]}</dd></div>
-          <div><dt>执行人</dt><dd title={batch.operator_user_id ?? undefined}>{executorText(batch)}</dd></div>
+          {!partnerView && <div><dt>执行人</dt><dd title={batch.operator_user_id ?? undefined}>{executorText(batch)}</dd></div>}
           <div><dt>执行时间</dt><dd title={batch.executed_at ?? undefined}>{batch.executed_at ? localTime(batch.executed_at) : missing}</dd></div>
         </dl>
-        {(batch.status === "failed" || batch.status === "voided") && batch.fail_reason && <div className="batch-record-note batch-record-note-error" role="alert">
+        {!partnerView && (batch.status === "failed" || batch.status === "voided") && batch.fail_reason && <div className="batch-record-note batch-record-note-error" role="alert">
           <TriangleAlert size={16} aria-hidden="true" /><p>{batch.fail_reason}</p>
         </div>}
         {batch.status === "voided" && batch.voided_by_batch_no && <div className="batch-record-note" role="note">
-          <p>{VOIDED_BY_PREFIX} <Link className="ops-table-action" to={batchPath(batch.holder_id, batch.voided_by_batch_no)} state={linkState}>
+          <p>{VOIDED_BY_PREFIX} <Link className="ops-table-action" to={partnerView ? partnerReconDetailPath(batch.voided_by_batch_no) : batchPath(batch.holder_id, batch.voided_by_batch_no)} state={linkState}>
             {batch.voided_by_batch_no}<ArrowRight size={14} aria-hidden="true" />
           </Link> 作废。</p>
         </div>}
@@ -768,7 +773,7 @@ const batchBillColumns: readonly SettlementLedgerColumn[] = [
   { label: "恒 0 说明", width: 132 },
 ];
 
-function BatchBillingTable({ items, linkState }: { items: ReconDetailResult["items"]; linkState: DetailLinkState }) {
+function BatchBillingTable({ items, linkState, billListPath }: { items: ReconDetailResult["items"]; linkState: DetailLinkState; billListPath: string }) {
   const table = useSettlementLedgerTable(batchBillColumns);
   return <div className={`${table.className} batch-record-table`} role="region" aria-label="本批账单明细,可横向滚动查看字段" tabIndex={0} ref={table.ref}>
     <table className="ops-table settlement-ledger" style={{ minWidth: table.minWidth }} aria-label="本批账单明细">
@@ -787,7 +792,7 @@ function BatchBillingTable({ items, linkState }: { items: ReconDetailResult["ite
             <td className="settlement-ledger-number"><span className="ops-money settlement-ledger-share">{moneyFromCents(line.share_amount_cents)}</span></td>
             <td title={zeroNote}>{zeroNote ?? <span className="table-placeholder">—</span>}</td>
             <td className="settlement-ledger-action">
-              <Link className="ops-table-action" to={`/settlement-bills/${encodeURIComponent(line.bill_detail_id)}`} state={linkState}>
+              <Link className="ops-table-action" to={`${billListPath}/${encodeURIComponent(line.bill_detail_id)}`} state={linkState}>
                 详情<ArrowRight size={14} aria-hidden="true" />
               </Link>
             </td>
@@ -912,13 +917,13 @@ function BillRecordPanel({ tab, active, children }: { tab: BillRecordTab; active
   </section>;
 }
 
-function BillBatchLink({ holderId, number, linkState }: { holderId: string; number: string; linkState: DetailLinkState }) {
-  return <Link className="ops-table-action bill-record-batch-link" to={batchPath(holderId, number)} state={linkState}>
+function BillBatchLink({ to, number, linkState }: { to: string; number: string; linkState: DetailLinkState }) {
+  return <Link className="ops-table-action bill-record-batch-link" to={to} state={linkState}>
     <span>{number}</span><ArrowRight size={14} aria-hidden="true" />
   </Link>;
 }
 
-function BillRecordContent({ bill }: { bill: BillDetailResult }) {
+function BillRecordContent({ bill, partnerView }: { bill: BillDetailResult; partnerView: boolean }) {
   const location = useLocation();
   const [tab, setTab] = useState<BillRecordTab>(() => billRecordTabs.find(({ id }) => id === location.state?.billTab)?.id ?? "billing");
   const outgoingState = detailLinkState(location.pathname + location.search + location.hash, { ...location.state, billTab: tab });
@@ -1000,11 +1005,10 @@ function BillRecordContent({ bill }: { bill: BillDetailResult }) {
         <dl className="ops-record-summary bill-record-facts">
           <div><dt>分成方</dt><dd>{bill.holder_name || missing}</dd></div>
           <div><dt>分成方式与取值</dt><dd>{settleTextFromSnapshot(bill.share_mode, bill.share_value)}</dd></div>
-          <div><dt>所属对账单号</dt><dd><BillBatchLink holderId={bill.holder_id} number={bill.batch_no} linkState={outgoingState} /></dd></div>
+          <div><dt>所属对账单号</dt><dd><BillBatchLink to={partnerView ? partnerReconDetailPath(bill.batch_no) : batchPath(bill.holder_id, bill.batch_no)} number={bill.batch_no} linkState={outgoingState} /></dd></div>
         </dl>
         {bill.base_floor_protected && <p className="bill-record-note" role="note">{BASE_FLOOR_NOTE}</p>}
-        {/* 仅在服务端下发其他分成方时展示。 */}
-        {bill.other_parties != null && bill.other_parties.length > 0 && <div className="ops-table-wrap bill-record-table">
+        {!partnerView && bill.other_parties != null && bill.other_parties.length > 0 && <div className="ops-table-wrap bill-record-table">
           <table className="ops-table" aria-label="其他分成方">
             <OpsTableColumns widths={[40, 23, 37]} />
             <thead><tr><th scope="col">其他分成方</th><th scope="col" className="bill-record-number">分成金额</th><th scope="col">对账单号</th></tr></thead>
@@ -1012,7 +1016,7 @@ function BillRecordContent({ bill }: { bill: BillDetailResult }) {
               {bill.other_parties.map((party, i) => <tr key={`${party.holder_type}-${party.holder_name}-${i}`}>
                 <td><div className="bill-record-table-title"><strong className="table-cell-title">{party.holder_name}</strong><OpsTag tone={holderTone[party.holder_type]}>{HOLDER_TYPE_TEXT[party.holder_type]}</OpsTag></div></td>
                 <td className="bill-record-number"><span className="table-number">{moneyFromCents(party.share_amount_cents)}</span></td>
-                <td>{party.batch_no && party.holder_id ? <BillBatchLink holderId={party.holder_id} number={party.batch_no} linkState={outgoingState} /> : party.batch_no ?? missing}</td>
+                <td>{party.batch_no && party.holder_id ? <BillBatchLink to={batchPath(party.holder_id, party.batch_no)} number={party.batch_no} linkState={outgoingState} /> : party.batch_no ?? missing}</td>
               </tr>)}
             </tbody>
           </table>
@@ -1040,10 +1044,16 @@ function BillRecordContent({ bill }: { bill: BillDetailResult }) {
   </>;
 }
 
-export function SettlementBillRecordPage() {
+export function SettlementBillRecordPage({ partnerView = false }: { partnerView?: boolean }) {
   const { index } = useParams();
+  return <BillRecordPage key={index} index={index} partnerView={partnerView} />;
+}
+
+function BillRecordPage({ index, partnerView }: { index?: string; partnerView: boolean }) {
   const location = useLocation();
-  const back = detailBack(location.state, "/settlement-bills", BACK_TO_BILL_LIST);
+  const back = partnerView
+    ? detailBack(location.state, "/bos/pv/recon", BACK_TO_REGION_RECON)
+    : detailBack(location.state, "/settlement-bills", BACK_TO_BILL_LIST);
 
   const detail = useBillDetail(index ?? null);
   const bill = detail.data;
@@ -1073,7 +1083,7 @@ export function SettlementBillRecordPage() {
         {detail.fail.message} <Button variant="ghost" size="sm" onClick={detail.reload}>重试</Button>
       </p>}
       {!bill && detail.loading && <p className="bill-record-placeholder" role="status">正在读取账单明细…</p>}
-      {bill && <BillRecordContent key={bill.bill_detail_id} bill={bill} />}
+      {bill && <BillRecordContent key={bill.bill_detail_id} bill={bill} partnerView={partnerView} />}
     </article>
   );
 }

+ 12 - 0
web-scaffold/src/pages/__tests__/settlement-bill-record.test.tsx

@@ -124,3 +124,15 @@ it("从账单进入对账批次,返回恢复原页签,再返回带筛选和
   fireEvent.click(screen.getByRole("link", { name: "返回账单明细" }));
   expect(screen.getByLabelText("账单列表参数").textContent).toBe("?month=2026-10&page=3");
 });
+
+it("合伙人账单只显示本方分成,并链接到本方对账批次", async () => {
+  vi.mocked(billGetDetail).mockResolvedValue({ ...bill, holder_type: "partner" });
+  render(<MemoryRouter initialEntries={["/bos/pv/bill-detail/BILL-001"]}>
+    <Routes><Route path="/bos/pv/bill-detail/:index" element={<SettlementBillRecordPage partnerView />} /></Routes>
+  </MemoryRouter>);
+
+  fireEvent.click(await screen.findByRole("tab", { name: "分成与对账" }));
+  expect(screen.queryByText("渠道伙伴")).toBeNull();
+  expect(screen.getByRole("link", { name: "RECON-001" }).getAttribute("href")).toBe("/bos/pv/recon/RECON-001");
+  expect(screen.getByRole("link", { name: "返回本运营区域对账" }).getAttribute("href")).toBe("/bos/pv/recon");
+});

+ 33 - 1
web-scaffold/src/pages/__tests__/settlement-statement-record.test.tsx

@@ -1,5 +1,5 @@
 import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
-import { MemoryRouter, Route, Routes } from "react-router";
+import { MemoryRouter, Route, Routes, useLocation } from "react-router";
 import { afterEach, beforeEach, expect, it, vi } from "vitest";
 import { billGetDetail, reconGetDetail, reconRerun } from "../../lib/api/bos";
 import type { ReconDetailResult } from "../../lib/api/types";
@@ -100,3 +100,35 @@ it("用服务端动作位控制按钮,补跑失败可重试,成功后从新
   fireEvent.click(screen.getByRole("link", { name: "返回批次详情" }));
   expect(await screen.findByRole("tabpanel", { name: "执行与追溯" })).toBeTruthy();
 });
+
+function PartnerReconListState() {
+  const { state } = useLocation();
+  return <output aria-label="对账清单筛选">{JSON.stringify(state?.partyList)}</output>;
+}
+
+it("合伙人批次只读,账单下钻和返回保留原批次页签和列表筛选", async () => {
+  vi.mocked(reconGetDetail).mockResolvedValue({ ...batch, holder_type: "partner", can_rerun: true, can_correct: true });
+  render(<MemoryRouter initialEntries={[{
+    pathname: "/bos/pv/recon/RECON-001",
+    state: { from: "/bos/pv/recon", previousState: { partyList: { month: "2026-10", page: 3 } } },
+  }]}>
+    <Routes>
+      <Route path="/bos/pv/recon" element={<PartnerReconListState />} />
+      <Route path="/bos/pv/recon/:no" element={<SettlementStatementRecordPage partnerView />} />
+      <Route path="/bos/pv/bill-detail/:index" element={<SettlementBillRecordPage partnerView />} />
+    </Routes>
+  </MemoryRouter>);
+
+  const tabs = within(await screen.findByRole("tablist", { name: "对账清单详情视图" }));
+  expect(screen.queryByRole("button", { name: "人工补跑" })).toBeNull();
+  expect(screen.queryByRole("button", { name: "登记更正" })).toBeNull();
+  expect(screen.getByRole("button", { name: "导出本批账单明细" })).toBeTruthy();
+  fireEvent.click(tabs.getByRole("tab", { name: /账单明细/ }));
+  const link = screen.getByRole("link", { name: "详情" });
+  expect(link.getAttribute("href")).toBe("/bos/pv/bill-detail/BILL-001");
+  fireEvent.click(link);
+  fireEvent.click(await screen.findByRole("link", { name: "返回对账清单详情" }));
+  expect(await screen.findByRole("tabpanel", { name: /账单明细/ })).toBeTruthy();
+  fireEvent.click(screen.getByRole("link", { name: "返回本运营区域对账" }));
+  expect(screen.getByLabelText("对账清单筛选").textContent).toBe(JSON.stringify({ month: "2026-10", page: 3 }));
+});

+ 4 - 0
web-scaffold/src/styles/record-detail.css

@@ -96,6 +96,10 @@
   background: var(--card);
 }
 
+.customer-record-metrics.partner-record-metrics {
+  grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr));
+}
+
 .customer-record-metrics dt svg {
   flex: none;
   color: var(--primary-soft-foreground);

+ 3 - 1
web-scaffold/tests/demo-navigation.test.mjs

@@ -61,7 +61,7 @@ function prototypeMenu(identity) {
     { title: "全部工单", section: "" },
   ];
   if (identity.role === "partner") return [
-    { title: "本区域对账", section: "对账与分成" },
+    { title: "本运营区域对账", section: "对账与分成" },
     { title: "客户清单", section: "客户与合同" },
     { title: "合同清单", section: "客户与合同" },
     { title: "本方变更记录", section: "变更与范围" },
@@ -104,12 +104,14 @@ test("主子账号差异及角色首屏遵循原型,不落到总运营概览",
 
 test("第 8 册详情路由可高亮正确菜单,旧运营侧路由不越权高亮", () => {
   const partner = getDemoNavigation(findDemoIdentity("邹合"));
+  assert.equal(getActiveDemoNavigation(partner, "/bos/pv/recon/recon-1").id, "region");
   assert.equal(getActiveDemoNavigation(partner, "/bos/pv/bill-detail/bill-1").id, "region");
   assert.equal(getActiveDemoNavigation(partner, "/bos/pv/customer/KL-2026-0001").id, "enterprises");
   assert.equal(getActiveDemoNavigation(partner, "/bos/pv/n").id, "changeLog");
   assert.equal(getActiveDemoNavigation(partner, "/settlement-batches/pt-0/2026-10"), undefined);
   assert.equal(getActiveDemoNavigation(partner, "/customers-other"), undefined);
   const admin = getDemoNavigation(findDemoIdentity("林管"));
+  assert.equal(getActiveDemoNavigation(admin, "/bos/pv/recon/recon-1"), undefined);
   assert.equal(getActiveDemoNavigation(admin, "/organization/maintenance-teams/mt-0/accounts").id, "maintenanceTeams");
   assert.equal(getActiveDemoNavigation(admin, "/").id, "home");
 });