|
@@ -12,7 +12,7 @@ import { useDetailLinkState, type detailBack } from "../lib/detail-navigation";
|
|
|
type RecordBack = ReturnType<typeof detailBack>;
|
|
type RecordBack = ReturnType<typeof detailBack>;
|
|
|
type RecordSection = { id: string; label: string; count?: number; content: ReactNode };
|
|
type RecordSection = { id: string; label: string; count?: number; content: ReactNode };
|
|
|
type RecordMetric = { label: string; icon: ReactNode; value: ReactNode };
|
|
type RecordMetric = { label: string; icon: ReactNode; value: ReactNode };
|
|
|
-type PartnerRecordState = { back: RecordBack; recordId: string; loading: boolean; fallback?: ReactNode };
|
|
|
|
|
|
|
+type PartyRecordState = { back: RecordBack; recordId: string; loading: boolean; fallback?: ReactNode };
|
|
|
|
|
|
|
|
const recordTypes = {
|
|
const recordTypes = {
|
|
|
CUSTOMER: { title: "客户详情", icon: Building2 },
|
|
CUSTOMER: { title: "客户详情", icon: Building2 },
|
|
@@ -28,7 +28,7 @@ function RecordFacts({ fields }: { fields: readonly (readonly [string, ReactNode
|
|
|
</dl>;
|
|
</dl>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function PartnerRecordLayout({ back, recordId, loading, fallback, type, number = recordId, title, context, metrics, sections }: PartnerRecordState & {
|
|
|
|
|
|
|
+function PartyRecordLayout({ back, recordId, loading, fallback, type, number = recordId, title, context, metrics, sections }: PartyRecordState & {
|
|
|
type: keyof typeof recordTypes;
|
|
type: keyof typeof recordTypes;
|
|
|
number?: string;
|
|
number?: string;
|
|
|
title?: string;
|
|
title?: string;
|
|
@@ -41,7 +41,7 @@ function PartnerRecordLayout({ back, recordId, loading, fallback, type, number =
|
|
|
const recordType = recordTypes[type];
|
|
const recordType = recordTypes[type];
|
|
|
const Icon = recordType.icon;
|
|
const Icon = recordType.icon;
|
|
|
const pending = loading && !sections;
|
|
const pending = loading && !sections;
|
|
|
- const prefix = `partner-${type.toLowerCase()}`;
|
|
|
|
|
|
|
+ const prefix = `party-${type.toLowerCase()}`;
|
|
|
return <article className="ops-page ops-record-page record-detail">
|
|
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>
|
|
<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">
|
|
<header className="customer-record-masthead">
|
|
@@ -50,14 +50,14 @@ function PartnerRecordLayout({ back, recordId, loading, fallback, type, number =
|
|
|
<p className="customer-record-id">{type} <span aria-hidden="true">·</span> <span>{number}</span></p>
|
|
<p className="customer-record-id">{type} <span aria-hidden="true">·</span> <span>{number}</span></p>
|
|
|
<h1 className="customer-record-title">{pending ? <>
|
|
<h1 className="customer-record-title">{pending ? <>
|
|
|
<span className="sr-only">{recordType.title}</span>
|
|
<span className="sr-only">{recordType.title}</span>
|
|
|
- <span className="partner-record-title-placeholder" aria-hidden="true" />
|
|
|
|
|
|
|
+ <span className="party-record-title-placeholder" aria-hidden="true" />
|
|
|
</> : title || recordType.title}</h1>
|
|
</> : title || recordType.title}</h1>
|
|
|
<div className="customer-record-tags">{pending
|
|
<div className="customer-record-tags">{pending
|
|
|
- ? <span className="partner-record-tags-placeholder" aria-hidden="true" />
|
|
|
|
|
|
|
+ ? <span className="party-record-tags-placeholder" aria-hidden="true" />
|
|
|
: context}</div>
|
|
: context}</div>
|
|
|
</div>
|
|
</div>
|
|
|
</header>
|
|
</header>
|
|
|
- {metrics && <dl className="customer-record-metrics partner-record-metrics" aria-label="业务摘要">
|
|
|
|
|
|
|
+ {metrics && <dl className="customer-record-metrics party-record-metrics" aria-label="业务摘要">
|
|
|
{metrics.map((metric) => <div key={metric.label}>
|
|
{metrics.map((metric) => <div key={metric.label}>
|
|
|
<dt>{metric.icon}{metric.label}</dt><dd><strong>{metric.value}</strong></dd>
|
|
<dt>{metric.icon}{metric.label}</dt><dd><strong>{metric.value}</strong></dd>
|
|
|
</div>)}
|
|
</div>)}
|
|
@@ -68,12 +68,12 @@ function PartnerRecordLayout({ back, recordId, loading, fallback, type, number =
|
|
|
id={`${prefix}-panel-${section.id}`} role="tabpanel" aria-labelledby={`${prefix}-tab-${section.id}`} hidden={active !== section.id} tabIndex={0}>
|
|
id={`${prefix}-panel-${section.id}`} role="tabpanel" aria-labelledby={`${prefix}-tab-${section.id}`} hidden={active !== section.id} tabIndex={0}>
|
|
|
{section.content}
|
|
{section.content}
|
|
|
</section>)}
|
|
</section>)}
|
|
|
- </div> : pending ? <div className="record-tabs-frame"><p className="partner-record-loading" role="status">正在读取{recordType.title}…</p></div> : fallback}
|
|
|
|
|
|
|
+ </div> : pending ? <div className="record-tabs-frame"><p className="party-record-loading" role="status">正在读取{recordType.title}…</p></div> : fallback}
|
|
|
</article>;
|
|
</article>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function PartnerCustomerRecord({ data, ...state }: PartnerRecordState & { data: CustomerDetail | null }) {
|
|
|
|
|
- if (!data) return <PartnerRecordLayout {...state} type="CUSTOMER" />;
|
|
|
|
|
|
|
+export function PartyCustomerRecord({ data, ...state }: PartyRecordState & { data: CustomerDetail | null }) {
|
|
|
|
|
+ if (!data) return <PartyRecordLayout {...state} type="CUSTOMER" />;
|
|
|
const customer = data.customer;
|
|
const customer = data.customer;
|
|
|
const region = data.region_mounts?.[0]?.path_name;
|
|
const region = data.region_mounts?.[0]?.path_name;
|
|
|
const subject = customer.subject_type ? label(SUBJECT_TYPE, customer.subject_type) : null;
|
|
const subject = customer.subject_type ? label(SUBJECT_TYPE, customer.subject_type) : null;
|
|
@@ -81,7 +81,7 @@ export function PartnerCustomerRecord({ data, ...state }: PartnerRecordState & {
|
|
|
const tone = status === "stopped" || status === "disabled" ? "danger"
|
|
const tone = status === "stopped" || status === "disabled" ? "danger"
|
|
|
: ["active", "normal", "in_use"].includes(status) ? "success" : "neutral";
|
|
: ["active", "normal", "in_use"].includes(status) ? "success" : "neutral";
|
|
|
|
|
|
|
|
- return <PartnerRecordLayout {...state} type="CUSTOMER" number={customer.customer_id} title={customer.customer_name}
|
|
|
|
|
|
|
+ return <PartyRecordLayout {...state} type="CUSTOMER" number={customer.customer_id} title={customer.customer_name}
|
|
|
context={<>
|
|
context={<>
|
|
|
{subject && <OpsTag tone="brand">{subject}</OpsTag>}
|
|
{subject && <OpsTag tone="brand">{subject}</OpsTag>}
|
|
|
{status && <OpsStatus tone={tone}>{label(ACCT_STATUS, status)}</OpsStatus>}
|
|
{status && <OpsStatus tone={tone}>{label(ACCT_STATUS, status)}</OpsStatus>}
|
|
@@ -103,7 +103,7 @@ export function PartnerCustomerRecord({ data, ...state }: PartnerRecordState & {
|
|
|
]} />;
|
|
]} />;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function PartnerRecordTable({ caption, columns, children }: { caption: string; columns: readonly string[]; children: ReactNode }) {
|
|
|
|
|
|
|
+function PartyRecordTable({ 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}>
|
|
return <div className="ops-table-wrap record-table-scroll" role="region" aria-label={caption} tabIndex={0}>
|
|
|
<table className="ops-table" aria-label={caption}>
|
|
<table className="ops-table" aria-label={caption}>
|
|
|
<thead><tr>{columns.map((column) => <th scope="col" key={column}>{column}</th>)}</tr></thead>
|
|
<thead><tr>{columns.map((column) => <th scope="col" key={column}>{column}</th>)}</tr></thead>
|
|
@@ -112,9 +112,9 @@ function PartnerRecordTable({ caption, columns, children }: { caption: string; c
|
|
|
</div>;
|
|
</div>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function PartnerContractRecord({ data, ...state }: PartnerRecordState & { data: ContractGetResult | null }) {
|
|
|
|
|
|
|
+export function PartyContractRecord({ data, customerListPath, ...state }: PartyRecordState & { data: ContractGetResult | null; customerListPath: string }) {
|
|
|
const linkState = useDetailLinkState();
|
|
const linkState = useDetailLinkState();
|
|
|
- if (!data) return <PartnerRecordLayout {...state} type="CONTRACT" />;
|
|
|
|
|
|
|
+ if (!data) return <PartyRecordLayout {...state} type="CONTRACT" />;
|
|
|
const profile = data.customer_profile;
|
|
const profile = data.customer_profile;
|
|
|
const items = data.service_items;
|
|
const items = data.service_items;
|
|
|
const subscriptions = data.subscriptions;
|
|
const subscriptions = data.subscriptions;
|
|
@@ -123,9 +123,9 @@ export function PartnerContractRecord({ data, ...state }: PartnerRecordState & {
|
|
|
const amount = data.contract_amount_cents == null ? null : money(data.contract_amount_cents);
|
|
const amount = data.contract_amount_cents == null ? null : money(data.contract_amount_cents);
|
|
|
const customerName = profile?.customer_name || data.customer_name;
|
|
const customerName = profile?.customer_name || data.customer_name;
|
|
|
const customerLink = profile && data.customer_id && customerName
|
|
const customerLink = profile && data.customer_id && customerName
|
|
|
- ? <Link className="contract-ref-link" to={`/bos/pv/customer/${encodeURIComponent(data.customer_id)}`} state={linkState}>{customerName}</Link>
|
|
|
|
|
|
|
+ ? <Link className="contract-ref-link" to={`${customerListPath}/${encodeURIComponent(data.customer_id)}`} state={linkState}>{customerName}</Link>
|
|
|
: customerName;
|
|
: customerName;
|
|
|
- return <PartnerRecordLayout {...state} type="CONTRACT" number={data.contract_id} title={data.contract_no}
|
|
|
|
|
|
|
+ return <PartyRecordLayout {...state} type="CONTRACT" number={data.contract_id} title={data.contract_no}
|
|
|
context={<>
|
|
context={<>
|
|
|
{status && <OpsStatus tone={contractStatusTone[status]}>{status}</OpsStatus>}
|
|
{status && <OpsStatus tone={contractStatusTone[status]}>{status}</OpsStatus>}
|
|
|
{data.opened != null && <OpsStatus tone={data.opened ? "success" : "warning"}>{data.opened ? "已开通" : "未开通"}</OpsStatus>}
|
|
{data.opened != null && <OpsStatus tone={data.opened ? "success" : "warning"}>{data.opened ? "已开通" : "未开通"}</OpsStatus>}
|
|
@@ -153,7 +153,7 @@ export function PartnerContractRecord({ data, ...state }: PartnerRecordState & {
|
|
|
["实际开通日", data.actual_opened_at], ["服务期", months], ["合同总额", amount],
|
|
["实际开通日", data.actual_opened_at], ["服务期", months], ["合同总额", amount],
|
|
|
["折扣率", data.discount_rate_pct == null ? null : `${data.discount_rate_pct}%`],
|
|
["折扣率", data.discount_rate_pct == null ? null : `${data.discount_rate_pct}%`],
|
|
|
]} /> },
|
|
]} /> },
|
|
|
- { id: "services", label: "服务构成", count: items?.length, content: <PartnerRecordTable caption="服务构成"
|
|
|
|
|
|
|
+ { id: "services", label: "服务构成", count: items?.length, content: <PartyRecordTable caption="服务构成"
|
|
|
columns={["套餐名称", "交付形态", "线路出口", "订阅份数", "分账号额度"]}>
|
|
columns={["套餐名称", "交付形态", "线路出口", "订阅份数", "分账号额度"]}>
|
|
|
{items?.map((item, index) => <tr key={item.item_id ?? index}>
|
|
{items?.map((item, index) => <tr key={item.item_id ?? index}>
|
|
|
<td><span className="table-cell-title">{item.plan_name || empty}</span></td>
|
|
<td><span className="table-cell-title">{item.plan_name || empty}</span></td>
|
|
@@ -163,8 +163,8 @@ export function PartnerContractRecord({ data, ...state }: PartnerRecordState & {
|
|
|
<td className="table-number">{item.sub_account_quota == null ? empty : `${item.sub_account_quota} 个`}</td>
|
|
<td className="table-number">{item.sub_account_quota == null ? empty : `${item.sub_account_quota} 个`}</td>
|
|
|
</tr>)}
|
|
</tr>)}
|
|
|
{!items?.length && <OpsTableEmpty colSpan={5}>{items ? "暂无服务条目" : "服务构成未下发"}</OpsTableEmpty>}
|
|
{!items?.length && <OpsTableEmpty colSpan={5}>{items ? "暂无服务条目" : "服务构成未下发"}</OpsTableEmpty>}
|
|
|
- </PartnerRecordTable> },
|
|
|
|
|
- { id: "subscriptions", label: "关联订阅", count: subscriptions?.length, content: <PartnerRecordTable caption="关联订阅"
|
|
|
|
|
|
|
+ </PartyRecordTable> },
|
|
|
|
|
+ { id: "subscriptions", label: "关联订阅", count: subscriptions?.length, content: <PartyRecordTable caption="关联订阅"
|
|
|
columns={["套餐 / 订阅编号", "订阅期间", "年订阅价格", "月结算标准", "状态"]}>
|
|
columns={["套餐 / 订阅编号", "订阅期间", "年订阅价格", "月结算标准", "状态"]}>
|
|
|
{subscriptions?.map((order) => <tr key={order.subscription_id}>
|
|
{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><div className="table-cell-title">{order.plan_name || empty}</div><small>{order.subscription_id}</small></td>
|
|
@@ -174,6 +174,6 @@ export function PartnerContractRecord({ data, ...state }: PartnerRecordState & {
|
|
|
<td>{order.status ? <OpsStatus tone={order.status === "active" ? "success" : order.status === "expired" ? "warning" : "neutral"}>{label(ORDER_STATUS, order.status)}</OpsStatus> : empty}</td>
|
|
<td>{order.status ? <OpsStatus tone={order.status === "active" ? "success" : order.status === "expired" ? "warning" : "neutral"}>{label(ORDER_STATUS, order.status)}</OpsStatus> : empty}</td>
|
|
|
</tr>)}
|
|
</tr>)}
|
|
|
{!subscriptions?.length && <OpsTableEmpty colSpan={5}>{subscriptions ? "暂无关联订阅" : "关联订阅未下发"}</OpsTableEmpty>}
|
|
{!subscriptions?.length && <OpsTableEmpty colSpan={5}>{subscriptions ? "暂无关联订阅" : "关联订阅未下发"}</OpsTableEmpty>}
|
|
|
- </PartnerRecordTable> },
|
|
|
|
|
|
|
+ </PartyRecordTable> },
|
|
|
]} />;
|
|
]} />;
|
|
|
}
|
|
}
|