import React from 'react'; import { Link } from "@remix-run/react"; import { json, type MetaFunction } from "@remix-run/node"; import { useLoaderData, useNavigate } from "@remix-run/react"; import { Button } from "~/components/ui/Button"; // import stylesUrl from "~/styles/pages/rule-groups.css"; // 引入CSS // export function links() { // return [ // { rel: "stylesheet", href: stylesUrl } // ]; // } export const meta: MetaFunction = () => { return [ { title: "中国烟草AI合同及卷宗审核系统 - 评查点分组列表" }, { name: "description", content: "评查点分组管理" } ]; }; // 分组接口定义 interface RuleGroup { id: string; name: string; code: string; ruleCount: number; childGroupCount: number; isActive: boolean; parentId: string | null; createdAt: string; level: 1 | 2; // 1-一级分组,2-二级分组 } interface LoaderData { groups: RuleGroup[]; } export async function loader() { // 模拟数据,实际项目中应该从API获取 const groups: RuleGroup[] = [ { id: "1", name: "合同基本要素检查", code: "contract-base", ruleCount: 18, childGroupCount: 2, isActive: true, parentId: null, createdAt: "2023-10-01 14:30", level: 1 }, { id: "2", name: "必备要素检查", code: "essential-elements", ruleCount: 7, childGroupCount: 0, isActive: true, parentId: "1", createdAt: "2023-10-02 10:15", level: 2 }, { id: "3", name: "合同主体检查", code: "contract-parties", ruleCount: 5, childGroupCount: 0, isActive: true, parentId: "1", createdAt: "2023-10-02 11:40", level: 2 }, { id: "4", name: "销售合同专项检查", code: "sales-contract", ruleCount: 10, childGroupCount: 2, isActive: true, parentId: null, createdAt: "2023-10-03 09:20", level: 1 }, { id: "5", name: "交付条款检查", code: "delivery-terms", ruleCount: 4, childGroupCount: 0, isActive: true, parentId: "4", createdAt: "2023-10-03 14:30", level: 2 }, { id: "6", name: "付款条款检查", code: "payment-terms", ruleCount: 6, childGroupCount: 0, isActive: true, parentId: "4", createdAt: "2023-10-03 15:45", level: 2 }, { id: "7", name: "采购合同专项检查", code: "purchase-contract", ruleCount: 8, childGroupCount: 0, isActive: true, parentId: null, createdAt: "2023-10-04 10:15", level: 1 }, { id: "8", name: "行政处罚规范性检查", code: "admin-punishment", ruleCount: 12, childGroupCount: 0, isActive: false, parentId: null, createdAt: "2023-10-05 16:30", level: 1 } ]; return json({ groups }); } export default function RuleGroupsPage() { const { groups } = useLoaderData(); const navigate = useNavigate(); // 过滤出父级分组和子级分组 const parentGroups = groups.filter(group => group.parentId === null); // 根据父级ID获取子分组 const getChildGroups = (parentId: string) => { return groups.filter(group => group.parentId === parentId); }; // 模拟删除操作 const handleDelete = (id: string) => { if (window.confirm("确定要删除该分组吗?删除后无法恢复,且会删除该分组下的所有评查点。")) { alert(`删除分组: ${id}`); } }; // 创建新分组 const handleCreate = () => { navigate("/rule-groups/new"); }; // 展开/收起状态(实际项目中可以使用useState管理) const toggleExpand = (groupId: string) => { const childRows = document.querySelectorAll(`.child-of-${groupId}`); childRows.forEach(row => { (row as HTMLElement).style.display = (row as HTMLElement).style.display === "none" ? "table-row" : "none"; }); // 切换图标 const icon = document.querySelector(`span.expand-icon[data-group-id="${groupId}"] i`); if (icon) { icon.classList.toggle("ri-arrow-down-s-line"); icon.classList.toggle("ri-arrow-right-s-line"); } }; // 键盘处理器 const handleKeyDown = (e: React.KeyboardEvent, groupId: string) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggleExpand(groupId); } }; return (
{/* 页面标识 */}

当前页面: 评查点分组列表 (rule-groups._index.tsx)

如果你看到这个提示,说明你已成功到达评查点分组列表页面。

查看路由诊断页面 | 返回首页
{/* 页面头部 */}

评查点分组管理

{/* 搜索栏 */}
{/* 数据表格 */}
{parentGroups.map(parent => ( {/* 一级分组 */} {/* 二级分组 */} {getChildGroups(parent.id).map(child => ( ))} ))}
分组名称 分组编码 评查点数量 状态 创建时间 操作
toggleExpand(parent.id)} onKeyDown={(e) => handleKeyDown(e, parent.id)} role="button" tabIndex={0} aria-label="展开/收起" > {parent.name} 一级分组
{parent.code} {parent.ruleCount} {parent.childGroupCount > 0 && ( | 子分组: {parent.childGroupCount} )} {parent.isActive ? '启用' : '禁用'} {parent.createdAt}
{child.name} 二级分组
{child.code} {child.ruleCount} {child.isActive ? '启用' : '禁用'} {child.createdAt}
); }