feat: 扩展开奖与结算管理,支持手动操作、导出和版本展示

This commit is contained in:
2026-05-16 18:00:57 +08:00
parent 34f9175304
commit fae8c1ae01
21 changed files with 1148 additions and 410 deletions

View File

@@ -13,11 +13,12 @@ import {
publishOddsVersion,
putOddsItems,
} from "@/api/admin-config";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { ConfigReadonlyValue } from "@/modules/config/config-readonly-value";
import { ConfigVersionActions } from "@/modules/config/config-version-actions";
import { ConfigVersionSwitcher } from "@/modules/config/config-version-switcher";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { LotteryApiBizError } from "@/types/api/errors";
@@ -147,7 +148,13 @@ export function RebateConfigDocScreen() {
return m;
}, [types]);
const isDraft = detail?.status === "draft";
const selectedVersionSummary = useMemo(
() => listRows.find((x) => String(x.id) === selectedId) ?? null,
[listRows, selectedId],
);
const isSelectedDetail = detail !== null && String(detail.id) === selectedId;
const selectedStatus = isSelectedDetail ? detail.status : selectedVersionSummary?.status;
const isDraft = selectedStatus === "draft";
function applyDimensionPercentsToRows(rows: OddsItemRow[]): OddsItemRow[] {
const r2 = Number.parseFloat(p2);
@@ -261,82 +268,89 @@ export function RebateConfigDocScreen() {
<CardHeader className="space-y-1">
<CardTitle className="text-lg"> / </CardTitle>
</CardHeader>
<CardContent className="space-y-6 max-w-xl">
<ConfigVersionSwitcher
versions={listRows}
selectedId={selectedId}
onSelectedIdChange={setSelectedId}
loading={loading}
sheetTitle="回水配置版本"
sheetDescription="回水写入赔率版本草稿;选择与赔率配置共用同一套版本"
onDeleteVersion={handleDeleteVersion}
/>
<CardContent className="space-y-6">
<div className="flex flex-wrap items-center gap-3">
<ConfigVersionSwitcher
versions={listRows}
selectedId={selectedId}
onSelectedIdChange={setSelectedId}
loading={loading}
sheetTitle="回水配置版本"
sheetDescription="回水写入赔率版本草稿;选择与赔率配置共用同一套版本。"
onDeleteVersion={handleDeleteVersion}
className="w-auto min-w-0"
/>
<div className="flex flex-wrap gap-2">
<Button type="button" variant="secondary" onClick={() => void refreshList()} disabled={loading}>
</Button>
<Button type="button" onClick={() => void handleNewDraft()} disabled={saving}>
稿
</Button>
<Button type="button" onClick={() => void handleSave()} disabled={!isDraft || saving || loadingDetail}>
稿
</Button>
<Button
type="button"
className="bg-emerald-600 text-white hover:bg-emerald-600/90"
onClick={() => void handlePublish()}
disabled={!isDraft || saving || loadingDetail}
>
</Button>
<ConfigVersionActions
isDraft={isDraft}
loadingList={loading}
loadingDetail={loadingDetail}
saving={saving}
publishLabel="发布生效"
onRefresh={() => void refreshList()}
onNewDraft={() => void handleNewDraft()}
onSaveDraft={() => void handleSave()}
onPublish={() => void handlePublish()}
/>
{detail ? (
<p className="text-sm text-muted-foreground">
v{detail.version_no} · {detail.status === "draft" ? "草稿" : detail.status === "active" ? "生效中" : "已归档"}
{!isDraft ? (
<span className="text-amber-600 dark:text-amber-400"> 稿</span>
) : null}
</p>
) : null}
</div>
{detail ? (
<p className="text-sm text-muted-foreground">
v{detail.version_no} · {detail.status === "draft" ? "草稿" : detail.status === "active" ? "生效中" : "已归档"}
{!isDraft ? (
<span className="text-amber-600 dark:text-amber-400"> 稿</span>
) : null}
</p>
) : null}
<div className="grid gap-4 sm:grid-cols-3">
<div className="grid gap-2">
<Label>2D %</Label>
<Input
type="number"
step="0.01"
min={0}
className="font-mono tabular-nums"
disabled={!isDraft || saving}
value={p2}
onChange={(e) => setP2(e.target.value)}
/>
{isDraft ? (
<Input
type="number"
step="0.01"
min={0}
className="font-mono tabular-nums"
disabled={saving}
value={p2}
onChange={(e) => setP2(e.target.value)}
/>
) : (
<ConfigReadonlyValue mono>{p2}</ConfigReadonlyValue>
)}
</div>
<div className="grid gap-2">
<Label>3D %</Label>
<Input
type="number"
step="0.01"
min={0}
className="font-mono tabular-nums"
disabled={!isDraft || saving}
value={p3}
onChange={(e) => setP3(e.target.value)}
/>
{isDraft ? (
<Input
type="number"
step="0.01"
min={0}
className="font-mono tabular-nums"
disabled={saving}
value={p3}
onChange={(e) => setP3(e.target.value)}
/>
) : (
<ConfigReadonlyValue mono>{p3}</ConfigReadonlyValue>
)}
</div>
<div className="grid gap-2">
<Label>4D %</Label>
<Input
type="number"
step="0.01"
min={0}
className="font-mono tabular-nums"
disabled={!isDraft || saving}
value={p4}
onChange={(e) => setP4(e.target.value)}
/>
{isDraft ? (
<Input
type="number"
step="0.01"
min={0}
className="font-mono tabular-nums"
disabled={saving}
value={p4}
onChange={(e) => setP4(e.target.value)}
/>
) : (
<ConfigReadonlyValue mono>{p4}</ConfigReadonlyValue>
)}
</div>
</div>