|
@@ -2,6 +2,7 @@ import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
|
|
|
import { FilterIcon, FilterSelect } from "../components/ui/filter-select";
|
|
import { FilterIcon, FilterSelect } from "../components/ui/filter-select";
|
|
|
import { TreeSelect } from "../components/ui/tree-select";
|
|
import { TreeSelect } from "../components/ui/tree-select";
|
|
|
import { useEffect, useMemo, useState } from "react";
|
|
import { useEffect, useMemo, useState } from "react";
|
|
|
|
|
+import { useNavigate } from "react-router";
|
|
|
import { ArrowRight, CalendarDays, Check, Info, RotateCcw, Scan, Search, X } from "lucide-react";
|
|
import { ArrowRight, CalendarDays, Check, Info, RotateCcw, Scan, Search, X } from "lucide-react";
|
|
|
import { Button } from "../components/ui/button";
|
|
import { Button } from "../components/ui/button";
|
|
|
import { Input } from "../components/ui/input";
|
|
import { Input } from "../components/ui/input";
|
|
@@ -14,14 +15,14 @@ import { ALL_ORG_COLLECTIONS, descendants, payCycleOptions } from "../lib/organi
|
|
|
import { regionTreeNodes } from "../lib/region-tree";
|
|
import { regionTreeNodes } from "../lib/region-tree";
|
|
|
import { currentSharePartyTypes, hasShareTerms, sharePartiesFromOrganization, type CurrentSharePartyType } from "../lib/share-party-view";
|
|
import { currentSharePartyTypes, hasShareTerms, sharePartiesFromOrganization, type CurrentSharePartyType } from "../lib/share-party-view";
|
|
|
import { Tri } from "../components/triState";
|
|
import { Tri } from "../components/triState";
|
|
|
-import { WORD_FETCH_FAILED, WORD_NOT_PROVIDED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
|
|
|
|
|
|
|
+import { WORD_FETCH_FAILED, WORD_NOT_PROVIDED } from "../lib/api/lockedCopy";
|
|
|
import { hasBizCode } from "../lib/api/http";
|
|
import { hasBizCode } from "../lib/api/http";
|
|
|
import { billingConfigGet, operatorUpdate } from "../lib/api/bos";
|
|
import { billingConfigGet, operatorUpdate } from "../lib/api/bos";
|
|
|
import type { BillingConfigOperatorRow, EffectiveMode, HolderType } from "../lib/api/types";
|
|
import type { BillingConfigOperatorRow, EffectiveMode, HolderType } from "../lib/api/types";
|
|
|
import { submitBillingConfigUpdate, useBillingConfig } from "../lib/recon";
|
|
import { submitBillingConfigUpdate, useBillingConfig } from "../lib/recon";
|
|
|
-import { SHARE_TERMS_UNSET, settleTextFromSnapshot } from "../lib/settle-text";
|
|
|
|
|
|
|
+import { SHARE_TERMS_UNSET, settleTextFromSnapshot, shareAmountText } from "../lib/settle-text";
|
|
|
import { shareSummaryKey, useShareParamSummary, type ShareSummaryState } from "../lib/share-summary";
|
|
import { shareSummaryKey, useShareParamSummary, type ShareSummaryState } from "../lib/share-summary";
|
|
|
-import { PARTY_NO_STATEMENT, PARTY_SCOPE_NOTE } from "../lib/copy-views";
|
|
|
|
|
|
|
+import { PARTY_NO_SHARE_ROWS, PARTY_SCOPE_NOTE } from "../lib/copy-views";
|
|
|
import {
|
|
import {
|
|
|
BACKEND_NOT_WIRED,
|
|
BACKEND_NOT_WIRED,
|
|
|
BILLING_CONFIG_WIRING_NOTE,
|
|
BILLING_CONFIG_WIRING_NOTE,
|
|
@@ -62,9 +63,17 @@ const PARTY_HOLDER_TYPE: Record<CurrentSharePartyType, HolderType> = {
|
|
|
* - 「分成方式」「分成取值」唯一来源=`share_param_summary` 读口([位] 未在 OpenAPI 声明 ⇒ 未接线期两列「后端未下发」;
|
|
* - 「分成方式」「分成取值」唯一来源=`share_param_summary` 读口([位] 未在 OpenAPI 声明 ⇒ 未接线期两列「后端未下发」;
|
|
|
* KLT-S406 ⇒ 只该两列「取数失败」,其余照常);
|
|
* KLT-S406 ⇒ 只该两列「取数失败」,其余照常);
|
|
|
* - 状态列=档案两列派生(已配分成/未配分成中性渲染),不依赖读口 ⇒ 读口失败照常;
|
|
* - 状态列=档案两列派生(已配分成/未配分成中性渲染),不依赖读口 ⇒ 读口失败照常;
|
|
|
- * - 行操作只有「分成金额」⇒ 契约 14.2 弹窗(四卡+历史分成清单+取值摘要只读),⛔ 路由页/规则表/保存按钮/方式下拉;
|
|
|
|
|
- * - 前端⛔ 分成写入口:KLT-S20001(分成写口未对运营支撑前端开放)。
|
|
|
|
|
|
|
+ * - 行操作只有「分成金额」⇒ 契约 14.2 弹窗(四卡+取值摘要只读);**写入口不搬进本弹窗**:
|
|
|
|
|
+ * 「去档案里配置分成」跳三类档案的编辑弹窗(分成§5.1:复用档案 `update@v1`,本册不开新接口);
|
|
|
|
|
+ * - 分成写口=档案两列:合伙人仅 admin 可写,运营商/运维团队 admin+运营主账号(范围内)。
|
|
|
*/
|
|
*/
|
|
|
|
|
+
|
|
|
|
|
+/** 弹窗「去档案里配置分成」的落点(分成§5.1:三类档案各自的编辑弹窗)。 */
|
|
|
|
|
+const ARCHIVE_EDIT_PATH: Record<CurrentSharePartyType, string> = {
|
|
|
|
|
+ 运营商: "/organization/operators",
|
|
|
|
|
+ 合伙人: "/organization/partners",
|
|
|
|
|
+ 运维团队: "/organization/maintenance-teams",
|
|
|
|
|
+};
|
|
|
export function ShareRulePage() {
|
|
export function ShareRulePage() {
|
|
|
const tableOverflow = useHorizontalOverflow();
|
|
const tableOverflow = useHorizontalOverflow();
|
|
|
/**
|
|
/**
|
|
@@ -138,23 +147,36 @@ export function ShareRulePage() {
|
|
|
<td className="org-maintenance-share">{termsCell(row)}</td>
|
|
<td className="org-maintenance-share">{termsCell(row)}</td>
|
|
|
<td>{hasShareTerms(row) ? <OpsStatus tone="success">已配分成</OpsStatus> : <small>未配分成</small>}</td>
|
|
<td>{hasShareTerms(row) ? <OpsStatus tone="success">已配分成</OpsStatus> : <small>未配分成</small>}</td>
|
|
|
<td><span className="ops-money">{row.customerCount}</span></td>
|
|
<td><span className="ops-money">{row.customerCount}</span></td>
|
|
|
- <td><button type="button" className="ops-table-action" onClick={() => setDetail(row)} title="契约 14.2:弹窗出四卡+历史分成清单(只读),不出现规则表/保存按钮/方式下拉">分成金额 <ArrowRight size={14} /></button></td>
|
|
|
|
|
|
|
+ <td><button type="button" className="ops-table-action" onClick={() => setDetail(row)} title="契约 14.2:弹窗出四卡+取值摘要(只读),配置分成请点弹窗里的「去档案里配置分成」">分成金额 <ArrowRight size={14} /></button></td>
|
|
|
</tr>)}{!filtered.length && <OpsTableEmpty colSpan={8}>{rows.length ? "没有符合筛选条件的分成方,可重置四组筛选" : "第 1 册档案里还没有运营商/合伙人/运维团队(分成方行源为空)"}</OpsTableEmpty>}</tbody></table></div>
|
|
</tr>)}{!filtered.length && <OpsTableEmpty colSpan={8}>{rows.length ? "没有符合筛选条件的分成方,可重置四组筛选" : "第 1 册档案里还没有运营商/合伙人/运维团队(分成方行源为空)"}</OpsTableEmpty>}</tbody></table></div>
|
|
|
<ListPager total={filtered.length} page={paging.safePage} pageSize={paging.pageSize} onPageChange={paging.setPage} unit="条" />
|
|
<ListPager total={filtered.length} page={paging.safePage} pageSize={paging.pageSize} onPageChange={paging.setPage} unit="条" />
|
|
|
</div>
|
|
</div>
|
|
|
- {detail && <ShareAmountDialog row={detail} summary={summary} onClose={() => setDetail(null)} />}
|
|
|
|
|
|
|
+ {detail && <ShareAmountDialog row={detail} summary={summary} canConfigure={canConfigureShare(identity?.role, detail.type)} onClose={() => setDetail(null)} />}
|
|
|
</section>;
|
|
</section>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/** 分成取值写权限(分成§5.1/A24):合伙人的两列仅 admin;运营商与运维团队 admin+运营主账号(范围内)。 */
|
|
|
|
|
+function canConfigureShare(role: string | undefined, type: CurrentSharePartyType) {
|
|
|
|
|
+ if (role === "admin") return true;
|
|
|
|
|
+ if (role === "regAdmin") return type !== "合伙人";
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 契约 14.2 分成金额弹窗(只读):
|
|
|
|
|
- * 四卡=累计分成金额/已分成期数(第 6 册对账聚合未上线 ⇒ 恒「未配置」,⛔ 编 0)+分成客户数/分成方式(share_param_summary 本册现算);
|
|
|
|
|
|
|
+ * 契约 14.2 分成金额弹窗(只读+配置入口):
|
|
|
|
|
+ * 四卡=累计分成金额/已分成期数(第 6 册**已出账**分成行聚合,经 `share_param_summary` 一并带回:
|
|
|
|
|
+ * 有行给真值、无行写「尚无分成记录」、聚合读失败写「取数失败」,⛔ 写「未配置」——
|
|
|
|
|
+ * 那说的是「分成方式/取值没配」,与「还没有分成行」是两回事)
|
|
|
|
|
+ * +分成客户数/分成方式(share_param_summary 现算);
|
|
|
* 取值摘要只读+「对该方名下全部客户统一生效」;⛔ 规则表/保存按钮/方式下拉;⛔ 客户数编辑;
|
|
* 取值摘要只读+「对该方名下全部客户统一生效」;⛔ 规则表/保存按钮/方式下拉;⛔ 客户数编辑;
|
|
|
|
|
+ * 配置分成=页脚「去档案里配置分成」跳该方档案的编辑弹窗(分成分段写入口只有这一处,分成§5.1);
|
|
|
* 11104 ⇒ 与「该方不存在」同一句并关弹窗(待详情读口接线后落位,见下)。
|
|
* 11104 ⇒ 与「该方不存在」同一句并关弹窗(待详情读口接线后落位,见下)。
|
|
|
- * ⚠️ 历史分成清单数据源=第 8 册「对方只读视图」详情读口:册 8 接口清单(06)无本场景读口(2026-11-11 核实)
|
|
|
|
|
- * ⇒ 本区为契约占位骨架+「后端未下发」标格,⛔ 造请求到不存在的接口、⛔ 读演示台账;缺口已登记。
|
|
|
|
|
|
|
+ * ⚠️ 2026-11-18 定案:**历史分成清单整块撤除**——数据源是第 8 册「对方只读视图」详情读口,
|
|
|
|
|
+ * 册 8 接口清单(06)无本场景读口,⛔ 造请求到不存在的接口、⛔ 读演示台账;
|
|
|
|
|
+ * 故不再渲染占位行「后端未下发」、也不再留表格下方的口径说明行,弹窗只出四卡+取值摘要。
|
|
|
*/
|
|
*/
|
|
|
-function ShareAmountDialog({ row, summary, onClose }: { row: SharePartyRow; summary: ShareSummaryState; onClose: () => void }) {
|
|
|
|
|
|
|
+function ShareAmountDialog({ row, summary, canConfigure, onClose }: { row: SharePartyRow; summary: ShareSummaryState; canConfigure: boolean; onClose: () => void }) {
|
|
|
|
|
+ const navigate = useNavigate();
|
|
|
const wiring = summary.fail === "wiring";
|
|
const wiring = summary.fail === "wiring";
|
|
|
const failed = summary.fail !== null && !wiring;
|
|
const failed = summary.fail !== null && !wiring;
|
|
|
const item = summary.items.get(shareSummaryKey(PARTY_HOLDER_TYPE[row.type], row.id)) ?? null;
|
|
const item = summary.items.get(shareSummaryKey(PARTY_HOLDER_TYPE[row.type], row.id)) ?? null;
|
|
@@ -163,23 +185,55 @@ function ShareAmountDialog({ row, summary, onClose }: { row: SharePartyRow; summ
|
|
|
: item ? (item.configured ? settleTextFromSnapshot(item.share_mode, item.share_value) : SHARE_TERMS_UNSET) : WORD_NOT_PROVIDED;
|
|
: item ? (item.configured ? settleTextFromSnapshot(item.share_mode, item.share_value) : SHARE_TERMS_UNSET) : WORD_NOT_PROVIDED;
|
|
|
const customerCountView = wiring ? WORD_NOT_PROVIDED : failed ? WORD_FETCH_FAILED
|
|
const customerCountView = wiring ? WORD_NOT_PROVIDED : failed ? WORD_FETCH_FAILED
|
|
|
: item ? `${item.customer_count} 家` : WORD_NOT_PROVIDED;
|
|
: item ? `${item.customer_count} 家` : WORD_NOT_PROVIDED;
|
|
|
- return <div className="ops-confirm-backdrop" role="presentation" onMouseDown={onClose}><div className="ops-batch-dialog ops-cost-def-dialog" role="dialog" aria-modal="true" aria-labelledby="share-amount-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
|
|
|
- <header><div><p>分成管理 / 分成金额</p><h2 id="share-amount-title">{row.displayName} · 分成金额</h2><p>{row.type} · {row.regionLabel || "—"}</p></div><Button variant="ghost" size="icon" aria-label="关闭" onClick={onClose}><X size={18} /></Button></header>
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 前两卡=第 6 册已出账分成行聚合(`share_param_summary` 带回,与账单明细同口径)。
|
|
|
|
|
+ * 四态严格分开:整接口未接线→后端未下发;聚合读失败→取数失败;该方无已出账行→尚无分成记录;
|
|
|
|
|
+ * 有行→真金额/真期数(0 元也照实给 ¥ 0.00,⛔ 用空态掩盖)。
|
|
|
|
|
+ */
|
|
|
|
|
+ const statsError = summary.statsError ?? "";
|
|
|
|
|
+ const statsFailed = statsError !== "";
|
|
|
|
|
+ const settledPeriods = item?.settled_periods ?? null;
|
|
|
|
|
+ const hasShareRows = !wiring && !failed && !statsFailed && item != null && settledPeriods != null && settledPeriods > 0;
|
|
|
|
|
+ /** 未带回该方(`item` 缺位)⇒「后端未下发」,⛔ 当成「尚无分成记录」(那是有据可查的 0 行)。 */
|
|
|
|
|
+ const statMissing = !wiring && !failed && !statsFailed && item == null;
|
|
|
|
|
+ const totalView = wiring || statMissing ? WORD_NOT_PROVIDED : failed || statsFailed ? WORD_FETCH_FAILED
|
|
|
|
|
+ : hasShareRows ? shareAmountText(item?.share_total_cents ?? 0) : PARTY_NO_SHARE_ROWS;
|
|
|
|
|
+ const periodsView = wiring || statMissing ? WORD_NOT_PROVIDED : failed || statsFailed ? WORD_FETCH_FAILED
|
|
|
|
|
+ : hasShareRows ? `${settledPeriods} 期` : PARTY_NO_SHARE_ROWS;
|
|
|
|
|
+ const settledNote = hasShareRows
|
|
|
|
|
+ ? `已出账月份:${(item?.settled_months ?? []).join("、") || "—"}(第 6 册已出账分成行聚合)`
|
|
|
|
|
+ : wiring || statMissing ? "第 6 册分成行聚合未接线——接线前无法统计"
|
|
|
|
|
+ : failed || statsFailed ? `聚合读失败:${statsError || summary.message || WORD_FETCH_FAILED}`
|
|
|
|
|
+ : "该方还没有已出账的分成行——出账后自动计入";
|
|
|
|
|
+ const statClass = hasShareRows ? undefined : "is-text";
|
|
|
|
|
+ /** 失败格按三态口径渲染 `.oss-tri-fail`(⛔ 与「尚无分成记录」同一样式)。 */
|
|
|
|
|
+ const statText = (text: string) => (failed || statsFailed)
|
|
|
|
|
+ ? <span className="oss-tri-fail" title={statsError || summary.message || WORD_FETCH_FAILED}>{text}</span>
|
|
|
|
|
+ : text;
|
|
|
|
|
+ return <div className="ops-confirm-backdrop" role="presentation" onMouseDown={onClose}><div className="ops-batch-dialog ops-share-amount-dialog" role="dialog" aria-modal="true" aria-labelledby="share-amount-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
|
|
|
+ <header><div><p>分成管理 / 分成金额</p><h2 id="share-amount-title">{row.displayName} · 分成金额</h2>
|
|
|
|
|
+ <span className="ops-share-amount-meta"><OpsTag tone={row.type === "合伙人" ? "brand" : row.type === "运营商" ? "info" : "neutral"}>{row.type}</OpsTag>{row.regionLabel || "—"}</span>
|
|
|
|
|
+ </div><Button variant="ghost" size="icon" aria-label="关闭" onClick={onClose}><X size={18} /></Button></header>
|
|
|
<div className="ops-batch-dialog-body">
|
|
<div className="ops-batch-dialog-body">
|
|
|
- <div className="ops-cost-cards">
|
|
|
|
|
- <article className="ops-cost-card"><span>累计分成金额</span><strong>{WORD_UNCONFIGURED}</strong><small>第 6 册对账聚合未上线——一期不接,不读演示台账</small></article>
|
|
|
|
|
- <article className="ops-cost-card"><span>已分成期数</span><strong>{WORD_UNCONFIGURED}</strong><small>第 6 册对账聚合未上线——同上口径</small></article>
|
|
|
|
|
- <article className="ops-cost-card"><span>分成客户数</span><strong>{customerCountView}</strong><small>share_param_summary 本册现算</small></article>
|
|
|
|
|
- <article className="ops-cost-card"><span>分成方式</span><strong>{termsView}</strong><small>share_param_summary 现行值</small></article>
|
|
|
|
|
|
|
+ <div className="ops-dialog-kpis">
|
|
|
|
|
+ <div><span>累计分成金额</span><strong className={statClass}>{statText(totalView)}</strong><small>{settledNote}</small></div>
|
|
|
|
|
+ <div><span>已分成期数</span><strong className={statClass}>{statText(periodsView)}</strong><small>{settledNote}</small></div>
|
|
|
|
|
+ <div><span>分成客户数</span><strong>{customerCountView}</strong><small>share_param_summary 本册现算</small></div>
|
|
|
|
|
+ <div><span>分成方式</span><strong className="is-text">{termsView}</strong><small>share_param_summary 现行值</small></div>
|
|
|
</div>
|
|
</div>
|
|
|
- <p className="ops-import-note">取值摘要(只读):{termsView} · {PARTY_SCOPE_NOTE}。不出现方式下拉与保存按钮——取值变更走运维流程(一期不接)。</p>
|
|
|
|
|
- <h3>历史分成清单</h3>
|
|
|
|
|
- <div className="ops-table-wrap"><table className="ops-table"><thead><tr><th>期次</th><th>计算过程</th><th>金额</th><th>对账指向</th></tr></thead><tbody>
|
|
|
|
|
- <tr><td colSpan={4}><Tri tone="missing" text={WORD_NOT_PROVIDED} title="数据源=第 8 册「对方只读视图」详情读口(接口清单无本场景读口)⇒ 契约占位骨架;就绪后逐行出「计算过程+对账指向」" /></td></tr>
|
|
|
|
|
- </tbody></table></div>
|
|
|
|
|
- <p className="ops-import-note">每行须给出计算过程,并指到对应对账单据;该方本期未出账 ⇒「{PARTY_NO_STATEMENT}」。数据源未接线 ⇒ 本区为契约占位骨架(已登记缺口)。</p>
|
|
|
|
|
|
|
+ <section className="ops-dialog-panel">
|
|
|
|
|
+ <h3>取值摘要(只读)</h3>
|
|
|
|
|
+ <p className="ops-import-note">{termsView} · {PARTY_SCOPE_NOTE}。本弹窗只读;{canConfigure
|
|
|
|
|
+ ? "配置分成请点页脚「去档案里配置分成」——取值变更只有档案编辑弹窗一处入口。"
|
|
|
|
|
+ : "本账号没有分成取值的写权限(合伙人两列仅总运营可改)。"}</p>
|
|
|
|
|
+ </section>
|
|
|
</div>
|
|
</div>
|
|
|
- <footer><Button variant="outline" onClick={onClose}>关闭</Button></footer>
|
|
|
|
|
|
|
+ <footer>
|
|
|
|
|
+ <Button variant="outline" onClick={onClose}>关闭</Button>
|
|
|
|
|
+ {canConfigure
|
|
|
|
|
+ ? <Button onClick={() => { onClose(); navigate(`${ARCHIVE_EDIT_PATH[row.type]}?edit=${encodeURIComponent(row.id)}`); }}>去档案里配置分成</Button>
|
|
|
|
|
+ : null}
|
|
|
|
|
+ </footer>
|
|
|
</div></div>;
|
|
</div></div>;
|
|
|
}
|
|
}
|
|
|
|
|
|