|
@@ -7,7 +7,7 @@ import { ListPager, ServerListPager } from "../components/ListPager";
|
|
|
import { slicePage, useLocalPage, LIST_PAGE_SIZE } from "../lib/list-paging";
|
|
import { slicePage, useLocalPage, LIST_PAGE_SIZE } from "../lib/list-paging";
|
|
|
import { Button } from "../components/ui/button";
|
|
import { Button } from "../components/ui/button";
|
|
|
import { Input } from "../components/ui/input";
|
|
import { Input } from "../components/ui/input";
|
|
|
-import { OpsNotice, OpsResponsiveActions, OpsStatus, OpsTag, OpsTableEmpty, OpsTableColumns } from "../components/OperationsKit";
|
|
|
|
|
|
|
+import { OpsHint, OpsNotice, OpsResponsiveActions, OpsStatus, OpsTag, OpsTableEmpty, OpsTableColumns } from "../components/OperationsKit";
|
|
|
import { TreeSelect } from "../components/ui/tree-select";
|
|
import { TreeSelect } from "../components/ui/tree-select";
|
|
|
import { regionTreeNodes } from "../lib/region-tree";
|
|
import { regionTreeNodes } from "../lib/region-tree";
|
|
|
import { Link, useLocation } from "react-router";
|
|
import { Link, useLocation } from "react-router";
|
|
@@ -33,9 +33,11 @@ import {
|
|
|
CORRECTION_WIRING_NOTE,
|
|
CORRECTION_WIRING_NOTE,
|
|
|
} from "../lib/copy-billing";
|
|
} from "../lib/copy-billing";
|
|
|
import {
|
|
import {
|
|
|
|
|
+ COST_AMORTIZED_HINT,
|
|
|
COST_AMOUNT_DIALOG_DISCARD_NOTE,
|
|
COST_AMOUNT_DIALOG_DISCARD_NOTE,
|
|
|
COST_COMBO_FORBIDDEN,
|
|
COST_COMBO_FORBIDDEN,
|
|
|
COST_CONFLICT_NOTE,
|
|
COST_CONFLICT_NOTE,
|
|
|
|
|
+ COST_DEDUCT_HINT,
|
|
|
COST_DELETE_CONFIRM_NOTE,
|
|
COST_DELETE_CONFIRM_NOTE,
|
|
|
COST_NO_PROVINCE_NOTE,
|
|
COST_NO_PROVINCE_NOTE,
|
|
|
COST_STALE_PANEL_NOTE,
|
|
COST_STALE_PANEL_NOTE,
|
|
@@ -46,7 +48,7 @@ import { FetchError } from "../components/fetchError";
|
|
|
import { WORD_FETCH_FAILED, WORD_NOT_PROVIDED } from "../lib/api/lockedCopy";
|
|
import { WORD_FETCH_FAILED, WORD_NOT_PROVIDED } from "../lib/api/lockedCopy";
|
|
|
import { COST_BILLING_UNIT, COST_CATEGORY, COST_CYCLE } from "../lib/api/labels";
|
|
import { COST_BILLING_UNIT, COST_CATEGORY, COST_CYCLE } from "../lib/api/labels";
|
|
|
import { boolView, costCellKey, useCostAmounts, useCostItems, type CostComboView, type CostItemView } from "../lib/cost-demo";
|
|
import { boolView, costCellKey, useCostAmounts, useCostItems, type CostComboView, type CostItemView } from "../lib/cost-demo";
|
|
|
-import { costAmountSave, costItemSave } from "../lib/api/bos";
|
|
|
|
|
|
|
+import { costAmountSave, costItemDelete, costItemSave } from "../lib/api/bos";
|
|
|
import { useSubmit } from "../lib/useLoad";
|
|
import { useSubmit } from "../lib/useLoad";
|
|
|
import { customerRegionId, onboardingCustomers, onboardingRegions, provinceId } from "../lib/customer-onboarding";
|
|
import { customerRegionId, onboardingCustomers, onboardingRegions, provinceId } from "../lib/customer-onboarding";
|
|
|
import { useBusinessView } from "../lib/use-business-view";
|
|
import { useBusinessView } from "../lib/use-business-view";
|
|
@@ -133,9 +135,15 @@ const amountFormDirty = (form: AmountForm): boolean => Object.keys({ ...form.bas
|
|
|
function CostLedger({ kind, count = 0, children }: { kind: "definitions" | "matrix"; count?: number; children: ReactNode | ((expanded: boolean) => ReactNode) }) {
|
|
function CostLedger({ kind, count = 0, children }: { kind: "definitions" | "matrix"; count?: number; children: ReactNode | ((expanded: boolean) => ReactNode) }) {
|
|
|
const scroll = useHorizontalOverflow();
|
|
const scroll = useHorizontalOverflow();
|
|
|
const expanded = scroll.width >= 1680;
|
|
const expanded = scroll.width >= 1680;
|
|
|
- const minimums = kind === "definitions" ? [56, 128, 76, 76, 56, 136, 154, 128, 156]
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 定义表 11 列=序号/项目/成本类别/计算方式/周期/是否摊销/总摊销月份数/计入分成基数/
|
|
|
|
|
+ * 金额配置情况/被套餐档引用/操作。⚠️ minimums 与 weights 必须逐列对齐(`OpsTableColumns`
|
|
|
|
|
+ * 只按数组长度下发 `<col>`):少一项,多出的列在 `table-layout:fixed` 下宽度为 0,表头与内容被挤没。
|
|
|
|
|
+ * 1500 窗口 ⇒ 表格容器≈1182px,故最小宽度合计收在 1156,避免无谓横向滚动。
|
|
|
|
|
+ */
|
|
|
|
|
+ const minimums = kind === "definitions" ? [56, 120, 76, 76, 56, 88, 132, 132, 148, 116, 156]
|
|
|
: [110, 84, ...Array<number>(count).fill(110), 76, 142, 120];
|
|
: [110, 84, ...Array<number>(count).fill(110), 76, 142, 120];
|
|
|
- const weights = kind === "definitions" ? [0, 17, 10, 8, 7, 8, 30, 20, 0]
|
|
|
|
|
|
|
+ const weights = kind === "definitions" ? [0, 17, 10, 8, 7, 6, 8, 8, 24, 12, 0]
|
|
|
: [0, 0, ...Array<number>(count).fill(1), 0, count ? 0 : 1, 0];
|
|
: [0, 0, ...Array<number>(count).fill(1), 0, count ? 0 : 1, 0];
|
|
|
const minWidth = minimums.reduce((total, minimum) => total + minimum, 0);
|
|
const minWidth = minimums.reduce((total, minimum) => total + minimum, 0);
|
|
|
const weightTotal = weights.reduce((total, weight) => total + weight, 0);
|
|
const weightTotal = weights.reduce((total, weight) => total + weight, 0);
|
|
@@ -204,6 +212,8 @@ export function CostManagementPage() {
|
|
|
}
|
|
}
|
|
|
const saveItem = useSubmit();
|
|
const saveItem = useSubmit();
|
|
|
const saveAmount = useSubmit();
|
|
const saveAmount = useSubmit();
|
|
|
|
|
+ /** 删除成本项(引用检查通过后真删;服务端仍会复判引用面)。 */
|
|
|
|
|
+ const removeItem = useSubmit();
|
|
|
const [tab, setTab] = useState<"definitions" | "amounts">("definitions");
|
|
const [tab, setTab] = useState<"definitions" | "amounts">("definitions");
|
|
|
const [query, setQuery] = useState("");
|
|
const [query, setQuery] = useState("");
|
|
|
const [kindFilter, setKindFilter] = useState("");
|
|
const [kindFilter, setKindFilter] = useState("");
|
|
@@ -225,6 +235,9 @@ export function CostManagementPage() {
|
|
|
const [staleItems, setStaleItems] = useState<Record<string, boolean>>({});
|
|
const [staleItems, setStaleItems] = useState<Record<string, boolean>>({});
|
|
|
/** KLT-E004 且 reason=no_province ⇒ 整页 ② 不可用。 */
|
|
/** KLT-E004 且 reason=no_province ⇒ 整页 ② 不可用。 */
|
|
|
const [panelBlocked, setPanelBlocked] = useState("");
|
|
const [panelBlocked, setPanelBlocked] = useState("");
|
|
|
|
|
+ /** 删除确认框选中的成本项(`null`=未打开);`deleteError` 只在框内显示。 */
|
|
|
|
|
+ const [deleteTarget, setDeleteTarget] = useState<CostItemView | null>(null);
|
|
|
|
|
+ const [deleteError, setDeleteError] = useState("");
|
|
|
const costItems = items.data ?? [];
|
|
const costItems = items.data ?? [];
|
|
|
/** 契约 14.1.1「清单按名称排序」(后端按 cost_item_id 排 ⇒ 前端按名称重排,不另发请求)。 */
|
|
/** 契约 14.1.1「清单按名称排序」(后端按 cost_item_id 排 ⇒ 前端按名称重排,不另发请求)。 */
|
|
|
const filtered = useMemo(() => (items.data ?? []).filter((item) => (!kindFilter || item.categoryKey === kindFilter)
|
|
const filtered = useMemo(() => (items.data ?? []).filter((item) => (!kindFilter || item.categoryKey === kindFilter)
|
|
@@ -394,8 +407,46 @@ export function CostManagementPage() {
|
|
|
? `成本项「${name}」已保存;此后出账按新定义计入,已出账月份保留当月快照。`
|
|
? `成本项「${name}」已保存;此后出账按新定义计入,已出账月份保留当月快照。`
|
|
|
: `成本项「${name}」已新增,请切到「成本金额定义」标签页选到对应的「省份 × 运营商」组合后录入该组合的金额;本条${draftDef.deduct ? "从分成基数扣除" : "不从分成基数扣除"}。`);
|
|
: `成本项「${name}」已新增,请切到「成本金额定义」标签页选到对应的「省份 × 运营商」组合后录入该组合的金额;本条${draftDef.deduct ? "从分成基数扣除" : "不从分成基数扣除"}。`);
|
|
|
}
|
|
}
|
|
|
- /** 后端⛔ 成本项删除接口(`/cost_item/delete@v1` 经网关回 11001),页面只说明、不发请求。 */
|
|
|
|
|
- function reportDeleteGap() { setNotice(`后端暂无成本项删除接口:/cost_item/delete@v1 未在 OpenAPI 声明(网关 11001),接口就绪前无删除入口。契约删除确认形态(确认框含引用档位数+「${COST_DELETE_CONFIRM_NOTE}」、不含连带金额行数)已登记缺口清单。`); }
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除成本项(契约 14.6):先开二次确认框;「能否删除」由服务端按 `plan_cost_item.item_name`
|
|
|
|
|
+ * 名称弱引用复判——页面只在**后端明确回了 0 个引用**时放行入口,`null`(未下发概况)一律不开。
|
|
|
|
|
+ */
|
|
|
|
|
+ function startDelete(item: CostItemView) {
|
|
|
|
|
+ if (!canEdit) return;
|
|
|
|
|
+ if (item.referringPlans === null) {
|
|
|
|
|
+ setNotice("后端未下发「被套餐档引用」概况,判不了这项能否删除;请刷新列表后再试。");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.referringPlans.length > 0) { setNotice(costRefBlocked(item.referringPlans.length)); return; }
|
|
|
|
|
+ setDeleteError("");
|
|
|
|
|
+ removeItem.clear();
|
|
|
|
|
+ setDeleteTarget(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ async function confirmDelete() {
|
|
|
|
|
+ if (!canEdit || !deleteTarget) return;
|
|
|
|
|
+ const target = deleteTarget;
|
|
|
|
|
+ const ok = await removeItem.run(() => costItemDelete({ cost_item_id: target.id }).catch((e: unknown) => {
|
|
|
|
|
+ const detail = bizDetail(e);
|
|
|
|
|
+ if (hasBizCode(e, "KLT-E002")) {
|
|
|
|
|
+ // 页面状态过期(开框后才被档位引用)⇒ 框内给引用档位数+「先在档位上解除引用」,并刷新引用面。
|
|
|
|
|
+ setDeleteError(costRefBlocked(typeof detail.referring_plan_count === "number" ? detail.referring_plan_count : null));
|
|
|
|
|
+ items.reload();
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (hasBizCode(e, "60005")) {
|
|
|
|
|
+ setDeleteError("这项已被删除或不存在,刷新列表后重试。");
|
|
|
|
|
+ items.reload();
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }
|
|
|
|
|
+ setDeleteError(errorMessage(e) || "删除失败,请重试。");
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }));
|
|
|
|
|
+ if (!ok) return;
|
|
|
|
|
+ setDeleteTarget(null);
|
|
|
|
|
+ items.reload();
|
|
|
|
|
+ amounts.reload();
|
|
|
|
|
+ setNotice(`成本项「${target.name}」已删除。${COST_DELETE_CONFIRM_NOTE}。`);
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* 一览表省份筛选:换省或改回「全部省份」时,若已选的品牌不在新候选里就一并清空,
|
|
* 一览表省份筛选:换省或改回「全部省份」时,若已选的品牌不在新候选里就一并清空,
|
|
|
* 否则残留的品牌筛选会把新省份的列表筛成空表(用户会误读成「该省无组合」)。
|
|
* 否则残留的品牌筛选会把新省份的列表筛成空表(用户会误读成「该省无组合」)。
|
|
@@ -543,8 +594,8 @@ export function CostManagementPage() {
|
|
|
? <Tri tone="missing" text={WORD_NOT_PROVIDED} title="后端未下发套餐档引用概况" />
|
|
? <Tri tone="missing" text={WORD_NOT_PROVIDED} title="后端未下发套餐档引用概况" />
|
|
|
: item.referringPlans.length
|
|
: item.referringPlans.length
|
|
|
? item.referringPlans.map((plan) => <small className="ops-stacked" title={`档位 ID:${plan.id}(按 plan_cost_item.item_name 名称弱引用)`} key={plan.id}>{plan.name}</small>)
|
|
? item.referringPlans.map((plan) => <small className="ops-stacked" title={`档位 ID:${plan.id}(按 plan_cost_item.item_name 名称弱引用)`} key={plan.id}>{plan.name}</small>)
|
|
|
- : <small>未被套餐档引用</small>}</td>
|
|
|
|
|
- <td>{canEdit ? <div className="ops-inline-actions"><button type="button" onClick={() => startEdit(item)}><PencilLine size={15} />编辑定义</button><OpsResponsiveActions expanded={expanded} items={[{ label: "删除成本项", shortLabel: "删除", danger: true, icon: <Trash2 size={15} />, disabled: true, title: "后端暂无成本项删除接口:cost_item/delete@v1 未在 OpenAPI 声明(网关 11001)", onSelect: reportDeleteGap }]} /></div> : <small className="ops-muted">只读(全局成本项定义由总运营维护)</small>}</td>
|
|
|
|
|
|
|
+ : <span className="ops-mono" title="后端现算:plan_cost_item 里没有任何套餐档引用该成本项名称(未被引用 ⇒ 可删除)">0</span>}</td>
|
|
|
|
|
+ <td>{canEdit ? <div className="ops-inline-actions"><button type="button" onClick={() => startEdit(item)}><PencilLine size={15} />编辑定义</button><OpsResponsiveActions expanded={expanded} items={[{ label: "删除成本项", shortLabel: "删除", danger: true, icon: <Trash2 size={15} />, disabled: (item.referringPlans?.length ?? 1) !== 0, title: item.referringPlans === null ? "后端未下发「被套餐档引用」概况,判不了能否删除" : item.referringPlans.length ? `被 ${item.referringPlans.length} 个套餐档引用,先在档位上解除引用` : "未被任何套餐档引用,可删除", onSelect: () => startDelete(item) }]} /></div> : <small className="ops-muted">只读(全局成本项定义由总运营维护)</small>}</td>
|
|
|
</tr>; })}{!filtered.length && <OpsTableEmpty colSpan={11}>{items.error ? `成本项定义取数失败:${items.error.message}——失败关闭,下表不回退内置演示定义` : items.loading && !items.data ? "成本项定义取数中…" : !costItems.length ? "后端未返回任何成本项(cost_item/get_list@v1 total:0)——真实空态,可点上方「新增成本项」落库验证" : "没有符合筛选条件的成本项,可点上方「新增成本项」或重置筛选"}</OpsTableEmpty>}</tbody></>}</CostLedger>
|
|
</tr>; })}{!filtered.length && <OpsTableEmpty colSpan={11}>{items.error ? `成本项定义取数失败:${items.error.message}——失败关闭,下表不回退内置演示定义` : items.loading && !items.data ? "成本项定义取数中…" : !costItems.length ? "后端未返回任何成本项(cost_item/get_list@v1 total:0)——真实空态,可点上方「新增成本项」落库验证" : "没有符合筛选条件的成本项,可点上方「新增成本项」或重置筛选"}</OpsTableEmpty>}</tbody></>}</CostLedger>
|
|
|
<ListPager total={filtered.length} page={defPaging.safePage} pageSize={defPaging.pageSize} onPageChange={defPaging.setPage} />
|
|
<ListPager total={filtered.length} page={defPaging.safePage} pageSize={defPaging.pageSize} onPageChange={defPaging.setPage} />
|
|
|
</> : panelBlocked ? <div className="ops-empty" role="alert"><h1>成本金额暂不可用</h1><p>{panelBlocked}(KLT-E004 · no_province)</p></div> : <>
|
|
</> : panelBlocked ? <div className="ops-empty" role="alert"><h1>成本金额暂不可用</h1><p>{panelBlocked}(KLT-E004 · no_province)</p></div> : <>
|
|
@@ -588,7 +639,10 @@ export function CostManagementPage() {
|
|
|
</div>
|
|
</div>
|
|
|
{amounts.data && !amounts.data.available && <p className="ops-form-error" role="alert">后端金额一览 available:false({amounts.data.message})⇒ 判不出哪些组合已有金额:已有组合请走一览表行内「编辑金额」,本弹窗只用于新增,不得拿它覆盖已有组合。</p>}
|
|
{amounts.data && !amounts.data.available && <p className="ops-form-error" role="alert">后端金额一览 available:false({amounts.data.message})⇒ 判不出哪些组合已有金额:已有组合请走一览表行内「编辑金额」,本弹窗只用于新增,不得拿它覆盖已有组合。</p>}
|
|
|
{amountError || (saveAmount.error && !saveAmount.busy) ? <p className="ops-form-error" role="alert">{amountError || `金额保存失败:${saveAmount.error?.message ?? ""}`}</p> : null}
|
|
{amountError || (saveAmount.error && !saveAmount.busy) ? <p className="ops-form-error" role="alert">{amountError || `金额保存失败:${saveAmount.error?.message ?? ""}`}</p> : null}
|
|
|
- <p className="ops-import-note">只提交本次改动过的格子(契约 14.1.2):留空=该项不配置、按 0 元 / 月计;编辑已有组合时清空某格=删掉这条差异金额。新增组合只写已填的项,不写空行。已配金额的组合不得在「新增运营商成本」里再选一次,改金额请在一览表对应行点「编辑金额」。{amountForm.mode === "new" ? "" : `当前组合:${provinceNameOf(amountForm.regionId)} × ${operatorNameOf(amountForm.operatorId)}。`}</p>
|
|
|
|
|
|
|
+ {/* ⛔ 弹窗底部不再挂「只提交本次改动过的格子(契约 14.1.2)…」整段说明(2026-11-18 业主指出):
|
|
|
|
|
+ 那段是跨两种模式的通用口径,放在「编辑运营商成本」里有一半句子(新增组合才写、去一览表点编辑金额)
|
|
|
|
|
+ 与当前场景相悖,且把契约编号等实现口径摆给操作人看。「留空=该项不配置」由每行输入框的
|
|
|
|
|
+ placeholder 承担,「已配金额的组合不在此新增」由运营商下拉禁用+「(已有金额)」承担。 */}
|
|
|
</div>
|
|
</div>
|
|
|
<footer><Button variant="outline" onClick={closeAmountForm}>取消</Button><Button disabled={saveAmount.busy} onClick={submitAmountForm}>{saveAmount.busy ? "保存中…" : amountForm.mode === "new" ? "确认新增" : "确认保存"}</Button></footer>
|
|
<footer><Button variant="outline" onClick={closeAmountForm}>取消</Button><Button disabled={saveAmount.busy} onClick={submitAmountForm}>{saveAmount.busy ? "保存中…" : amountForm.mode === "new" ? "确认新增" : "确认保存"}</Button></footer>
|
|
|
</div></div>}
|
|
</div></div>}
|
|
@@ -600,18 +654,28 @@ export function CostManagementPage() {
|
|
|
<label><span className="ops-field-title">项目(成本项名称) <b>*</b></span><Input aria-invalid={Boolean(nameError) || undefined} value={draftDef.itemName} onChange={(event) => { setDraftDef({ ...draftDef, itemName: event.target.value }); if (nameError) setNameError(""); }} placeholder="例如 国际出口带宽月摊销" />{nameError && <small className="ops-form-error" role="alert">{nameError}</small>}</label>
|
|
<label><span className="ops-field-title">项目(成本项名称) <b>*</b></span><Input aria-invalid={Boolean(nameError) || undefined} value={draftDef.itemName} onChange={(event) => { setDraftDef({ ...draftDef, itemName: event.target.value }); if (nameError) setNameError(""); }} placeholder="例如 国际出口带宽月摊销" />{nameError && <small className="ops-form-error" role="alert">{nameError}</small>}</label>
|
|
|
<label><span className="ops-field-title">计算方式</span><select value={draftDef.billingUnit} onChange={(event) => setDraftDef({ ...draftDef, billingUnit: event.target.value })}>{BILLING_OPTIONS.map((item) => <option key={item.value} value={item.value}>{item.text}</option>)}</select></label>
|
|
<label><span className="ops-field-title">计算方式</span><select value={draftDef.billingUnit} onChange={(event) => setDraftDef({ ...draftDef, billingUnit: event.target.value })}>{BILLING_OPTIONS.map((item) => <option key={item.value} value={item.value}>{item.text}</option>)}</select></label>
|
|
|
<label><span className="ops-field-title">周期</span><select value="monthly" disabled title="周期一期恒 monthly(设计册 分成§2.1,后端 CHECK 钉死),由服务端写常量;表单不提交该键"><option value="monthly">{COST_CYCLE.monthly}</option></select></label>
|
|
<label><span className="ops-field-title">周期</span><select value="monthly" disabled title="周期一期恒 monthly(设计册 分成§2.1,后端 CHECK 钉死),由服务端写常量;表单不提交该键"><option value="monthly">{COST_CYCLE.monthly}</option></select></label>
|
|
|
- <label className="ops-form-check"><input type="checkbox" checked={draftDef.amortized} onChange={(event) => setDraftDef({ ...draftDef, amortized: event.target.checked, amortMonths: event.target.checked ? draftDef.amortMonths : "" })} title="勾选后可填「总摊销月份数」;取消勾选立即清空并置灰" />是否摊销</label>
|
|
|
|
|
|
|
+ <div className="ops-form-check-row">
|
|
|
|
|
+ <label className="ops-form-check"><input type="checkbox" checked={draftDef.amortized} onChange={(event) => setDraftDef({ ...draftDef, amortized: event.target.checked, amortMonths: event.target.checked ? draftDef.amortMonths : "" })} title="勾选后可填「总摊销月份数」;取消勾选立即清空并置灰" />是否摊销</label>
|
|
|
|
|
+ <OpsHint label="「是否摊销」口径说明" title="是否摊销">{COST_AMORTIZED_HINT.map((line) => <p key={line}>{line}</p>)}</OpsHint>
|
|
|
|
|
+ </div>
|
|
|
<label><span className="ops-field-title">总摊销月份数</span><Input type="number" min="1" step="1" disabled={!draftDef.amortized} placeholder={draftDef.amortized ? "留空表示每月摊销、不结束;填值须为正整数" : "勾选「是否摊销」后可填"} value={draftDef.amortMonths} onChange={(event) => setDraftDef({ ...draftDef, amortMonths: event.target.value })} /></label>
|
|
<label><span className="ops-field-title">总摊销月份数</span><Input type="number" min="1" step="1" disabled={!draftDef.amortized} placeholder={draftDef.amortized ? "留空表示每月摊销、不结束;填值须为正整数" : "勾选「是否摊销」后可填"} value={draftDef.amortMonths} onChange={(event) => setDraftDef({ ...draftDef, amortMonths: event.target.value })} /></label>
|
|
|
- <label className="ops-form-check"><input type="checkbox" checked={draftDef.deduct} onChange={(event) => setDraftDef({ ...draftDef, deduct: event.target.checked })} />从分成基数中扣除</label>
|
|
|
|
|
|
|
+ <div className="ops-form-check-row">
|
|
|
|
|
+ <label className="ops-form-check"><input type="checkbox" checked={draftDef.deduct} onChange={(event) => setDraftDef({ ...draftDef, deduct: event.target.checked })} />从分成基数中扣除</label>
|
|
|
|
|
+ <OpsHint label="「从分成基数中扣除」口径说明" title="从分成基数中扣除">{COST_DEDUCT_HINT.map((line) => <p key={line}>{line}</p>)}</OpsHint>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
{(error || (!nameError && saveItem.error)) && <p className="ops-form-error" role="alert">{error || `保存失败:${saveItem.error?.message ?? ""}(后端校验:11102 乐观锁冲突/11103 参数不合法)`}</p>}
|
|
{(error || (!nameError && saveItem.error)) && <p className="ops-form-error" role="alert">{error || `保存失败:${saveItem.error?.message ?? ""}(后端校验:11102 乐观锁冲突/11103 参数不合法)`}</p>}
|
|
|
- <p className="ops-import-note">这里维护的是成本项定义,全局一套,不区分运营商和省份,弹窗内不录入金额;保存调用 cost_item/save@v1 真实落库(新增不带 cost_item_id,编辑带回 cost_item_id 与 row_version),后端写审计日志。具体金额在「成本金额定义」按「省份 × 运营商」组合各配一套。</p>
|
|
|
|
|
{editing !== "new" && draftDef.rowVersion === null && <p className="ops-import-note">该行后端未下发 row_version ⇒ 本次保存不带乐观锁,他人同时修改不会被拦下。</p>}
|
|
{editing !== "new" && draftDef.rowVersion === null && <p className="ops-import-note">该行后端未下发 row_version ⇒ 本次保存不带乐观锁,他人同时修改不会被拦下。</p>}
|
|
|
{editing !== "new" && (editing.categoryKey === null || editing.billingUnitKey === null || editing.deduct === null) && <p className="ops-import-note">该行的 category/billing_unit/deduct_from_base 后端本期未灌值(columns_pending),表单已按默认值预填——保存会把预填值真实写入这些列。</p>}
|
|
{editing !== "new" && (editing.categoryKey === null || editing.billingUnitKey === null || editing.deduct === null) && <p className="ops-import-note">该行的 category/billing_unit/deduct_from_base 后端本期未灌值(columns_pending),表单已按默认值预填——保存会把预填值真实写入这些列。</p>}
|
|
|
- <p className="ops-import-note">「从分成基数中扣除」对应 deduct_from_base(后端必填布尔):勾选的按组合摊销额从基数中扣除,不勾选的只做登记。「是否摊销」默认不勾选(U-34):勾选后「总摊销月份数」选填、留空=每月摊销不结束(is_amortized:true 且不下发月份数),填值须为正整数;未勾选时表单不提交月份数(给了 ⇒ 后端 11103)。计算方式对应 billing_unit:per_customer 每客户、per_account 每账号、per_copy 每份;周期一期恒 monthly(设计册 分成§2.1),表单不提交该键。</p>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
<footer><Button variant="outline" onClick={() => setEditing(null)}>取消</Button><Button disabled={saveItem.busy} onClick={submitDefinition}>{saveItem.busy ? "保存中…" : editing === "new" ? "新增成本项" : "保存"}</Button></footer>
|
|
<footer><Button variant="outline" onClick={() => setEditing(null)}>取消</Button><Button disabled={saveItem.busy} onClick={submitDefinition}>{saveItem.busy ? "保存中…" : editing === "new" ? "新增成本项" : "保存"}</Button></footer>
|
|
|
</div></div>}
|
|
</div></div>}
|
|
|
|
|
+ {deleteTarget && <div className="ops-confirm-backdrop" role="presentation" onMouseDown={() => !removeItem.busy && setDeleteTarget(null)}><div className="ops-confirm" role="alertdialog" aria-modal="true" aria-labelledby="cost-delete-title" onMouseDown={(event) => event.stopPropagation()}>
|
|
|
|
|
+ <h2 id="cost-delete-title">删除成本项「{deleteTarget.name}」?</h2>
|
|
|
|
|
+ <p>该项当前未被任何套餐档引用(引用数 0),可以删除。{COST_DELETE_CONFIRM_NOTE}。此操作无法撤销。</p>
|
|
|
|
|
+ {deleteError && <p className="ops-form-error" role="alert">{deleteError}</p>}
|
|
|
|
|
+ <div><Button variant="outline" disabled={removeItem.busy} onClick={() => setDeleteTarget(null)}>取消</Button><Button variant="destructive" disabled={removeItem.busy} onClick={confirmDelete}>{removeItem.busy ? "正在删除…" : "确认删除"}</Button></div>
|
|
|
|
|
+ </div></div>}
|
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
{notice && <OpsNotice message={notice} onClose={() => setNotice("")} />}
|
|
|
</section>;
|
|
</section>;
|
|
|
}
|
|
}
|