feat(config): 重构配置模块导航与版本切换,新增版本删除能力

This commit is contained in:
2026-05-15 15:30:52 +08:00
parent 000295ae2b
commit 8bd7cc3d73
20 changed files with 669 additions and 377 deletions

View File

@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
import { toast } from "sonner";
import {
deleteOddsVersion,
getAdminPlayTypes,
getOddsVersion,
getOddsVersions,
@@ -16,6 +17,7 @@ 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 { ConfigVersionSwitcher } from "@/modules/config/config-version-switcher";
import { useAdminDateTimeFormatter } from "@/hooks/use-admin-datetime-formatter";
import { LotteryApiBizError } from "@/types/api/errors";
import type {
@@ -242,17 +244,38 @@ export function RebateConfigDocScreen() {
const activeHead = listRows.find((x) => x.status === "active");
async function handleDeleteVersion(row: ConfigVersionSummary) {
try {
await deleteOddsVersion(row.id);
toast.success("已删除该版本");
await refreshList();
} catch (e) {
toast.error(e instanceof LotteryApiBizError ? e.message : "删除失败");
throw e;
}
}
return (
<Card>
<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}
/>
<div className="flex flex-wrap gap-2">
<Button type="button" variant="secondary" size="sm" onClick={() => void refreshList()} disabled={loading}>
<Button type="button" variant="secondary" onClick={() => void refreshList()} disabled={loading}>
</Button>
<Button type="button" size="sm" onClick={() => void handleNewDraft()} disabled={saving}>
<Button type="button" onClick={() => void handleNewDraft()} disabled={saving}>
稿
</Button>
<Button type="button" onClick={() => void handleSave()} disabled={!isDraft || saving || loadingDetail}>