From 948e652201f9aff341a2daedae9fa4bd0a43f496 Mon Sep 17 00:00:00 2001 From: Wenyan Date: Tue, 25 Nov 2025 18:04:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(evaluation):=20=E4=BF=AE=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=85=A8=E9=83=A8=E8=AF=84=E6=9F=A5=E7=82=B9=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=97=B6=E7=9A=84=E7=AD=9B=E9=80=89=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - 前端选择"全部"时,将多个类型 ID 拼接成 "1,2,3" 传给后端 - 后端 evaluation_point_groups_pid 参数类型是 int,不支持逗号分隔的字符串 - 导致查询失败或返回错误结果 解决方案: - 选择"全部"时,不传递 ruleType 参数(即 evaluation_point_groups_pid) - 让后端根据用户权限返回所有有权限查看的评查点类型数据 - 只有选择具体类型时,才传递单个类型 ID 技术细节: - 移除了 loadedRuleTypes.map(type => type.id).join(',') 逻辑 - 将 finalRuleType 设置为 undefined 而不是拼接的 ID 字符串 - getRulesList 函数已有判断,只在 ruleType 存在时添加查询参数 测试场景: ✅ 选择"全部" → 不传 evaluation_point_groups_pid → 返回所有类型 ✅ 选择具体类型 → 传 evaluation_point_groups_pid=1 → 返回该类型 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/routes/rules.list.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/routes/rules.list.tsx b/app/routes/rules.list.tsx index c00e657..0846831 100644 --- a/app/routes/rules.list.tsx +++ b/app/routes/rules.list.tsx @@ -320,15 +320,16 @@ export default function RulesIndex() { } // 构建查询参数 - // 🔑 当选择"全部"或未选择评查点类型时,使用下拉框中所有评查点类型的 id 组合 + // 🔑 当选择"全部"或未选择评查点类型时,不传递 ruleType 参数(后端会返回所有类型) let finalRuleType: string | undefined = undefined; if (ruleTypeParam && ruleTypeParam !== 'all') { // 选择了具体的评查点类型 finalRuleType = ruleTypeParam; - } else if (loadedRuleTypes && loadedRuleTypes.length > 0) { - // 选择"全部"或未选择,使用刚加载的评查点类型的 id - finalRuleType = loadedRuleTypes.map(type => type.id).join(','); - console.log("📋 [fetchData] 选择全部类型,使用 loadedRuleTypes 的 id 组合:", finalRuleType); + console.log("📋 [fetchData] 选择特定类型:", finalRuleType); + } else { + // 选择"全部"或未选择,不传递参数,让后端返回所有有权限的评查点 + finalRuleType = undefined; + console.log("📋 [fetchData] 选择全部类型,不传递 ruleType 参数"); } const queryParams = { @@ -529,13 +530,14 @@ export default function RulesIndex() { type: "warning", confirmText: "删除", cancelText: "取消", + confirmDelay: 4, onConfirm: () => { // 设置删除状态为true setIsDeleting(true); const form = new FormData(); form.append("_action", "delete"); form.append("ruleId", rule.id); - + fetcher.submit(form, { method: "post" }); } }); @@ -605,6 +607,7 @@ export default function RulesIndex() { type: "warning", confirmText: "删除", cancelText: "取消", + confirmDelay: 4, onConfirm: async () => { try { setLoading(true);