|
|
@@ -10,7 +10,7 @@
|
|
|
*/
|
|
|
import { useEffect, useId, useState, type FormEvent, type ReactNode } from "react";
|
|
|
import { PageIntro } from "../components/PageIntro";
|
|
|
-import { ArrowLeft, ArrowRight, Building2, Calculator, CalendarClock, CalendarDays, ChevronDown, CircleDollarSign, Download, FileSpreadsheet, ListFilter, Receipt, RefreshCw, ScrollText, Search, TriangleAlert, X } from "lucide-react";
|
|
|
+import { ArrowLeft, ArrowRight, Building2, Calculator, CalendarClock, CalendarDays, ChevronDown, CircleDollarSign, ClipboardList, Download, FilePenLine, FileSpreadsheet, ListFilter, Receipt, RefreshCw, ScrollText, Search, TriangleAlert, X } from "lucide-react";
|
|
|
import { Link, useLocation, useNavigate, useParams, useSearchParams } from "react-router";
|
|
|
import { Button } from "../components/ui/button";
|
|
|
import { SearchInput } from "../components/ui/search-input";
|
|
|
@@ -59,7 +59,6 @@ import {
|
|
|
saveReconExportCsv,
|
|
|
STAT_CARDS,
|
|
|
TICKET_GAP_LABEL,
|
|
|
- ticketGapText,
|
|
|
TRIGGER_TYPE_TEXT,
|
|
|
VOIDED_BY_PREFIX,
|
|
|
ZERO_NOTE_TEXT,
|
|
|
@@ -546,224 +545,258 @@ export function SettlementStatementListPage() {
|
|
|
|
|
|
/* ── 批次详情(14.2) ───────────────────────────────────────────── */
|
|
|
|
|
|
+const batchRecordTabs = [
|
|
|
+ { id: "overview", label: "批次概况" },
|
|
|
+ { id: "bills", label: "账单明细" },
|
|
|
+ { id: "execution", label: "执行与追溯" },
|
|
|
+] as const;
|
|
|
+type BatchRecordTab = typeof batchRecordTabs[number]["id"];
|
|
|
+
|
|
|
export function SettlementStatementRecordPage() {
|
|
|
+ const { no } = useParams();
|
|
|
+ return <BatchRecordPage key={no} no={no} />;
|
|
|
+}
|
|
|
+
|
|
|
+function BatchRecordPage({ no }: { no?: string }) {
|
|
|
const identity = useDemoIdentity();
|
|
|
const navigate = useNavigate();
|
|
|
const location = useLocation();
|
|
|
- const outgoingState = useDetailLinkState();
|
|
|
- const { no } = useParams();
|
|
|
const back = 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 });
|
|
|
|
|
|
const detail = useReconDetail(no ?? null);
|
|
|
- const d = detail.data;
|
|
|
+ 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 [confirmRerun, setConfirmRerun] = useState(false);
|
|
|
const [rerunError, setRerunError] = useState("");
|
|
|
- const [busy, setBusy] = useState(false);
|
|
|
+ const [rerunning, setRerunning] = useState(false);
|
|
|
+ const [exporting, setExporting] = useState(false);
|
|
|
const [notice, setNotice] = useState("");
|
|
|
|
|
|
- function runRerun() {
|
|
|
- if (!d) return;
|
|
|
- setBusy(true);
|
|
|
+ async function runRerun(event: FormEvent<HTMLFormElement>) {
|
|
|
+ event.preventDefault();
|
|
|
+ if (!batch || !isAdmin || batch.can_rerun !== true || rerunning) return;
|
|
|
+ setRerunning(true);
|
|
|
setRerunError("");
|
|
|
- submitReconRerun({ holder_type: d.holder_type, holder_id: d.holder_id, period: d.period })
|
|
|
- .then((res) => {
|
|
|
- setConfirmRerun(false);
|
|
|
- // 补跑成功 ⇒ 原批次作废、生成新批;直接落到新批详情(来路保留)。
|
|
|
- navigate(batchPath(d.holder_id, res.batch_no), { state: outgoingState });
|
|
|
- })
|
|
|
- .catch((e: unknown) => {
|
|
|
- // 四道闸(60502→60503→60504→60506)/KLT-S407:文案直读后端 message。
|
|
|
- setRerunError(e instanceof Error && e.message ? e.message : "补跑失败,请重试。");
|
|
|
- setBusy(false);
|
|
|
- });
|
|
|
+ try {
|
|
|
+ const result = await submitReconRerun({ holder_type: batch.holder_type, holder_id: batch.holder_id, period: batch.period });
|
|
|
+ setConfirmRerun(false);
|
|
|
+ navigate(batchPath(batch.holder_id, result.batch_no), { state: outgoingState });
|
|
|
+ } catch (error) {
|
|
|
+ setRerunError(error instanceof Error && error.message ? error.message : "补跑失败,请重试。");
|
|
|
+ } finally {
|
|
|
+ setRerunning(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async function exportDetail() {
|
|
|
+ if (!batch || batch.can_export !== true || exporting) return;
|
|
|
+ setExporting(true);
|
|
|
+ try {
|
|
|
+ const result = await reconExportDetail({ batch_id: batch.batch_no });
|
|
|
+ setNotice(saveReconExportCsv(result) ? exportResultNote(result) : EXPORT_EMPTY_NOTE);
|
|
|
+ } catch (error) {
|
|
|
+ setNotice(error instanceof Error && error.message ? error.message : WORD_FETCH_FAILED);
|
|
|
+ } finally {
|
|
|
+ setExporting(false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- function exportDetail() {
|
|
|
- if (!d) return;
|
|
|
- reconExportDetail({ batch_id: d.batch_no })
|
|
|
- .then((res) => setNotice(saveReconExportCsv(res) ? exportResultNote(res) : EXPORT_EMPTY_NOTE))
|
|
|
- .catch((e: unknown) => setNotice(e instanceof Error && e.message ? e.message : WORD_FETCH_FAILED));
|
|
|
+ function closeRerun() {
|
|
|
+ if (!rerunning) setConfirmRerun(false);
|
|
|
}
|
|
|
|
|
|
+ const batchNumber = batch?.batch_no ?? no;
|
|
|
return (
|
|
|
- <article className="ops-page reconcile-record">
|
|
|
+ <article className="ops-page ops-record-page record-detail batch-record">
|
|
|
<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 batch-record-masthead">
|
|
|
+ <div className="customer-hero-symbol" aria-hidden="true"><FileSpreadsheet size={26} /></div>
|
|
|
+ <div className="customer-hero-copy">
|
|
|
+ <p className="customer-record-id">RECONCILIATION{batchNumber && <><span aria-hidden="true">·</span><span>{batchNumber}</span></>}</p>
|
|
|
+ <h1 className="customer-record-title">对账清单详情</h1>
|
|
|
+ {batch && <div className="customer-record-tags batch-record-context">
|
|
|
+ <OpsStatus tone={batchTone[batch.status]}>{BATCH_STATUS_TEXT[batch.status]}</OpsStatus>
|
|
|
+ <span className="customer-record-meta">
|
|
|
+ <OpsTag tone={holderTone[batch.holder_type]}>{HOLDER_TYPE_TEXT[batch.holder_type]}</OpsTag>
|
|
|
+ {batch.holder_name && <strong>{batch.holder_name}</strong>}
|
|
|
+ </span>
|
|
|
+ <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" 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>
|
|
|
+ {isAdmin && <>
|
|
|
+ <Button variant="outline" disabled={batch.can_rerun !== true}
|
|
|
+ title={batch.can_rerun == null ? ACTION_FLAG_PENDING_NOTE : undefined}
|
|
|
+ onClick={() => { setRerunError(""); setConfirmRerun(true); }}>
|
|
|
+ <RefreshCw size={15} aria-hidden="true" />人工补跑
|
|
|
+ </Button>
|
|
|
+ <Button variant="outline" disabled={batch.can_correct !== true}
|
|
|
+ title={batch.can_correct == null ? ACTION_FLAG_PENDING_NOTE : undefined}
|
|
|
+ onClick={() => navigate("/correction-notes", { state: { ...outgoingState, ref: batch.batch_no } })}>
|
|
|
+ <FilePenLine size={15} aria-hidden="true" />登记更正
|
|
|
+ </Button>
|
|
|
+ </>}
|
|
|
+ </div>}
|
|
|
+ </header>
|
|
|
|
|
|
{wiring && <p className="ops-import-note" role="status">{RECON_WIRING_NOTE}</p>}
|
|
|
- {detail.fail && !wiring && (
|
|
|
- <p className="ops-form-error" role="alert">{detail.fail.message} <Button variant="ghost" size="sm" onClick={detail.reload}>重试</Button></p>
|
|
|
- )}
|
|
|
-
|
|
|
- {/* 契约占位分支:八字段头结构落位、值格「后端未下发」。 */}
|
|
|
- {(wiring || (!d && detail.loading)) && (
|
|
|
- <header className="reconcile-record-hero">
|
|
|
- <div className="reconcile-record-symbol"><FileSpreadsheet size={27} /></div>
|
|
|
- <div>
|
|
|
- <span className="reconcile-record-eyebrow">RECONCILIATION / {no}</span>
|
|
|
- <h1>批次详情</h1>
|
|
|
- <p>{detail.loading && !wiring ? "加载中…" : BACKEND_NOT_WIRED}</p>
|
|
|
- </div>
|
|
|
- </header>
|
|
|
- )}
|
|
|
-
|
|
|
- {d && <BatchDetailBody
|
|
|
- d={d}
|
|
|
- isAdmin={isAdmin}
|
|
|
- onRerun={() => { setRerunError(""); setConfirmRerun(true); }}
|
|
|
- onExport={exportDetail}
|
|
|
- onCorrect={() => navigate("/correction-notes", { state: { ...outgoingState, ref: d.batch_no } })}
|
|
|
- lineState={outgoingState}
|
|
|
- />}
|
|
|
-
|
|
|
- {confirmRerun && d && (
|
|
|
- <div className="ops-confirm-backdrop" role="presentation" onMouseDown={() => !busy && setConfirmRerun(false)}>
|
|
|
- <div className="ops-confirm" role="alertdialog" aria-modal="true" aria-labelledby="rerun-confirm-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
|
- <h2 id="rerun-confirm-title">{RERUN_DIALOG_TITLE}</h2>
|
|
|
- <p>{rerunScopeLine(d.holder_name, d.period)}</p>
|
|
|
- {/* failed 批补跑区追加句(§8.6 界面唯一落点之一)。 */}
|
|
|
- {d.status === "failed" && <p>{RERUN_VOID_NOTE}</p>}
|
|
|
- {rerunError && <p className="ops-form-error" role="alert">{rerunError}</p>}
|
|
|
- <div>
|
|
|
- <Button variant="outline" onClick={() => setConfirmRerun(false)} disabled={busy}>取消</Button>
|
|
|
- <Button onClick={runRerun} disabled={busy}>{busy ? "提交中…" : RERUN_SUBMIT}</Button>
|
|
|
+ {detail.fail && !wiring && <p className="ops-form-error" role="alert">
|
|
|
+ {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} />}
|
|
|
+
|
|
|
+ {confirmRerun && batch && <OpsDialog title={RERUN_DIALOG_TITLE} className="statement-run-dialog" onClose={closeRerun}>
|
|
|
+ <form onSubmit={runRerun} aria-busy={rerunning}>
|
|
|
+ <div className="statement-run-body">
|
|
|
+ <div className="statement-run-scope">
|
|
|
+ <CalendarClock size={19} aria-hidden="true" />
|
|
|
+ <strong>{rerunScopeLine(batch.holder_name, batch.period)}</strong>
|
|
|
</div>
|
|
|
+ {batch.status === "failed" && <div className="statement-run-impact">
|
|
|
+ <TriangleAlert size={16} aria-hidden="true" /><p>{RERUN_VOID_NOTE}</p>
|
|
|
+ </div>}
|
|
|
+ {rerunError && <p className="ops-form-error statement-run-error" role="alert">{rerunError}</p>}
|
|
|
</div>
|
|
|
- </div>
|
|
|
- )}
|
|
|
+ <footer>
|
|
|
+ <Button variant="outline" type="button" onClick={closeRerun} disabled={rerunning}>取消</Button>
|
|
|
+ <Button type="submit" disabled={rerunning || batch.can_rerun !== true}>{rerunning ? "正在补跑…" : RERUN_SUBMIT}</Button>
|
|
|
+ </footer>
|
|
|
+ </form>
|
|
|
+ </OpsDialog>}
|
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
|
</article>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-function BatchDetailBody({ d, isAdmin, onRerun, onExport, onCorrect, lineState }: {
|
|
|
- d: ReconDetailResult;
|
|
|
- isAdmin: boolean;
|
|
|
- onRerun: () => void;
|
|
|
- onExport: () => void;
|
|
|
- onCorrect: () => void;
|
|
|
- lineState: DetailLinkState;
|
|
|
-}) {
|
|
|
- // 动作可用性=服务端布尔位(与对账§5.5.4 同源常量;⚠️ 前端按角色自猜=第二套判据)。
|
|
|
- // null ⇒ 后端未下发 ⇒ 禁用+「可操作性位后端未下发」说明。
|
|
|
- const rerunEnabled = isAdmin && d.can_rerun === true;
|
|
|
- const exportEnabled = d.can_export === true;
|
|
|
- const correctEnabled = isAdmin && d.can_correct === true;
|
|
|
- const flagPending = d.can_rerun == null || d.can_export == null || d.can_correct == null;
|
|
|
- return (
|
|
|
- <>
|
|
|
- <header className="reconcile-record-hero">
|
|
|
- <div className="reconcile-record-symbol"><FileSpreadsheet size={27} /></div>
|
|
|
- <div>
|
|
|
- <span className="reconcile-record-eyebrow">RECONCILIATION / {d.batch_no}</span>
|
|
|
- <h1>批次详情</h1>
|
|
|
- <p>
|
|
|
- <strong>{d.holder_name}</strong>
|
|
|
- <span>{HOLDER_TYPE_TEXT[d.holder_type]}</span>
|
|
|
- <span>自然月 {d.period}</span>
|
|
|
- <span>{TRIGGER_TYPE_TEXT[d.trigger_type]}触发 · {executorText(d)}执行</span>
|
|
|
- </p>
|
|
|
- <div className="reconcile-hero-pills">
|
|
|
- <OpsStatus tone={batchTone[d.status]}>{BATCH_STATUS_TEXT[d.status]}</OpsStatus>
|
|
|
- <OpsTag tone={d.trigger_type === "manual" ? "warning" : "neutral"}>{TRIGGER_TYPE_TEXT[d.trigger_type]}触发</OpsTag>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </header>
|
|
|
+function BatchRecordPanel({ tab, active, children }: { tab: BatchRecordTab; active: BatchRecordTab; children: ReactNode }) {
|
|
|
+ return <section className="ops-record-card record-tab-panel batch-record-panel" id={`batch-record-panel-${tab}`}
|
|
|
+ role="tabpanel" aria-labelledby={`batch-record-tab-${tab}`} tabIndex={0} hidden={active !== tab}>
|
|
|
+ {children}
|
|
|
+ </section>;
|
|
|
+}
|
|
|
|
|
|
- <div className="reconcile-record-stats">
|
|
|
- <div><span>明细条数</span><strong>{d.detail_count}</strong><small>本批有效行现算,作废行不计</small></div>
|
|
|
- <div><span>总金额</span><strong>{moneyFromCents(d.base_cents)}</strong><small>本批有效行应收基数合计</small></div>
|
|
|
- <div><span>分成金额</span><strong>{moneyFromCents(d.share_cents)}</strong><small>本批有效行分成金额合计</small></div>
|
|
|
- <div>
|
|
|
- <span>{TICKET_GAP_LABEL}</span>
|
|
|
- <strong>{d.ticket_gap_failed ? WORD_FETCH_FAILED : d.ticket_gap_count == null ? BACKEND_NOT_WIRED : ticketGapText(d.ticket_gap_count)}</strong>
|
|
|
- <small>{TICKET_GAP_LABEL}按工单台账现算(0 个缺口与取数失败是两回事)</small>
|
|
|
- </div>
|
|
|
+function BatchRecordContent({ batch, tab, onTabChange, linkState, flagsPending }: {
|
|
|
+ batch: ReconDetailResult;
|
|
|
+ tab: BatchRecordTab;
|
|
|
+ onTabChange: (tab: BatchRecordTab) => void;
|
|
|
+ linkState: DetailLinkState;
|
|
|
+ flagsPending: 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="批次统计">
|
|
|
+ <div>
|
|
|
+ <dt><ClipboardList size={16} aria-hidden="true" />明细条数</dt>
|
|
|
+ <dd><strong>{batch.detail_count}</strong><span className="batch-record-unit">条</span></dd>
|
|
|
</div>
|
|
|
+ <div>
|
|
|
+ <dt><Receipt size={16} aria-hidden="true" />总金额</dt>
|
|
|
+ <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>
|
|
|
+ <dd><strong>{moneyFromCents(batch.share_cents)}</strong></dd>
|
|
|
+ </div>
|
|
|
+ <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>
|
|
|
+ </dl>
|
|
|
|
|
|
- <section className="reconcile-record-section">
|
|
|
- <div className="reconcile-record-section-head">
|
|
|
- <div><h2>执行结果</h2><p>批次动作与执行说明。</p></div>
|
|
|
- <div style={{ display: "flex", gap: 8 }}>
|
|
|
- {isAdmin && (
|
|
|
- <Button variant="outline" onClick={onRerun} disabled={!rerunEnabled} title={d.can_rerun == null ? ACTION_FLAG_PENDING_NOTE : undefined}>人工补跑</Button>
|
|
|
- )}
|
|
|
- <Button variant="outline" onClick={onExport} disabled={!exportEnabled} title={d.can_export == null ? ACTION_FLAG_PENDING_NOTE : undefined}>
|
|
|
- <Download size={15} />导出本批账单明细
|
|
|
- </Button>
|
|
|
- {isAdmin && (
|
|
|
- <Button variant="outline" onClick={onCorrect} disabled={!correctEnabled} title={d.can_correct == null ? ACTION_FLAG_PENDING_NOTE : undefined}>登记更正</Button>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- {flagPending && <p className="reconcile-footnote">{ACTION_FLAG_PENDING_NOTE},动作暂不可用。</p>}
|
|
|
- {/* 失败原因只在 failed/voided 时渲染;voided 必带「由哪一次补跑作废」链接。 */}
|
|
|
- {(d.status === "failed" || d.status === "voided") && d.fail_reason && (
|
|
|
- <p className="ops-form-error" role="alert">{d.fail_reason}</p>
|
|
|
- )}
|
|
|
- {d.status === "voided" && d.voided_by_batch_no && (
|
|
|
- <p className="reconcile-footnote">
|
|
|
- {VOIDED_BY_PREFIX}
|
|
|
- <Link className="ops-table-action" to={batchPath(d.holder_id, d.voided_by_batch_no)} state={lineState}>{d.voided_by_batch_no} <ArrowRight size={14} /></Link>
|
|
|
- 作废。
|
|
|
- </p>
|
|
|
- )}
|
|
|
- {/* 成本未配置提示一行(不发通知、不建提醒表;不说"异常")。 */}
|
|
|
- {d.cost_unconfigured.length > 0 && (
|
|
|
- <p className="reconcile-footnote">{COST_UNCONFIGURED_NOTE}:{d.cost_unconfigured.join("、")}</p>
|
|
|
- )}
|
|
|
- </section>
|
|
|
-
|
|
|
- <section className="reconcile-record-section">
|
|
|
- <div className="reconcile-record-section-head">
|
|
|
- <span>01</span>
|
|
|
- <div><h2>本批账单明细</h2><p>{d.holder_name} · {d.period} · {d.detail_count} 条</p></div>
|
|
|
- </div>
|
|
|
- <div className="ops-table-wrap">
|
|
|
- <table className="ops-table" style={{ minWidth: 980 }}>
|
|
|
- <thead><tr><th>客户</th><th>订阅标识</th><th>应收金额</th><th>分成基数</th><th>分成方式与取值</th><th>本方分成金额</th><th>恒 0 说明</th><th>操作</th></tr></thead>
|
|
|
- <tbody>
|
|
|
- {d.items.map((line) => (
|
|
|
- <tr key={line.bill_detail_id}>
|
|
|
- <td><strong>{line.customer_name}</strong></td>
|
|
|
- <td>{line.subscription_label}</td>
|
|
|
- <td><span className="ops-money">{moneyFromCents(line.receivable_cents)}</span></td>
|
|
|
- <td><span className="ops-money">{moneyFromCents(line.share_base_cents)}</span></td>
|
|
|
- <td className="table-number">{settleTextFromSnapshot(line.share_mode, line.share_value)}</td>
|
|
|
- <td><strong className="reconcile-money">{moneyFromCents(line.share_amount_cents)}</strong></td>
|
|
|
- {/* zero_note 如实展示并解释为什么是 0(⛔ 隐藏 0 金额行)。 */}
|
|
|
- <td>{line.zero_note ? ZERO_NOTE_TEXT[line.zero_note] : <span className="table-placeholder">—</span>}</td>
|
|
|
- <td>
|
|
|
- <Link className="ops-table-action" to={`/settlement-bills/${encodeURIComponent(line.bill_detail_id)}`} state={lineState}>
|
|
|
- 详情
|
|
|
- </Link>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- ))}
|
|
|
- {!d.items.length && <OpsTableEmpty colSpan={8}>本批无明细行。</OpsTableEmpty>}
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- </div>
|
|
|
- </section>
|
|
|
-
|
|
|
- <section className="reconcile-record-section">
|
|
|
- <div className="reconcile-record-section-head"><span>02</span><div><h2>执行与口径</h2><p>批次八字段头与状态说明。</p></div></div>
|
|
|
- <dl className="reconcile-record-facts">
|
|
|
- <div><dt>对账单号</dt><dd>{d.batch_no}</dd></div>
|
|
|
- <div><dt>分成方</dt><dd>{d.holder_name} · {HOLDER_TYPE_TEXT[d.holder_type]}</dd></div>
|
|
|
- <div><dt>自然月</dt><dd>{d.period}</dd></div>
|
|
|
- <div><dt>应出账日期</dt><dd title="该分成方该自然月的应出账日期=自然月次月的对账日;「每月 N 日」的对账日口径见「出账配置」">{d.recon_date ?? "—"}</dd></div>
|
|
|
- <div><dt>批次状态</dt><dd>{BATCH_STATUS_TEXT[d.status]}</dd></div>
|
|
|
- <div><dt>执行人</dt><dd title={d.operator_user_id ?? undefined}>{executorText(d)}</dd></div>
|
|
|
- <div><dt>执行时间</dt><dd title={d.executed_at ?? undefined}>{d.executed_at ? localTime(d.executed_at) : "—"}</dd></div>
|
|
|
- <div><dt>触发方式</dt><dd>{TRIGGER_TYPE_TEXT[d.trigger_type]}</dd></div>
|
|
|
+ <div className="record-tabs-frame">
|
|
|
+ <RecordTabs prefix="batch-record" label="对账清单详情视图" tabs={tabs} active={tab} onChange={onTabChange} />
|
|
|
+ <BatchRecordPanel tab="overview" active={tab}>
|
|
|
+ <dl className="ops-record-summary batch-record-facts">
|
|
|
+ <div><dt>对账单号</dt><dd>{batch.batch_no}</dd></div>
|
|
|
+ <div><dt>分成方</dt><dd>{batch.holder_name || missing}</dd></div>
|
|
|
+ <div><dt>自然月</dt><dd>{batch.period}</dd></div>
|
|
|
+ <div><dt>应出账日期</dt><dd title="该自然月次月的对账日">{batch.recon_date || missing}</dd></div>
|
|
|
</dl>
|
|
|
- <p className="reconcile-footnote">状态以批次当前记录为准。执行失败的批次由总运营补跑;账单差错通过出账更正登记。</p>
|
|
|
- </section>
|
|
|
- </>
|
|
|
- );
|
|
|
+ {batch.cost_unconfigured.length > 0 && <div className="batch-record-note batch-record-note-warning" role="note">
|
|
|
+ <TriangleAlert size={16} aria-hidden="true" />
|
|
|
+ <p>{COST_UNCONFIGURED_NOTE}:{batch.cost_unconfigured.join("、")}</p>
|
|
|
+ </div>}
|
|
|
+ </BatchRecordPanel>
|
|
|
+
|
|
|
+ <BatchRecordPanel tab="bills" active={tab}>
|
|
|
+ <BatchBillingTable items={batch.items} linkState={linkState} />
|
|
|
+ </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>
|
|
|
+ <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">
|
|
|
+ <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}>
|
|
|
+ {batch.voided_by_batch_no}<ArrowRight size={14} aria-hidden="true" />
|
|
|
+ </Link> 作废。</p>
|
|
|
+ </div>}
|
|
|
+ {flagsPending && <div className="batch-record-note" role="note"><p>{ACTION_FLAG_PENDING_NOTE},动作暂不可用。</p></div>}
|
|
|
+ </BatchRecordPanel>
|
|
|
+ </div>
|
|
|
+ </>;
|
|
|
+}
|
|
|
+
|
|
|
+const batchBillColumns: readonly SettlementLedgerColumn[] = [
|
|
|
+ { label: "客户", width: 160 },
|
|
|
+ { label: "订阅标识", width: 180 },
|
|
|
+ { label: "应收金额", width: 104, numeric: true },
|
|
|
+ { label: "分成基数", width: 104, numeric: true },
|
|
|
+ { label: "分成方式与取值", width: 124 },
|
|
|
+ { label: "本方分成金额", width: 120, numeric: true },
|
|
|
+ { label: "恒 0 说明", width: 132 },
|
|
|
+];
|
|
|
+
|
|
|
+function BatchBillingTable({ items, linkState }: { items: ReconDetailResult["items"]; linkState: DetailLinkState }) {
|
|
|
+ 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="本批账单明细">
|
|
|
+ <OpsTableColumns widths={table.widths} />
|
|
|
+ <SettlementLedgerHead columns={batchBillColumns} />
|
|
|
+ <tbody>
|
|
|
+ {items.map((line) => {
|
|
|
+ const shareRule = settleTextFromSnapshot(line.share_mode, line.share_value);
|
|
|
+ const zeroNote = line.zero_note ? ZERO_NOTE_TEXT[line.zero_note] : undefined;
|
|
|
+ return <tr key={line.bill_detail_id}>
|
|
|
+ <td><strong className="table-cell-title" title={line.customer_name}>{line.customer_name}</strong></td>
|
|
|
+ <td><strong className="table-cell-title" title={line.subscription_label}>{line.subscription_label}</strong></td>
|
|
|
+ <td className="settlement-ledger-number"><span className="ops-money">{moneyFromCents(line.receivable_cents)}</span></td>
|
|
|
+ <td className="settlement-ledger-number"><span className="ops-money">{moneyFromCents(line.share_base_cents)}</span></td>
|
|
|
+ <td className="table-number" title={shareRule}>{shareRule}</td>
|
|
|
+ <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}>
|
|
|
+ 详情<ArrowRight size={14} aria-hidden="true" />
|
|
|
+ </Link>
|
|
|
+ </td>
|
|
|
+ </tr>;
|
|
|
+ })}
|
|
|
+ {!items.length && <OpsTableEmpty colSpan={table.widths.length}>本批无明细行。</OpsTableEmpty>}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>;
|
|
|
}
|
|
|
|
|
|
/* ── FN-08 账单明细(14.3 列表) ─────────────────────────────────── */
|