完成评查点分组列表和评查点列表的页面,封装部分组件,重新构造样式文件结构

This commit is contained in:
2025-03-26 18:39:42 +08:00
parent 97ccf5a077
commit d9b9ce4676
34 changed files with 3281 additions and 3777 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import { Card } from "~/components/ui/Card";
import { Button } from "~/components/ui/Button";
export const links = () => [
{ rel: "stylesheet", href: "/app/styles/index.css" }
{ rel: "stylesheet", href: "app/styles/pages/home.css" }
];
export const meta: MetaFunction = () => {
+34
View File
@@ -0,0 +1,34 @@
import { MetaFunction } from '@remix-run/node';
import { Card } from '~/components/ui/Card';
import { Button } from '~/components/ui/Button';
export const meta: MetaFunction = () => {
return [
{ title: "文件上传 - 中国烟草AI合同及卷宗审核系统" },
{ name: "description", content: "上传文件进行智能评查" }
];
};
export default function FilesNew() {
return (
<div className="p-6">
{/* 页面标识 */}
<div className="mb-4 p-3 bg-blue-100 border border-blue-300 rounded text-blue-800">
<h3 className="font-bold text-lg">当前页面: 文件上传 (files/new.tsx)</h3>
<p></p>
<div className="mt-2">
<a href="/" className="text-blue-600 hover:underline"></a>
</div>
</div>
<Card title="文件上传" icon="ri-upload-cloud-line" className="mt-6">
<div className="flex flex-col items-center justify-center p-6 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50">
<i className="ri-upload-cloud-line text-5xl text-gray-400 mb-4"></i>
<p className="text-lg mb-4"></p>
<Button type="primary" icon="ri-upload-line"></Button>
<p className="text-gray-500 mt-3"> PDFDOCDOCXXLSXLSX </p>
</div>
</Card>
</div>
);
}
+264
View File
@@ -0,0 +1,264 @@
import { json, redirect, type ActionFunctionArgs, type LoaderFunctionArgs, type MetaFunction } from "@remix-run/node";
import { Form, useLoaderData, useNavigation, useActionData } from "@remix-run/react";
import { useState, useEffect } from "react";
export const meta: MetaFunction = ({ data }) => {
return [
{ title: `编辑评查点分组 - ${data?.group?.name || '加载中'} - 中国烟草AI合同及卷宗审核系统` },
{ name: "description", content: "编辑评查点分组信息,包括名称、编码、描述和状态" },
];
};
// 模拟数据
const MOCK_GROUPS = [
{
id: "1",
name: "合同条款类",
code: "CONTRACT",
description: "关于合同条款的评查点分组",
status: "active",
sortOrder: 1,
createdAt: "2024-01-01T00:00:00Z",
updatedAt: "2024-01-01T00:00:00Z",
},
{
id: "2",
name: "合规性类",
code: "COMPLIANCE",
description: "关于合规性的评查点分组",
status: "active",
sortOrder: 2,
createdAt: "2024-01-01T00:00:00Z",
updatedAt: "2024-01-01T00:00:00Z",
},
{
id: "3",
name: "风险提示类",
code: "RISK",
description: "关于风险提示的评查点分组",
status: "inactive",
sortOrder: 3,
createdAt: "2024-01-01T00:00:00Z",
updatedAt: "2024-01-01T00:00:00Z",
},
];
export async function loader({ params }: LoaderFunctionArgs) {
const { groupId } = params;
// 真实环境中,这里会调用API获取数据
// const response = await fetch(`${process.env.API_URL}/api/rule-groups/${groupId}`);
// if (response.status === 404) {
// throw new Response("评查点分组不存在", { status: 404 });
// }
// if (!response.ok) {
// throw new Response("获取评查点分组失败", { status: response.status });
// }
// const group = await response.json();
// 使用模拟数据
const group = MOCK_GROUPS.find(g => g.id === groupId);
if (!group) {
throw new Response("评查点分组不存在", { status: 404 });
}
return json({ group });
}
export async function action({ request, params }: ActionFunctionArgs) {
const formData = await request.formData();
const groupId = params.groupId;
const name = formData.get("name");
const code = formData.get("code");
const description = formData.get("description");
const status = formData.get("status");
const sortOrder = formData.get("sortOrder");
// 基本验证
const errors = {};
if (!name) errors.name = "分组名称不能为空";
if (!code) errors.code = "分组编码不能为空";
if (Object.keys(errors).length > 0) {
return json({ errors, values: Object.fromEntries(formData) });
}
// 构建更新数据
const updateData = {
name,
code,
description,
status,
sortOrder: Number(sortOrder) || 0,
};
// 真实环境中,这里会调用API更新数据
// const response = await fetch(`${process.env.API_URL}/api/rule-groups/${groupId}`, {
// method: "PUT",
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify(updateData),
// });
//
// if (!response.ok) {
// throw new Response("更新评查点分组失败", { status: response.status });
// }
// 模拟更新成功
console.log('保存分组数据:', { id: groupId, ...updateData });
// 重定向回列表页
return redirect('/rule-groups');
}
export default function EditRuleGroup() {
const { group } = useLoaderData<typeof loader>();
const actionData = useActionData<typeof action>();
const navigation = useNavigation();
const isSubmitting = navigation.state === "submitting";
const [formData, setFormData] = useState({
name: group.name,
code: group.code,
description: group.description || "",
status: group.status,
sortOrder: group.sortOrder.toString(),
});
// 当actionData中有错误时,保留用户输入的值
useEffect(() => {
if (actionData?.values) {
setFormData({
name: actionData.values.name,
code: actionData.values.code,
description: actionData.values.description || "",
status: actionData.values.status,
sortOrder: actionData.values.sortOrder,
});
}
}, [actionData]);
const handleChange = (e) => {
const { name, value } = e.target;
setFormData(prev => ({ ...prev, [name]: value }));
};
return (
<div className="edit-rule-group">
<div className="mb-6">
<h1 className="text-2xl font-medium"></h1>
</div>
<div className="card">
<Form method="post" className="space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="form-group">
<label htmlFor="name" className="block text-sm font-medium text-gray-700 mb-1">
<span className="text-red-500">*</span>
</label>
<input
type="text"
id="name"
name="name"
value={formData.name}
onChange={handleChange}
className={`w-full h-10 px-3 border ${actionData?.errors?.name ? 'border-red-500' : 'border-gray-300'} rounded-md focus:border-primary focus:ring-1 focus:ring-primary`}
placeholder="请输入分组名称"
/>
{actionData?.errors?.name && (
<p className="mt-1 text-sm text-red-500">{actionData.errors.name}</p>
)}
</div>
<div className="form-group">
<label htmlFor="code" className="block text-sm font-medium text-gray-700 mb-1">
<span className="text-red-500">*</span>
</label>
<input
type="text"
id="code"
name="code"
value={formData.code}
onChange={handleChange}
className={`w-full h-10 px-3 border ${actionData?.errors?.code ? 'border-red-500' : 'border-gray-300'} rounded-md focus:border-primary focus:ring-1 focus:ring-primary`}
placeholder="请输入分组编码"
/>
{actionData?.errors?.code && (
<p className="mt-1 text-sm text-red-500">{actionData.errors.code}</p>
)}
</div>
</div>
<div className="form-group">
<label htmlFor="description" className="block text-sm font-medium text-gray-700 mb-1">
</label>
<textarea
id="description"
name="description"
value={formData.description}
onChange={handleChange}
rows={3}
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:border-primary focus:ring-1 focus:ring-primary"
placeholder="请输入分组描述"
></textarea>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="form-group">
<label htmlFor="status" className="block text-sm font-medium text-gray-700 mb-1">
</label>
<select
id="status"
name="status"
value={formData.status}
onChange={handleChange}
className="w-full h-10 px-3 border border-gray-300 rounded-md focus:border-primary focus:ring-1 focus:ring-primary"
>
<option value="active"></option>
<option value="inactive"></option>
</select>
</div>
<div className="form-group">
<label htmlFor="sortOrder" className="block text-sm font-medium text-gray-700 mb-1">
</label>
<input
type="number"
id="sortOrder"
name="sortOrder"
value={formData.sortOrder}
onChange={handleChange}
className="w-full h-10 px-3 border border-gray-300 rounded-md focus:border-primary focus:ring-1 focus:ring-primary"
placeholder="请输入排序值"
min="0"
/>
</div>
</div>
<div className="flex justify-end space-x-3 pt-4 border-t border-gray-100">
<a
href="/rule-groups"
className="ant-btn ant-btn-default"
onClick={(e) => {
e.preventDefault();
window.history.back();
}}
>
</a>
<button
type="submit"
className="ant-btn ant-btn-primary"
disabled={isSubmitting}
>
{isSubmitting ? '保存中...' : '保存'}
</button>
</div>
</Form>
</div>
</div>
);
}
+283 -331
View File
@@ -1,384 +1,336 @@
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 { useLoaderData, Link, useNavigate } from "@remix-run/react";
import { useState } from "react";
import indexStyles from "~/styles/pages/rule-groups_index.css?url";
import { Card } from "~/components/ui/Card";
import { Button } from "~/components/ui/Button";
import { SearchBox } from "~/components/ui/SearchBox";
import { StatusDot } from "~/components/ui/StatusDot";
// 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;
subGroupCount: number;
status: 'active' | 'inactive';
createdAt: string;
level: 1 | 2; // 1-一级分组,2-二级分组
children?: RuleGroup[];
}
interface LoaderData {
groups: RuleGroup[];
export const handle = {
breadcrumb: "评查点分组"
};
export const meta: MetaFunction = () => {
return [
{ title: "评查点分组 - 中国烟草AI合同及卷宗审核系统" },
{ name: "description", content: "管理评查点分组,包括创建、编辑和删除分组" },
];
};
export function links() {
return [{ rel: "stylesheet", href: indexStyles }];
}
// 模拟数据
const MOCK_GROUPS: RuleGroup[] = [
{
id: "1",
name: "合同基本要素检查",
code: "contract-base",
ruleCount: 18,
subGroupCount: 12,
status: "active",
createdAt: "2023-10-01 14:30",
children: [
{
id: "2",
name: "必备要素检查",
code: "essential-elements",
ruleCount: 7,
subGroupCount: 0,
status: "active",
createdAt: "2023-10-02 10:15",
},
{
id: "3",
name: "合同主体检查",
code: "contract-parties",
ruleCount: 5,
subGroupCount: 0,
status: "active",
createdAt: "2023-10-03 16:20",
}
]
},
{
id: "4",
name: "销售合同专项检查",
code: "contract-sales",
ruleCount: 12,
subGroupCount: 5,
status: "active",
createdAt: "2023-10-05 09:30",
children: [
{
id: "6",
name: "付款条件检查",
code: "payment-terms",
ruleCount: 5,
subGroupCount: 0,
status: "active",
createdAt: "2023-10-05 14:45",
}
]
},
{
id: "5",
name: "行政处罚规范性检查",
code: "punishment",
ruleCount: 8,
subGroupCount: 0,
status: "inactive",
createdAt: "2023-10-08 11:45",
}
];
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<LoaderData>({ groups });
return json({ groups: MOCK_GROUPS });
}
export default function RuleGroupsPage() {
export default function RuleGroupsIndex() {
const { groups } = useLoaderData<typeof loader>();
const navigate = useNavigate();
const [searchText, setSearchText] = useState("");
const [groupCode, setGroupCode] = useState("");
const [expandedGroups, setExpandedGroups] = useState<string[]>([]);
// 过滤出父级分组和子级分组
const parentGroups = groups.filter(group => group.parentId === null);
// 根据父级ID获取子分组
const getChildGroups = (parentId: string) => {
return groups.filter(group => group.parentId === parentId);
// 处理展开/收起
const toggleGroup = (groupId: string) => {
setExpandedGroups(prev =>
prev.includes(groupId)
? prev.filter(id => id !== groupId)
: [...prev, groupId]
);
};
// 模拟删除操作
const handleDelete = (id: string) => {
if (window.confirm("确定要删除该分组吗?删除后无法恢复,且会删除该分组下的所有评查点。")) {
alert(`删除分组: ${id}`);
}
// 展开/收起全部
const toggleAll = (expand: boolean) => {
setExpandedGroups(expand ? groups.map(g => g.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 handleDeleteGroup = (groupId: string) => {
if (confirm("确定要删除该分组吗?此操作将同时删除该分组下的所有评查点,且不可恢复。")) {
console.log('删除分组ID:', groupId);
// 实际应用中,这里会调用API删除数据
}
};
// 键盘处理器
const handleKeyDown = (e: React.KeyboardEvent, groupId: string) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
toggleExpand(groupId);
}
// 处理搜索名称
const handleNameSearch = (value: string) => {
setSearchText(value);
// 实际项目中这里可能需要调用API或过滤本地数据
};
// 处理搜索编码
const handleCodeSearch = (value: string) => {
setGroupCode(value);
// 实际项目中这里可能需要调用API或过滤本地数据
};
// 处理表格数据,包括父子级关系
const processedData = groups.flatMap(group => {
// 先添加父级分组
const result: (RuleGroup & { isParent?: boolean, parentId?: string })[] = [
{ ...group, isParent: true }
];
// 如果有子级分组并且当前已展开,则添加子级分组
if (group.children && expandedGroups.includes(group.id)) {
group.children.forEach(child => {
result.push({ ...child, parentId: group.id });
});
}
return result;
});
return (
<div className="p-6">
{/* 页面标识 */}
<div className="mb-4 p-3 bg-blue-100 border border-blue-300 rounded text-blue-800">
<h3 className="font-bold text-lg">当前页面: 评查点分组列表 (rule-groups._index.tsx)</h3>
<p></p>
<div className="mt-2">
<a href="/debug" className="text-blue-600 hover:underline"></a> |
<a href="/" className="ml-2 text-blue-600 hover:underline"></a>
</div>
</div>
<div className="content-container rule-groups-page">
{/* 页面头部 */}
<div className="flex justify-between items-center mb-4">
<h2 className="text-xl font-medium"></h2>
<div className="flex">
<Button type="default" className="mr-2" icon="ri-arrow-down-s-line"
onClick={() => document.querySelectorAll(".child-row").forEach(row => (row as HTMLElement).style.display = "table-row")}>
<Button
type="default"
icon="ri-arrow-down-s-line"
onClick={() => toggleAll(true)}
className="mr-2"
>
</Button>
<Button type="default" className="mr-2" icon="ri-arrow-up-s-line"
onClick={() => document.querySelectorAll(".child-row").forEach(row => (row as HTMLElement).style.display = "none")}>
<Button
type="default"
icon="ri-arrow-up-s-line"
onClick={() => toggleAll(false)}
className="mr-2"
>
</Button>
<Button type="primary" icon="ri-add-line" onClick={handleCreate}>
<Button
type="primary"
icon="ri-add-line"
onClick={() => navigate("/rule-groups/new")}
>
</Button>
</div>
</div>
{/* 搜索栏 */}
<div className="card mb-4">
<div className="card-body">
<div className="flex flex-wrap items-end gap-4">
<div className="flex-1 min-w-[200px]">
<label htmlFor="groupName" className="form-label"></label>
<input type="text" id="groupName" className="form-input" placeholder="请输入分组名称" />
</div>
<div className="flex-1 min-w-[200px]">
<label htmlFor="groupCode" className="form-label"></label>
<input type="text" id="groupCode" className="form-input" placeholder="请输入分组编码" />
</div>
<div className="flex-1 min-w-[200px]">
<label htmlFor="groupStatus" className="form-label"></label>
<select id="groupStatus" className="form-select">
<option value=""></option>
<option value="true"></option>
<option value="false"></option>
</select>
</div>
<div className="flex items-center">
<Button type="default" className="mr-2" icon="ri-refresh-line">
</Button>
<Button type="primary" icon="ri-search-line">
</Button>
</div>
<Card className="mb-4" bodyClassName="px-4 py-4">
<div className="flex flex-wrap items-end gap-4">
<div className="flex-1 min-w-[200px]">
<label htmlFor="groupName" className="form-label"></label>
<SearchBox
placeholder="请输入分组名称"
defaultValue={searchText}
onSearch={handleNameSearch}
name="groupName"
buttonText=""
className="form-input-only"
/>
</div>
<div className="flex-1 min-w-[200px]">
<label htmlFor="groupCode" className="form-label"></label>
<SearchBox
placeholder="请输入分组编码"
defaultValue={groupCode}
onSearch={handleCodeSearch}
name="groupCode"
buttonText=""
className="form-input-only"
/>
</div>
<div className="flex-1 min-w-[200px]">
<label htmlFor="status" className="form-label"></label>
<select id="status" className="form-select">
<option value=""></option>
<option value="true"></option>
<option value="false"></option>
</select>
</div>
<div className="flex items-center">
<Button type="default" icon="ri-refresh-line" className="mr-2">
</Button>
<Button type="primary" icon="ri-search-line">
</Button>
</div>
</div>
</div>
</Card>
{/* 数据表格 */}
<div className="card">
<div className="card-body">
<div className="overflow-x-auto">
<table className="table tree-table">
<thead>
<tr>
<th style={{ width: "400px" }}></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th style={{ width: "180px" }}></th>
</tr>
</thead>
<tbody>
{parentGroups.map(parent => (
<React.Fragment key={parent.id}>
{/* 一级分组 */}
<tr className="group-row parent-row" data-group-id={parent.id}>
<td>
<div className="flex items-center">
<span
className="expand-icon"
data-group-id={parent.id}
onClick={() => toggleExpand(parent.id)}
onKeyDown={(e) => handleKeyDown(e, parent.id)}
role="button"
tabIndex={0}
aria-label="展开/收起"
>
<i className="ri-arrow-down-s-line text-primary"></i>
</span>
<Link
to={`/rules?groupId=${parent.id}`}
className="text-primary hover:underline flex items-center ml-1"
>
<i className="ri-folder-line mr-1"></i> {parent.name}
</Link>
<span className="group-badge parent-badge"></span>
</div>
</td>
<td>{parent.code}</td>
<td>
<Link to={`/rules?groupId=${parent.id}`} className="badge bg-primary text-white">
{parent.ruleCount}
</Link>
{parent.childGroupCount > 0 && (
<span className="text-secondary text-sm ml-1">
| : {parent.childGroupCount}
</span>
)}
</td>
<td>
<span className={`status-dot ${parent.isActive ? 'status-success' : 'status-error'}`}></span>
{parent.isActive ? '启用' : '禁用'}
</td>
<td>{parent.createdAt}</td>
<td className="py-3 px-2 text-center">
<Button
type="default"
size="small"
className="text-primary mr-2"
icon="ri-edit-line"
onClick={() => navigate(`/rule-groups/${parent.id}/edit`)}
<Card bodyClassName="px-4 py-4">
<div className="overflow-x-auto">
<table className="ant-table tree-table w-full">
<thead>
<tr>
<th style={{ width: "400px" }}></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th style={{ width: "180px" }}></th>
</tr>
</thead>
<tbody>
{processedData.map((item) => (
<tr key={item.id} className={`group-row ${item.isParent ? 'parent-row' : 'child-row child-of-' + item.parentId}`}>
<td>
<div className={`flex items-center ${!item.isParent ? 'ml-8' : ''}`}>
{item.isParent && (
<span
className="expand-icon"
onClick={() => toggleGroup(item.id)}
role="button"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
toggleGroup(item.id);
}
}}
>
</Button>
<Button
type="danger"
size="small"
icon="ri-delete-bin-line"
onClick={() => handleDelete(parent.id)}
>
</Button>
</td>
</tr>
{/* 二级分组 */}
{getChildGroups(parent.id).map(child => (
<tr
key={child.id}
className={`group-row child-row child-of-${parent.id}`}
data-parent-id={parent.id}
data-group-id={child.id}
<i className={`ri-arrow-${expandedGroups.includes(item.id) ? 'down' : 'right'}-s-line`}></i>
</span>
)}
<Link
to={`/rule-groups/${item.id}/rules`}
className="group-name-link flex items-center ml-1"
>
<td>
<div className="flex items-center ml-8">
<Link
to={`/rules?groupId=${child.id}`}
className="text-primary hover:underline flex items-center"
>
<i className="ri-file-list-line mr-1"></i> {child.name}
</Link>
<span className="group-badge child-badge"></span>
</div>
</td>
<td>{child.code}</td>
<td>
<Link to={`/rules?groupId=${child.id}`} className="badge bg-primary text-white">
{child.ruleCount}
</Link>
</td>
<td>
<span className={`status-dot ${child.isActive ? 'status-success' : 'status-error'}`}></span>
{child.isActive ? '启用' : '禁用'}
</td>
<td>{child.createdAt}</td>
<td className="py-3 px-2 text-center">
<Button
type="default"
size="small"
className="text-primary mr-2"
icon="ri-edit-line"
onClick={() => navigate(`/rule-groups/${child.id}/edit`)}
>
</Button>
<Button
type="danger"
size="small"
icon="ri-delete-bin-line"
onClick={() => handleDelete(child.id)}
>
</Button>
</td>
</tr>
))}
</React.Fragment>
))}
</tbody>
</table>
<i className={`${item.isParent ? 'ri-folder-line' : 'ri-file-list-line'} mr-1`}></i> {item.name}
</Link>
<span className={`group-badge ${item.isParent ? 'parent-badge' : 'child-badge'}`}>
{item.isParent ? '一级分组' : '二级分组'}
</span>
</div>
</td>
<td>{item.code}</td>
<td>
<Link to={`/rule-groups/${item.id}/rules`} className="badge bg-primary text-white">
{item.ruleCount}
</Link>
{item.subGroupCount > 0 && (
<span className="text-secondary text-sm ml-1">
| : {item.subGroupCount}
</span>
)}
</td>
<td>
<StatusDot status={item.status === 'active' ? 'success' : 'error'} text={item.status === 'active' ? '启用' : '禁用'} />
</td>
<td>{item.createdAt}</td>
<td>
<button
className="ant-btn ant-btn-text ant-btn-sm text-primary"
onClick={() => navigate(`/rule-groups/${item.id}`)}
>
<i className="ri-edit-line"></i>
</button>
<button
className="ant-btn ant-btn-text ant-btn-sm text-error"
onClick={() => handleDeleteGroup(item.id)}
>
<i className="ri-delete-bin-line"></i>
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
{/* 分页 */}
<div className="flex justify-between items-center mt-4">
<div className="text-sm text-secondary">
{groups.length} 10
</div>
<div className="ant-pagination">
<button className="ant-pagination-item ant-pagination-prev" disabled>
<i className="ri-arrow-left-s-line"></i>
</button>
<button className="ant-pagination-item ant-pagination-item-active">1</button>
<button className="ant-pagination-item ant-pagination-next" disabled>
<i className="ri-arrow-right-s-line"></i>
</button>
</div>
</div>
</div>
</Card>
</div>
);
}
+207
View File
@@ -0,0 +1,207 @@
// app/routes/rule-groups.new.tsx
import { json, redirect, type ActionFunctionArgs, type MetaFunction } from "@remix-run/node";
import { Form, useNavigation, useActionData } from "@remix-run/react";
import { useState, useEffect } from "react";
export const meta: MetaFunction = () => {
return [
{ title: "新建评查点分组 - 中国烟草AI合同及卷宗审核系统" },
{ name: "description", content: "创建新的评查点分组,包括分组名称、编码、描述和状态" },
];
};
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const name = formData.get("name");
const code = formData.get("code");
const description = formData.get("description");
const status = formData.get("status") || "active";
const sortOrder = formData.get("sortOrder") || "0";
// 基本验证
const errors = {};
if (!name) errors.name = "分组名称不能为空";
if (!code) errors.code = "分组编码不能为空";
if (Object.keys(errors).length > 0) {
return json({ errors, values: Object.fromEntries(formData) });
}
// 构建创建数据
const createData = {
name,
code,
description,
status,
sortOrder: Number(sortOrder) || 0,
};
// 真实环境中,这里会调用API创建数据
// const response = await fetch(`${process.env.API_URL}/api/rule-groups`, {
// method: "POST",
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify(createData),
// });
//
// if (!response.ok) {
// throw new Response("创建评查点分组失败", { status: response.status });
// }
// 模拟创建成功
console.log('创建分组数据:', createData);
// 重定向回列表页
return redirect('/rule-groups');
}
export default function NewRuleGroup() {
const actionData = useActionData<typeof action>();
const navigation = useNavigation();
const isSubmitting = navigation.state === "submitting";
const [formData, setFormData] = useState({
name: "",
code: "",
description: "",
status: "active",
sortOrder: "0",
});
// 当actionData中有错误时,保留用户输入的值
useEffect(() => {
if (actionData?.values) {
setFormData({
name: actionData.values.name,
code: actionData.values.code,
description: actionData.values.description || "",
status: actionData.values.status,
sortOrder: actionData.values.sortOrder,
});
}
}, [actionData]);
const handleChange = (e) => {
const { name, value } = e.target;
setFormData(prev => ({ ...prev, [name]: value }));
};
return (
<div className="new-rule-group">
<div className="mb-6">
<h1 className="text-2xl font-medium"></h1>
</div>
<div className="card">
<Form method="post" className="space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="form-group">
<label htmlFor="name" className="block text-sm font-medium text-gray-700 mb-1">
<span className="text-red-500">*</span>
</label>
<input
type="text"
id="name"
name="name"
value={formData.name}
onChange={handleChange}
className={`w-full h-10 px-3 border ${actionData?.errors?.name ? 'border-red-500' : 'border-gray-300'} rounded-md focus:border-primary focus:ring-1 focus:ring-primary`}
placeholder="请输入分组名称"
/>
{actionData?.errors?.name && (
<p className="mt-1 text-sm text-red-500">{actionData.errors.name}</p>
)}
</div>
<div className="form-group">
<label htmlFor="code" className="block text-sm font-medium text-gray-700 mb-1">
<span className="text-red-500">*</span>
</label>
<input
type="text"
id="code"
name="code"
value={formData.code}
onChange={handleChange}
className={`w-full h-10 px-3 border ${actionData?.errors?.code ? 'border-red-500' : 'border-gray-300'} rounded-md focus:border-primary focus:ring-1 focus:ring-primary`}
placeholder="请输入分组编码"
/>
{actionData?.errors?.code && (
<p className="mt-1 text-sm text-red-500">{actionData.errors.code}</p>
)}
</div>
</div>
<div className="form-group">
<label htmlFor="description" className="block text-sm font-medium text-gray-700 mb-1">
</label>
<textarea
id="description"
name="description"
value={formData.description}
onChange={handleChange}
rows={3}
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:border-primary focus:ring-1 focus:ring-primary"
placeholder="请输入分组描述"
></textarea>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="form-group">
<label htmlFor="status" className="block text-sm font-medium text-gray-700 mb-1">
</label>
<select
id="status"
name="status"
value={formData.status}
onChange={handleChange}
className="w-full h-10 px-3 border border-gray-300 rounded-md focus:border-primary focus:ring-1 focus:ring-primary"
>
<option value="active"></option>
<option value="inactive"></option>
</select>
</div>
<div className="form-group">
<label htmlFor="sortOrder" className="block text-sm font-medium text-gray-700 mb-1">
</label>
<input
type="number"
id="sortOrder"
name="sortOrder"
value={formData.sortOrder}
onChange={handleChange}
className="w-full h-10 px-3 border border-gray-300 rounded-md focus:border-primary focus:ring-1 focus:ring-primary"
placeholder="请输入排序值"
min="0"
/>
</div>
</div>
<div className="flex justify-end space-x-3 pt-4 border-t border-gray-100">
<a
href="/rule-groups"
className="ant-btn ant-btn-default"
onClick={(e) => {
e.preventDefault();
window.history.back();
}}
>
</a>
<button
type="submit"
className="ant-btn ant-btn-primary"
disabled={isSubmitting}
>
{isSubmitting ? '创建中...' : '创建'}
</button>
</div>
</Form>
</div>
</div>
);
}
+6 -16
View File
@@ -1,20 +1,10 @@
// app/routes/rule-groups.tsx
import { Outlet } from "@remix-run/react";
import { type MetaFunction } from "@remix-run/node";
export const links = () => [
{ rel: "stylesheet", href: "/rule-groups.css" }
];
export const meta: MetaFunction = () => {
return [
{ title: "中国烟草AI合同及卷宗审核系统 - 评查点分组管理" },
{ name: "description", content: "评查点分组管理页面" }
];
export const handle = {
breadcrumb: "评查规则库"
};
/**
* 评查点分组管理路由布局
*/
export default function RuleGroupsLayout() {
return <Outlet />;
}
export default function RuleGroupsLayout() {
return <Outlet />
}
+473 -225
View File
@@ -1,20 +1,30 @@
import React from 'react';
import { json, type MetaFunction, type LoaderFunctionArgs } from "@remix-run/node";
import { useLoaderData, useSearchParams } from "@remix-run/react";
import React, { useState } from 'react';
import { json, type MetaFunction, type LoaderFunctionArgs, redirect } from "@remix-run/node";
import { useLoaderData, useSearchParams, useSubmit } from "@remix-run/react";
import { Button } from '~/components/ui/Button';
import { Card } from '~/components/ui/Card';
import { Tag, type TagColor } from '~/components/ui/Tag';
import { SearchBox } from '~/components/ui/SearchBox';
import { Tag } from '~/components/ui/Tag';
import { StatusDot } from '~/components/ui/StatusDot';
import rulesStyles from "~/styles/pages/rules_index.css?url";
import type { Rule } from '~/models/rule';
import { RULE_TYPE_LABELS, RULE_TYPE_COLORS, RULE_PRIORITY_LABELS, RULE_PRIORITY_COLORS } from '~/models/rule';
import type { TagColor } from '~/components/ui/Tag';
import { Link } from '@remix-run/react';
export const links = () => [
{ rel: "stylesheet", href: "/rules_index.css" }
{ rel: "stylesheet", href: rulesStyles }
];
export const handle = {
breadcrumb: "评查点列表"
};
export const meta: MetaFunction = () => {
return [
{ title: "中国烟草AI合同及卷宗审核系统 - 评查点列表" },
{ name: "description", content: "评查点管理列表" }
{ name: "description", content: "管理评查点规则,支持根据类型、规则组和状态进行筛选" },
{ name: "keywords", content: "评查点,合同审核,规则管理,中国烟草" }
];
};
@@ -25,6 +35,9 @@ interface LoaderData {
name: string;
}[];
totalCount: number;
currentPage: number;
pageSize: number;
totalPages: number;
}
export async function loader({ request }: LoaderFunctionArgs) {
@@ -33,128 +46,269 @@ export async function loader({ request }: LoaderFunctionArgs) {
const groupId = url.searchParams.get("groupId") || "";
const isActive = url.searchParams.get("isActive") || "";
const keyword = url.searchParams.get("keyword") || "";
const currentPage = parseInt(url.searchParams.get("page") || "1", 10);
const pageSize = parseInt(url.searchParams.get("pageSize") || "10", 10);
// 模拟数据,实际项目中应从API获取
const rules: Rule[] = [
{
id: "1",
code: "CP001",
name: "合同主体信息完整性检查",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "essential",
priority: "high",
description: "检查合同中是否完整包含签约方的基本信息,包括名称、地址、法定代表人等",
checkMethod: "automatic",
prompt: "检查合同主体双方信息是否完整,包括企业名称、注册地址、法定代表人或授权代表、联系方式等",
isActive: true,
createdAt: "2023-06-15 10:30",
updatedAt: "2023-06-15 10:30"
},
{
id: "2",
code: "CP002",
name: "合同金额一致性校验",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "content",
priority: "high",
description: "检查合同大小写金额是否一致",
checkMethod: "automatic",
prompt: "检查合同中的金额大写和小写表示是否一致,如¥10,000.00(壹万元整)",
isActive: true,
createdAt: "2023-06-20 14:15",
updatedAt: "2023-06-20 14:15"
},
{
id: "3",
code: "CP003",
name: "保密条款合规性审核",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "legal",
priority: "medium",
description: "检查合同是否包含保密条款并符合行业要求",
checkMethod: "mixed",
prompt: "检查合同中的保密条款是否完整、清晰,包含保密范围、期限、违约责任等",
isActive: true,
createdAt: "2023-07-05 09:45",
updatedAt: "2023-07-05 09:45"
},
{
id: "4",
code: "CP004",
name: "合同签约日期格式检查",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "format",
priority: "low",
description: "检查合同签约日期格式是否规范",
checkMethod: "automatic",
prompt: "检查合同签约日期格式是否符合YYYY年MM月DD日的规范格式",
isActive: false,
createdAt: "2023-07-10 16:20",
updatedAt: "2023-07-10 16:20"
},
{
id: "5",
code: "CP005",
name: "违约责任条款完整性检查",
ruleGroupId: "2",
groupName: "销售合同专项检查",
ruleType: "legal",
priority: "high",
description: "检查合同违约责任条款是否明确、完整",
checkMethod: "mixed",
prompt: "检查合同中的违约责任条款是否包含违约情形、违约金计算方式、责任承担方式等内容",
isActive: true,
createdAt: "2023-07-15 11:30",
updatedAt: "2023-07-15 11:30"
try {
// 模拟数据,实际项目中应从API获取
const rules: Rule[] = [
{
id: "1",
code: "CP001",
name: "合同主体信息完整性检查",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "essential",
priority: "high",
description: "检查合同中是否完整包含签约方的基本信息,包括名称、地址、法定代表人等",
checkMethod: "automatic",
prompt: "检查合同主体双方信息是否完整,包括企业名称、注册地址、法定代表人或授权代表、联系方式等",
isActive: true,
createdAt: "2023-06-15 10:30",
updatedAt: "2023-06-15 10:30"
},
{
id: "2",
code: "CP002",
name: "合同金额一致性校验",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "content",
priority: "high",
description: "检查合同大小写金额是否一致",
checkMethod: "automatic",
prompt: "检查合同中的金额大写和小写表示是否一致,如¥10,000.00(壹万元整)",
isActive: true,
createdAt: "2023-06-20 14:15",
updatedAt: "2023-06-20 14:15"
},
{
id: "3",
code: "CP003",
name: "保密条款合规性审核",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "legal",
priority: "medium",
description: "检查合同是否包含保密条款并符合行业要求",
checkMethod: "mixed",
prompt: "检查合同中的保密条款是否完整、清晰,包含保密范围、期限、违约责任等",
isActive: true,
createdAt: "2023-07-05 09:45",
updatedAt: "2023-07-05 09:45"
},
{
id: "4",
code: "CP004",
name: "合同签约日期格式检查",
ruleGroupId: "1",
groupName: "合同基本要素检查",
ruleType: "format",
priority: "low",
description: "检查合同签约日期格式是否规范",
checkMethod: "automatic",
prompt: "检查合同签约日期格式是否符合YYYY年MM月DD日的规范格式",
isActive: false,
createdAt: "2023-07-10 16:20",
updatedAt: "2023-07-10 16:20"
},
{
id: "5",
code: "CP005",
name: "违约责任条款完整性检查",
ruleGroupId: "2",
groupName: "销售合同专项检查",
ruleType: "legal",
priority: "high",
description: "检查合同违约责任条款是否明确、完整",
checkMethod: "mixed",
prompt: "检查合同中的违约责任条款是否包含违约情形、违约金计算方式、责任承担方式等内容",
isActive: true,
createdAt: "2023-07-15 11:30",
updatedAt: "2023-07-15 11:30"
},
{
id: "6",
code: "CP006",
name: "交货期限有效性检查",
ruleGroupId: "2",
groupName: "销售合同专项检查",
ruleType: "business",
priority: "medium",
description: "检查合同中交货期限是否明确、合理",
checkMethod: "automatic",
prompt: "检查合同中是否明确约定了交货期限,并且期限设置是否合理",
isActive: true,
createdAt: "2023-08-01 14:40",
updatedAt: "2023-08-01 14:40"
},
{
id: "7",
code: "CP007",
name: "合同条款矛盾性检查",
ruleGroupId: "3",
groupName: "采购合同专项检查",
ruleType: "legal",
priority: "high",
description: "检查合同条款之间是否存在矛盾或冲突",
checkMethod: "mixed",
prompt: "分析合同各条款,检查是否存在相互矛盾或冲突的内容",
isActive: true,
createdAt: "2023-08-10 09:15",
updatedAt: "2023-08-10 09:15"
}
];
const groups = [
{ id: "1", name: "合同基本要素检查" },
{ id: "2", name: "销售合同专项检查" },
{ id: "3", name: "采购合同专项检查" },
{ id: "4", name: "专卖许可证审核规则" },
{ id: "5", name: "行政处罚规范性检查" }
];
// 过滤数据
let filteredRules = [...rules];
if (ruleType) {
filteredRules = filteredRules.filter(rule => rule.ruleType === ruleType);
}
];
const groups = [
{ id: "1", name: "合同基本要素检查" },
{ id: "2", name: "销售合同专项检查" },
{ id: "3", name: "采购合同专项检查" },
{ id: "4", name: "专卖许可证审核规则" },
{ id: "5", name: "行政处罚规范性检查" }
];
// 过滤数据
let filteredRules = [...rules];
if (ruleType) {
filteredRules = filteredRules.filter(rule => rule.ruleType === ruleType);
if (groupId) {
filteredRules = filteredRules.filter(rule => rule.ruleGroupId === groupId);
}
if (isActive) {
const activeValue = isActive === 'true';
filteredRules = filteredRules.filter(rule => rule.isActive === activeValue);
}
if (keyword) {
const lowerKeyword = keyword.toLowerCase();
filteredRules = filteredRules.filter(rule =>
rule.name.toLowerCase().includes(lowerKeyword) ||
rule.code.toLowerCase().includes(lowerKeyword)
);
}
// 计算分页信息
const totalCount = filteredRules.length;
const totalPages = Math.ceil(totalCount / pageSize);
// 验证页码范围
if (currentPage < 1 || (totalCount > 0 && currentPage > totalPages)) {
// 如果页码超出范围,重定向到第一页
const newUrl = new URL(request.url);
newUrl.searchParams.set('page', '1');
return redirect(newUrl.pathname + newUrl.search);
}
// 分页截取
const startIndex = (currentPage - 1) * pageSize;
const endIndex = startIndex + pageSize;
const paginatedRules = filteredRules.slice(startIndex, endIndex);
return json<LoaderData>({
rules: paginatedRules,
groups,
totalCount,
currentPage,
pageSize,
totalPages
}, {
headers: {
// 添加缓存控制,在生产环境中可以调整
"Cache-Control": "max-age=60, s-maxage=180"
}
});
} catch (error) {
console.error('加载评查点列表失败:', error);
throw new Response('加载评查点列表失败', { status: 500 });
}
if (groupId) {
filteredRules = filteredRules.filter(rule => rule.ruleGroupId === groupId);
}
if (isActive) {
const activeValue = isActive === 'true';
filteredRules = filteredRules.filter(rule => rule.isActive === activeValue);
}
if (keyword) {
const lowerKeyword = keyword.toLowerCase();
filteredRules = filteredRules.filter(rule =>
rule.name.toLowerCase().includes(lowerKeyword) ||
rule.code.toLowerCase().includes(lowerKeyword)
);
}
return json<LoaderData>({
rules: filteredRules,
groups,
totalCount: rules.length
});
}
export async function action({ request }: LoaderFunctionArgs) {
const formData = await request.formData();
const _action = formData.get('_action');
const ruleId = formData.get('ruleId');
if (!ruleId) {
return json({ success: false, error: "缺少评查点ID" }, { status: 400 });
}
try {
if (_action === 'delete') {
// 实际项目中应调用API删除评查点
console.log(`删除评查点 ${ruleId}`);
// 模拟API调用
// const response = await fetch(`/api/rules/${ruleId}`, {
// method: 'DELETE',
// });
// if (!response.ok) {
// throw new Error(`删除失败: ${response.status}`);
// }
return json({ success: true });
}
if (_action === 'duplicate') {
// 实际项目中应调用API复制评查点
console.log(`复制评查点 ${ruleId}`);
// 模拟API调用
// const response = await fetch(`/api/rules/${ruleId}/duplicate`, {
// method: 'POST',
// });
// if (!response.ok) {
// throw new Error(`复制失败: ${response.status}`);
// }
return json({ success: true });
}
return json({ success: false, error: "未知操作" }, { status: 400 });
} catch (error) {
console.error('操作评查点失败:', error);
return json({ success: false, error: "操作失败" }, { status: 500 });
}
}
export function ErrorBoundary() {
return (
<div className="error-container p-6">
<h1 className="text-xl font-bold text-red-500 mb-4"></h1>
<p className="mb-4"></p>
<Button type="primary" to="/"></Button>
</div>
);
}
// 规则类型和优先级的描述标签映射
const typeLabels = {
'essential': '基本要素类',
'content': '内容合规类',
'legal': '法律风险类',
'format': '格式规范类',
'business': '业务专项类'
};
const priorityLabels = {
'high': '高',
'medium': '中',
'low': '低'
};
export default function RulesList() {
const { rules, groups } = useLoaderData<typeof loader>();
const { rules, groups, totalCount, currentPage, pageSize, totalPages } = useLoaderData<typeof loader>();
const [searchParams, setSearchParams] = useSearchParams();
const submit = useSubmit();
// 状态管理
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
const [ruleToDelete, setRuleToDelete] = useState<Rule | null>(null);
const handleFilterChange = (e: React.ChangeEvent<HTMLSelectElement | HTMLInputElement>) => {
const { name, value } = e.target;
@@ -166,14 +320,13 @@ export default function RulesList() {
newParams.delete(name);
}
// 切换筛选条件时,重置到第一页
newParams.set('page', '1');
setSearchParams(newParams);
};
const handleSearch = (e: React.FormEvent) => {
e.preventDefault();
const formData = new FormData(e.target as HTMLFormElement);
const keyword = formData.get('keyword') as string;
const handleSearch = (keyword: string) => {
const newParams = new URLSearchParams(searchParams);
if (keyword) {
newParams.set('keyword', keyword);
@@ -181,33 +334,53 @@ export default function RulesList() {
newParams.delete('keyword');
}
// 搜索时,重置到第一页
newParams.set('page', '1');
setSearchParams(newParams);
};
const handleCopy = (rule: Rule) => {
// 实际项目中应调用API复制规则
alert(`复制规则: ${rule.name}`);
const handleDeleteClick = (rule: Rule) => {
setRuleToDelete(rule);
setShowDeleteConfirm(true);
};
const handleDelete = (rule: Rule) => {
// 实际项目中应调用API删除规则
if (window.confirm(`确定要删除评查点"${rule.name}"吗?`)) {
alert(`删除规则: ${rule.name}`);
}
const confirmDelete = () => {
if (!ruleToDelete) return;
const formData = new FormData();
formData.append('_action', 'delete');
formData.append('ruleId', ruleToDelete.id);
submit(formData, { method: 'post' });
setShowDeleteConfirm(false);
setRuleToDelete(null);
};
const handleCopy = (rule: Rule) => {
const formData = new FormData();
formData.append('_action', 'duplicate');
formData.append('ruleId', rule.id);
submit(formData, { method: 'post' });
};
const handlePageChange = (page: number) => {
const newParams = new URLSearchParams(searchParams);
newParams.set('page', page.toString());
setSearchParams(newParams);
};
const handlePageSizeChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const newPageSize = e.target.value;
const newParams = new URLSearchParams(searchParams);
newParams.set('pageSize', newPageSize);
newParams.set('page', '1'); // 更改每页条数时,重置到第一页
setSearchParams(newParams);
};
return (
<div className="p-6">
{/* 页面标识 */}
<div className="mb-4 p-3 bg-blue-100 border border-blue-300 rounded text-blue-800">
<h3 className="font-bold text-lg">当前页面: 评查点列表 (rules._index.tsx)</h3>
<p></p>
<div className="mt-2">
<a href="/debug" className="text-blue-600 hover:underline"></a> |
<a href="/" className="ml-2 text-blue-600 hover:underline"></a>
</div>
</div>
<div className="p-6 rules-page">
{/* 页面头部 */}
<div className="flex justify-between items-center mb-4">
<h2 className="text-xl font-medium"></h2>
@@ -217,28 +390,30 @@ export default function RulesList() {
</div>
{/* 筛选区域 */}
<Card className="mb-4" noDivider>
<div className="grid grid-cols-1 md:grid-cols-4 gap-4 p-4">
<Card className="card-container">
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<div>
<label htmlFor="ruleType" className="block text-sm mb-1"></label>
<label htmlFor="ruleType" className="form-label"></label>
<select
id="ruleType"
className="form-select w-full rounded border-gray-300 shadow-sm"
className="form-select"
name="ruleType"
value={searchParams.get('ruleType') || ''}
onChange={handleFilterChange}
>
<option value=""></option>
{Object.entries(RULE_TYPE_LABELS).map(([value, label]) => (
<option key={value} value={value}>{label}</option>
))}
<option value="essential"></option>
<option value="content"></option>
<option value="format"></option>
<option value="legal"></option>
<option value="business"></option>
</select>
</div>
<div>
<label htmlFor="groupId" className="block text-sm mb-1"></label>
<label htmlFor="groupId" className="form-label"></label>
<select
id="groupId"
className="form-select w-full rounded border-gray-300 shadow-sm"
className="form-select"
name="groupId"
value={searchParams.get('groupId') || ''}
onChange={handleFilterChange}
@@ -250,10 +425,10 @@ export default function RulesList() {
</select>
</div>
<div>
<label htmlFor="isActive" className="block text-sm mb-1"></label>
<label htmlFor="isActive" className="form-label"></label>
<select
id="isActive"
className="form-select w-full rounded border-gray-300 shadow-sm"
className="form-select"
name="isActive"
value={searchParams.get('isActive') || ''}
onChange={handleFilterChange}
@@ -264,88 +439,161 @@ export default function RulesList() {
</select>
</div>
<div>
<label htmlFor="keyword" className="block text-sm mb-1"></label>
<form onSubmit={handleSearch} className="flex items-center">
<input
type="text"
id="keyword"
name="keyword"
className="form-input rounded-l flex-1 border-gray-300 shadow-sm"
placeholder="输入评查点名称或编码"
defaultValue={searchParams.get('keyword') || ''}
/>
<Button type="primary" icon="ri-search-line" className="rounded-l-none">
</Button>
</form>
<label htmlFor="keyword" className="form-label"></label>
<SearchBox
placeholder="输入评查点名称或编码"
defaultValue={searchParams.get('keyword') || ''}
onSearch={handleSearch}
/>
</div>
</div>
</Card>
{/* 评查点列表 */}
<Card noDivider>
<Card className="ant-card">
<div className="overflow-x-auto">
<table className="w-full text-left border-collapse">
<thead className="bg-gray-50">
<tr className="text-xs text-gray-500 border-b">
<th className="py-3 px-4"></th>
<th className="py-3 px-4"></th>
<th className="py-3 px-4"></th>
<th className="py-3 px-4"></th>
<th className="py-3 px-4"></th>
<th className="py-3 px-4"></th>
<th className="py-3 px-4"></th>
<th className="py-3 px-4"></th>
<table className="ant-table">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{rules.map((rule) => {
const typeColor = RULE_TYPE_COLORS[rule.ruleType] as TagColor;
const priorityColor = RULE_PRIORITY_COLORS[rule.priority] as TagColor;
return (
<tr key={rule.id} className="border-b hover:bg-gray-50">
<td className="py-3 px-4">{rule.code}</td>
<td className="py-3 px-4">{rule.name}</td>
<td className="py-3 px-4">
<Tag color={typeColor}>{RULE_TYPE_LABELS[rule.ruleType]}</Tag>
</td>
<td className="py-3 px-4">{rule.groupName}</td>
<td className="py-3 px-4">
<Tag color={priorityColor}>{RULE_PRIORITY_LABELS[rule.priority]}</Tag>
</td>
<td className="py-3 px-4">
{rule.isActive ? (
<span className="flex items-center">
<i className="inline-block w-2 h-2 rounded-full bg-green-500 mr-2"></i>
</span>
) : (
<span className="flex items-center">
<i className="inline-block w-2 h-2 rounded-full bg-gray-400 mr-2"></i>
</span>
)}
</td>
<td className="py-3 px-4">{rule.createdAt}</td>
<td className="py-3 px-4">
<Button type="default" size="small" icon="ri-edit-line" to={`/rules/${rule.id}`} className="mr-1">
</Button>
<Button type="default" size="small" icon="ri-file-copy-line" className="mr-1" onClick={() => handleCopy(rule)}>
</Button>
<Button type="danger" size="small" icon="ri-delete-bin-line" onClick={() => handleDelete(rule)}>
</Button>
</td>
</tr>
);
})}
{rules.length > 0 ? (
rules.map((rule) => {
const typeColor = RULE_TYPE_COLORS[rule.ruleType] as TagColor;
const priorityColor = RULE_PRIORITY_COLORS[rule.priority] as TagColor;
return (
<tr key={rule.id}>
<td>{rule.code}</td>
<td>{rule.name}</td>
<td>
<Tag color={typeColor}>
{typeLabels[rule.ruleType as keyof typeof typeLabels] || RULE_TYPE_LABELS[rule.ruleType]}
</Tag>
</td>
<td>{rule.groupName}</td>
<td>
<Tag color={priorityColor}>
{priorityLabels[rule.priority as keyof typeof priorityLabels] || RULE_PRIORITY_LABELS[rule.priority]}
</Tag>
</td>
<td>
<StatusDot status={rule.isActive} />
</td>
<td>{rule.createdAt}</td>
<td className="operations-cell">
<Link to={`/rules/${rule.id}`} className="operation-btn">
<i className="ri-edit-line"></i>
</Link>
<button className="operation-btn" onClick={() => handleCopy(rule)}>
<i className="ri-file-copy-line"></i>
</button>
<button className="operation-btn operation-btn-danger" onClick={() => handleDeleteClick(rule)}>
<i className="ri-delete-bin-line"></i>
</button>
</td>
</tr>
);
})
) : (
<tr>
<td colSpan={8} className="text-center py-8 text-gray-500">
</td>
</tr>
)}
</tbody>
</table>
</div>
{/* 分页 */}
{totalCount > 0 && (
<div className="ant-pagination">
<div className="ant-pagination-options">
<span className="text-sm mr-2"> {totalCount} </span>
<select
className="form-select ant-pagination-options-size-changer"
style={{ width: "100px" }}
value={pageSize}
onChange={handlePageSizeChange}
>
<option value="10">10 /</option>
<option value="20">20 /</option>
<option value="50">50 /</option>
</select>
</div>
<div className="ant-pagination-right">
<button
className={`ant-pagination-item ant-pagination-prev ${currentPage <= 1 ? 'ant-pagination-disabled' : ''}`}
onClick={() => currentPage > 1 && handlePageChange(currentPage - 1)}
disabled={currentPage <= 1}
>
<i className="ri-arrow-left-s-line"></i>
</button>
{Array.from({ length: Math.min(totalPages, 5) }, (_, i) => {
// 显示当前页附近的页码,最多显示5个
let pageNum;
if (totalPages <= 5) {
// 总页数少于5,直接显示所有页码
pageNum = i + 1;
} else if (currentPage <= 3) {
// 当前页靠近开始
pageNum = i + 1;
} else if (currentPage >= totalPages - 2) {
// 当前页靠近结尾
pageNum = totalPages - 4 + i;
} else {
// 当前页在中间
pageNum = currentPage - 2 + i;
}
return (
<button
key={pageNum}
className={`ant-pagination-item ${pageNum === currentPage ? 'ant-pagination-item-active' : ''}`}
onClick={() => handlePageChange(pageNum)}
>
{pageNum}
</button>
);
})}
<button
className={`ant-pagination-item ant-pagination-next ${currentPage >= totalPages ? 'ant-pagination-disabled' : ''}`}
onClick={() => currentPage < totalPages && handlePageChange(currentPage + 1)}
disabled={currentPage >= totalPages}
>
<i className="ri-arrow-right-s-line"></i>
</button>
</div>
</div>
)}
</Card>
{/* 删除确认对话框 */}
{showDeleteConfirm && ruleToDelete && (
<div className="fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center z-50">
<div className="bg-white rounded-lg p-6 max-w-md w-full">
<h3 className="text-lg font-medium mb-4"></h3>
<p className="mb-6">&ldquo;{ruleToDelete.name}&rdquo;</p>
<div className="flex justify-end space-x-2">
<Button type="default" onClick={() => setShowDeleteConfirm(false)}></Button>
<Button type="danger" onClick={confirmDelete}></Button>
</div>
</div>
</div>
)}
</div>
);
}
+586
View File
@@ -0,0 +1,586 @@
import { json, type MetaFunction, type LoaderFunctionArgs } from "@remix-run/node";
import { useLoaderData, useSearchParams, useSubmit } from "@remix-run/react";
import { Button } from "~/components/ui/Button";
import { Card } from "~/components/ui/Card";
import { Table } from "~/components/ui/Table";
import { SearchBox } from "~/components/ui/SearchBox";
import rulesFilesStyles from "~/styles/pages/rules_files.css?url";
export const links = () => [
{ rel: "stylesheet", href: rulesFilesStyles }
];
export const handle = {
breadcrumb: "评查文件列表"
};
export const meta: MetaFunction = () => {
return [
{ title: "评查文件列表 - 中国烟草AI合同及卷宗审核系统" },
{ name: "description", content: "管理系统中所有上传的评查文件,支持按文件类型、评查状态进行筛选" },
{ name: "keywords", content: "评查文件,合同审核,中国烟草,文件管理" }
];
};
// 评查文件类型枚举
export enum FileType {
CONTRACT = 'contract',
LICENSE = 'license',
PUNISHMENT = 'punishment',
REPORT = 'report',
OTHER = 'other'
}
// 评查状态枚举
export enum ReviewStatus {
PASS = 'pass',
WARNING = 'warning',
FAIL = 'fail',
PENDING = 'pending'
}
// 日期范围枚举
export enum DateRange {
ALL = 'all',
TODAY = 'today',
WEEK = 'week',
MONTH = 'month',
CUSTOM = 'custom'
}
// 文件类型标签映射
export const FILE_TYPE_LABELS: Record<FileType, string> = {
[FileType.CONTRACT]: '合同文档',
[FileType.LICENSE]: '专卖许可证',
[FileType.PUNISHMENT]: '行政处罚',
[FileType.REPORT]: '报表文档',
[FileType.OTHER]: '其他文档'
};
// 评查状态标签映射
export const REVIEW_STATUS_LABELS: Record<ReviewStatus, string> = {
[ReviewStatus.PASS]: '通过',
[ReviewStatus.WARNING]: '警告',
[ReviewStatus.FAIL]: '不通过',
[ReviewStatus.PENDING]: '待人工确认'
};
// 评查文件模型
interface ReviewFile {
id: string;
fileName: string;
fileCode: string; // 文件编号
fileType: FileType;
fileSize: number;
uploadTime: string;
reviewStatus: ReviewStatus;
issueCount: number;
issues: Array<{
severity: 'info' | 'warning' | 'error' | 'critical';
message: string;
}>;
createdBy: string;
}
interface LoaderData {
files: ReviewFile[];
totalCount: number;
currentPage: number;
pageSize: number;
totalPages: number;
}
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);
const fileType = url.searchParams.get("fileType") || "";
const reviewStatus = url.searchParams.get("reviewStatus") || "";
const dateRange = url.searchParams.get("dateRange") || "";
const keyword = url.searchParams.get("keyword") || "";
const sortOrder = url.searchParams.get("sortOrder") || "upload_time_desc";
const currentPage = parseInt(url.searchParams.get("page") || "1", 10);
const pageSize = parseInt(url.searchParams.get("pageSize") || "10", 10);
try {
// 模拟数据,实际项目中应从API获取
const mockFiles: ReviewFile[] = [
{
id: "1",
fileName: "烟草产品销售合同(2023版).pdf",
fileCode: "XS-2023-1025-001",
fileType: FileType.CONTRACT,
fileSize: 1024 * 1024 * 2.5, // 2.5MB
uploadTime: "2023-10-25 14:30:45",
reviewStatus: ReviewStatus.WARNING,
issueCount: 3,
issues: [
{ severity: "warning", message: "付款条件描述不明确" },
{ severity: "warning", message: "违约责任条款缺失" },
{ severity: "warning", message: "签章不完整" }
],
createdBy: "张三"
},
{
id: "2",
fileName: "2023年度烟草专卖零售许可证.pdf",
fileCode: "LS-2023-0058",
fileType: FileType.LICENSE,
fileSize: 1024 * 1024 * 1.2, // 1.2MB
uploadTime: "2023-10-24 10:15:22",
reviewStatus: ReviewStatus.PASS,
issueCount: 0,
issues: [],
createdBy: "李四"
},
{
id: "3",
fileName: "XX公司违规处罚决定书.pdf",
fileCode: "处罚[2023]42号",
fileType: FileType.PUNISHMENT,
fileSize: 1024 * 1024 * 3.1, // 3.1MB
uploadTime: "2023-10-23 16:45:30",
reviewStatus: ReviewStatus.FAIL,
issueCount: 2,
issues: [
{ severity: "error", message: "处罚依据条款引用错误" },
{ severity: "error", message: "处罚金额超出规定范围" }
],
createdBy: "王五"
},
{
id: "4",
fileName: "烟草设备采购协议.docx",
fileCode: "CG-2023-0089",
fileType: FileType.CONTRACT,
fileSize: 1024 * 1024 * 0.8, // 0.8MB
uploadTime: "2023-10-22 09:22:15",
reviewStatus: ReviewStatus.PENDING,
issueCount: 1,
issues: [
{ severity: "warning", message: "交付日期条款存在歧义,需人工确认" }
],
createdBy: "赵六"
},
{
id: "5",
fileName: "2023年度销售额报表.xlsx",
fileCode: "BB-2023-Q3",
fileType: FileType.REPORT,
fileSize: 1024 * 1024 * 0.5, // 0.5MB
uploadTime: "2023-10-20 14:05:38",
reviewStatus: ReviewStatus.PASS,
issueCount: 0,
issues: [],
createdBy: "钱七"
}
];
// 过滤数据
let filteredFiles = [...mockFiles];
if (fileType) {
filteredFiles = filteredFiles.filter(file => file.fileType === fileType);
}
if (reviewStatus) {
filteredFiles = filteredFiles.filter(file => file.reviewStatus === reviewStatus);
}
if (dateRange) {
const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
switch (dateRange) {
case DateRange.TODAY:
filteredFiles = filteredFiles.filter(file => {
const fileDate = new Date(file.uploadTime.split(' ')[0]);
return fileDate >= today;
});
break;
case DateRange.WEEK:
const weekStart = new Date(today);
weekStart.setDate(today.getDate() - today.getDay());
filteredFiles = filteredFiles.filter(file => {
const fileDate = new Date(file.uploadTime.split(' ')[0]);
return fileDate >= weekStart;
});
break;
case DateRange.MONTH:
const monthStart = new Date(today.getFullYear(), today.getMonth(), 1);
filteredFiles = filteredFiles.filter(file => {
const fileDate = new Date(file.uploadTime.split(' ')[0]);
return fileDate >= monthStart;
});
break;
}
}
if (keyword) {
const lowerKeyword = keyword.toLowerCase();
filteredFiles = filteredFiles.filter(file =>
file.fileName.toLowerCase().includes(lowerKeyword) ||
file.fileCode.toLowerCase().includes(lowerKeyword)
);
}
// 排序
switch (sortOrder) {
case "upload_time_desc":
filteredFiles.sort((a, b) => new Date(b.uploadTime).getTime() - new Date(a.uploadTime).getTime());
break;
case "upload_time_asc":
filteredFiles.sort((a, b) => new Date(a.uploadTime).getTime() - new Date(b.uploadTime).getTime());
break;
case "issue_count_desc":
filteredFiles.sort((a, b) => b.issueCount - a.issueCount);
break;
case "issue_count_asc":
filteredFiles.sort((a, b) => a.issueCount - b.issueCount);
break;
}
// 计算分页信息
const totalCount = filteredFiles.length;
const totalPages = Math.ceil(totalCount / pageSize);
// 分页截取
const startIndex = (currentPage - 1) * pageSize;
const endIndex = startIndex + pageSize;
const paginatedFiles = filteredFiles.slice(startIndex, endIndex);
return json<LoaderData>({
files: paginatedFiles,
totalCount,
currentPage,
pageSize,
totalPages
}, {
headers: {
"Cache-Control": "max-age=60, s-maxage=180"
}
});
} catch (error) {
console.error('加载评查文件列表失败:', error);
throw new Response('加载评查文件列表失败', { status: 500 });
}
}
export function ErrorBoundary() {
return (
<div className="error-container p-6">
<h1 className="text-xl font-bold text-red-500 mb-4"></h1>
<p className="mb-4"></p>
<Button type="primary" to="/"></Button>
</div>
);
}
export default function ReviewFilesList() {
const { files, totalCount, currentPage, pageSize, totalPages } = useLoaderData<typeof loader>();
const [searchParams, setSearchParams] = useSearchParams();
const handleFilterChange = (e: React.ChangeEvent<HTMLSelectElement | HTMLInputElement>) => {
const { name, value } = e.target;
const newParams = new URLSearchParams(searchParams);
if (value) {
newParams.set(name, value);
} else {
newParams.delete(name);
}
// 切换筛选条件时,重置到第一页
newParams.set('page', '1');
setSearchParams(newParams);
};
const handleSearch = (keyword: string) => {
const newParams = new URLSearchParams(searchParams);
if (keyword) {
newParams.set('keyword', keyword);
} else {
newParams.delete('keyword');
}
// 搜索时,重置到第一页
newParams.set('page', '1');
setSearchParams(newParams);
};
const handlePageChange = (page: number) => {
const newParams = new URLSearchParams(searchParams);
newParams.set('page', page.toString());
setSearchParams(newParams);
};
// 渲染问题摘要
const renderIssues = (issues: ReviewFile['issues']) => {
if (issues.length === 0) {
return (
<div className="text-sm text-success">
<i className="ri-check-double-line mr-1"></i>
</div>
);
}
return (
<div className="text-sm">
{issues.slice(0, 3).map((issue, index) => (
<div key={index} className="mb-1 last:mb-0">
<span className={`severity-indicator severity-${issue.severity}`}></span>
{issue.message}
</div>
))}
</div>
);
};
// 渲染文件图标
const renderFileIcon = (fileName: string) => {
if (fileName.endsWith('.pdf')) {
return <i className="ri-file-pdf-line text-red-500 mr-2 text-lg"></i>;
} else if (fileName.endsWith('.docx') || fileName.endsWith('.doc')) {
return <i className="ri-file-word-2-line text-blue-500 mr-2 text-lg"></i>;
} else if (fileName.endsWith('.xlsx') || fileName.endsWith('.xls')) {
return <i className="ri-file-excel-2-line text-green-500 mr-2 text-lg"></i>;
} else {
return <i className="ri-file-line text-gray-500 mr-2 text-lg"></i>;
}
};
return (
<div className="p-6 review-files-page">
{/* 页面头部 */}
<div className="flex justify-between items-center mb-4">
<div className="flex items-center">
<h2 className="text-xl font-medium"></h2>
<div className="flex items-center ml-4 bg-white px-3 py-1 rounded-md">
<i className="ri-file-list-3-line text-primary text-lg mr-1"></i>
<span className="text-sm text-secondary"></span>
<span className="text-base font-bold text-primary ml-1">{totalCount}</span>
</div>
</div>
<Button type="primary" icon="ri-file-upload-line" to="/files/new">
</Button>
</div>
{/* 筛选区域 */}
<Card className="card-container">
<div className="flex flex-wrap items-end gap-3">
<div className="w-48">
<div className="mb-1 text-sm font-medium"></div>
<select
className="form-select w-full"
name="fileType"
value={searchParams.get('fileType') || ''}
onChange={handleFilterChange}
>
<option value=""></option>
<option value={FileType.CONTRACT}></option>
<option value={FileType.LICENSE}></option>
<option value={FileType.PUNISHMENT}></option>
<option value={FileType.REPORT}></option>
<option value={FileType.OTHER}></option>
</select>
</div>
<div className="w-48">
<div className="mb-1 text-sm font-medium"></div>
<select
className="form-select w-full"
name="reviewStatus"
value={searchParams.get('reviewStatus') || ''}
onChange={handleFilterChange}
>
<option value=""></option>
<option value={ReviewStatus.PASS}></option>
<option value={ReviewStatus.WARNING}></option>
<option value={ReviewStatus.FAIL}></option>
<option value={ReviewStatus.PENDING}></option>
</select>
</div>
<div className="w-48">
<div className="mb-1 text-sm font-medium"></div>
<select
className="form-select w-full"
name="dateRange"
value={searchParams.get('dateRange') || ''}
onChange={handleFilterChange}
>
<option value=""></option>
<option value={DateRange.TODAY}></option>
<option value={DateRange.WEEK}></option>
<option value={DateRange.MONTH}></option>
<option value={DateRange.CUSTOM}></option>
</select>
</div>
<div className="w-72">
<div className="mb-1 text-sm font-medium"></div>
<div className="flex border border-gray-300 rounded overflow-hidden">
<SearchBox
placeholder="搜索文件名、合同编号或关键词"
defaultValue={searchParams.get('keyword') || ''}
onSearch={handleSearch}
className="search-input"
buttonText="搜索"
/>
</div>
</div>
<div className="ml-auto">
<select
className="form-select w-auto"
name="sortOrder"
value={searchParams.get('sortOrder') || 'upload_time_desc'}
onChange={handleFilterChange}
>
<option value="upload_time_desc"> </option>
<option value="upload_time_asc"> </option>
<option value="issue_count_desc"> </option>
<option value="issue_count_asc"> </option>
</select>
</div>
</div>
</Card>
{/* 文件列表 */}
<Card className="content-card">
<table className="ant-table">
<thead>
<tr>
<th style={{ width: "30%" }}></th>
<th style={{ width: "12%" }}></th>
<th style={{ width: "12%" }}></th>
<th style={{ width: "12%" }}></th>
<th style={{ width: "20%" }}></th>
<th style={{ width: "14%" }}></th>
</tr>
</thead>
<tbody>
{files.length > 0 ? (
files.map((file) => (
<tr key={file.id}>
<td>
<div className="flex items-center">
{renderFileIcon(file.fileName)}
<div>
<div className="font-medium">{file.fileName}</div>
<div className="text-xs text-secondary mt-1">
{file.fileType === FileType.CONTRACT && "合同编号:"}
{file.fileType === FileType.LICENSE && "许可证号:"}
{file.fileType === FileType.PUNISHMENT && "文号:"}
{file.fileType === FileType.REPORT && "报表编号:"}
{file.fileCode}
</div>
</div>
</div>
</td>
<td>
<span className={`file-type-badge file-type-${file.fileType}`}>
{file.fileType === FileType.CONTRACT && <i className="ri-file-list-3-line"></i>}
{file.fileType === FileType.LICENSE && <i className="ri-vip-crown-line"></i>}
{file.fileType === FileType.PUNISHMENT && <i className="ri-scales-line"></i>}
{file.fileType === FileType.REPORT && <i className="ri-file-chart-line"></i>}
{file.fileType === FileType.OTHER && <i className="ri-file-line"></i>}
{FILE_TYPE_LABELS[file.fileType]}
</span>
</td>
<td>
{file.uploadTime.split(' ')[0]}
<br />
<span className="text-xs text-secondary">{file.uploadTime.split(' ')[1]}</span>
</td>
<td>
<span className={`status-badge status-${file.reviewStatus}`}>
{file.reviewStatus === ReviewStatus.PASS && <i className="ri-checkbox-circle-line mr-1"></i>}
{file.reviewStatus === ReviewStatus.WARNING && <i className="ri-alert-line mr-1"></i>}
{file.reviewStatus === ReviewStatus.FAIL && <i className="ri-close-circle-line mr-1"></i>}
{file.reviewStatus === ReviewStatus.PENDING && <i className="ri-time-line mr-1"></i>}
{REVIEW_STATUS_LABELS[file.reviewStatus]}
{file.issueCount > 0 && ` (${file.issueCount})`}
</span>
</td>
<td>
{renderIssues(file.issues)}
</td>
<td>
{file.reviewStatus === ReviewStatus.PENDING ? (
<Button type="primary" size="small" icon="ri-check-double-line" className="mr-2">
</Button>
) : (
<Button type="default" size="small" icon="ri-eye-line" to={`/files/${file.id}`} className="mr-2">
</Button>
)}
<Button type="default" size="small" icon="ri-download-2-line">
</Button>
</td>
</tr>
))
) : (
<tr>
<td colSpan={6} className="text-center py-8 text-gray-500">
</td>
</tr>
)}
</tbody>
</table>
{/* 分页 */}
{totalCount > 0 && (
<div className="pagination">
<button
className={`pagination-item ${currentPage <= 1 ? 'disabled' : ''}`}
onClick={() => currentPage > 1 && handlePageChange(currentPage - 1)}
disabled={currentPage <= 1}
>
<i className="ri-arrow-left-s-line"></i>
</button>
{Array.from({ length: Math.min(totalPages, 5) }, (_, i) => {
// 显示当前页附近的页码,最多显示5个
let pageNum;
if (totalPages <= 5) {
// 总页数少于5,直接显示所有页码
pageNum = i + 1;
} else if (currentPage <= 3) {
// 当前页靠近开始
pageNum = i + 1;
} else if (currentPage >= totalPages - 2) {
// 当前页靠近结尾
pageNum = totalPages - 4 + i;
} else {
// 当前页在中间
pageNum = currentPage - 2 + i;
}
return (
<button
key={pageNum}
className={`pagination-item ${pageNum === currentPage ? 'active' : ''}`}
onClick={() => handlePageChange(pageNum)}
>
{pageNum}
</button>
);
})}
<button
className={`pagination-item ${currentPage >= totalPages ? 'disabled' : ''}`}
onClick={() => currentPage < totalPages && handlePageChange(currentPage + 1)}
disabled={currentPage >= totalPages}
>
<i className="ri-arrow-right-s-line"></i>
</button>
</div>
)}
</Card>
</div>
);
}
+14 -7
View File
@@ -1,20 +1,27 @@
import { Outlet } from "@remix-run/react";
import { type MetaFunction } from "@remix-run/node";
// export const links = () => [
// { rel: "stylesheet", href: "app/styles/pages/rules.css" }
// ];
export const meta: MetaFunction = () => {
return [
{ title: "中国烟草AI合同及卷宗审核系统 - 规则管理" },
{ name: "description", content: "规则管理页面" }
{ title: "评查规则管理 - 中国烟草AI合同及卷宗审核系统" },
{
name: "description",
content: "评查规则管理模块,包括评查点列表、创建和编辑功能"
}
];
};
export const handle = {
breadcrumb: "评查规则库"
};
/**
* 规则管理路由布局
*/
export default function RulesLayout() {
return (
<>
<Outlet />
</>
);
return <Outlet />;
}