refactor(rule-groups): 替换列表页面为 FastAPI v3 接口
变更内容: - 更新导入语句,使用新的 FastAPI v3 函数 - getRuleGroups → getEvaluationPointGroups - deleteRuleGroup → deleteEvaluationPointGroup - batchUpdateRuleGroupStatus → batchUpdateEvaluationPointGroupStatus - batchDeleteRuleGroups → batchDeleteEvaluationPointGroups 影响范围: - app/routes/rule-groups._index.tsx(评查点分组列表页面) 功能: - 列表查询、删除、批量启用/禁用、批量删除 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,12 +9,12 @@ import { Table } from "~/components/ui/Table";
|
|||||||
import { FilterPanel, FilterSelect, SearchFilter } from "~/components/ui/FilterPanel";
|
import { FilterPanel, FilterSelect, SearchFilter } from "~/components/ui/FilterPanel";
|
||||||
// import { Pagination } from "~/components/ui/Pagination";
|
// import { Pagination } from "~/components/ui/Pagination";
|
||||||
import {
|
import {
|
||||||
getRuleGroups,
|
getEvaluationPointGroups,
|
||||||
getChildGroups,
|
getChildGroups,
|
||||||
type RuleGroup,
|
type RuleGroup,
|
||||||
deleteRuleGroup,
|
deleteEvaluationPointGroup,
|
||||||
batchUpdateRuleGroupStatus,
|
batchUpdateEvaluationPointGroupStatus,
|
||||||
batchDeleteRuleGroups
|
batchDeleteEvaluationPointGroups
|
||||||
} from "~/api/evaluation_points/rule-groups";
|
} from "~/api/evaluation_points/rule-groups";
|
||||||
import { toastService, messageService } from "~/components/ui";
|
import { toastService, messageService } from "~/components/ui";
|
||||||
|
|
||||||
@@ -43,8 +43,8 @@ export async function loader({ request }: { request: Request }) {
|
|||||||
const page = parseInt(url.searchParams.get('page') || '1');
|
const page = parseInt(url.searchParams.get('page') || '1');
|
||||||
const pageSize = parseInt(url.searchParams.get('pageSize') || '50');
|
const pageSize = parseInt(url.searchParams.get('pageSize') || '50');
|
||||||
|
|
||||||
// 🆕 调用增强的 getRuleGroups API
|
// 🆕 调用 FastAPI v3 的 getEvaluationPointGroups API
|
||||||
const response = await getRuleGroups({
|
const response = await getEvaluationPointGroups({
|
||||||
name,
|
name,
|
||||||
code,
|
code,
|
||||||
is_enabled: is_enabled ? is_enabled === 'true' : undefined,
|
is_enabled: is_enabled ? is_enabled === 'true' : undefined,
|
||||||
@@ -52,7 +52,7 @@ export async function loader({ request }: { request: Request }) {
|
|||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
token: frontendJWT
|
token: frontendJWT
|
||||||
});
|
}, frontendJWT);
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
throw new Error(response.error);
|
throw new Error(response.error);
|
||||||
@@ -239,7 +239,7 @@ export default function RuleGroupsIndex() {
|
|||||||
confirmDelay: 4,
|
confirmDelay: 4,
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
try {
|
try {
|
||||||
const result = await deleteRuleGroup(groupId, frontendJWT);
|
const result = await deleteEvaluationPointGroup(groupId, frontendJWT);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
// 从本地状态中移除被删除的分组
|
// 从本地状态中移除被删除的分组
|
||||||
setGroups(prev => {
|
setGroups(prev => {
|
||||||
@@ -283,7 +283,7 @@ export default function RuleGroupsIndex() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await batchUpdateRuleGroupStatus(selectedIds, enable, frontendJWT);
|
const result = await batchUpdateEvaluationPointGroupStatus(selectedIds, enable, frontendJWT);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
toastService.success(`成功${enable ? '启用' : '禁用'} ${result.updated_count} 个分组`);
|
toastService.success(`成功${enable ? '启用' : '禁用'} ${result.updated_count} 个分组`);
|
||||||
// 刷新页面以重新加载数据
|
// 刷新页面以重新加载数据
|
||||||
@@ -313,7 +313,7 @@ export default function RuleGroupsIndex() {
|
|||||||
confirmDelay: 4,
|
confirmDelay: 4,
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
try {
|
try {
|
||||||
const result = await batchDeleteRuleGroups(selectedIds, frontendJWT);
|
const result = await batchDeleteEvaluationPointGroups(selectedIds, frontendJWT);
|
||||||
toastService.success(`成功删除 ${result.deleted_count} 个分组`);
|
toastService.success(`成功删除 ${result.deleted_count} 个分组`);
|
||||||
if (result.failed_ids.length > 0) {
|
if (result.failed_ids.length > 0) {
|
||||||
toastService.warning(`有 ${result.failed_ids.length} 个分组删除失败`);
|
toastService.warning(`有 ${result.failed_ids.length} 个分组删除失败`);
|
||||||
|
|||||||
Reference in New Issue
Block a user