fix: 1. 继续对齐交叉评查的接口,完善创建交叉评查的逻辑 和 相关组件的渲染布局。
2. 文档的基本信息修改改用接口。 3. 重新完善角色权限管理的页面逻辑。 4.将评查点列表中的返回逻辑改用浏览器的记忆返回。
This commit is contained in:
+20
-36
@@ -66,6 +66,7 @@ interface ApiRule {
|
||||
priority: string;
|
||||
description: string;
|
||||
isActive: boolean;
|
||||
area?: string; // 地区
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -96,6 +97,7 @@ function mapApiRuleToModel(apiRule: ApiRule): Rule {
|
||||
checkMethod: 'automatic', // 默认值
|
||||
prompt: apiRule.description, // 使用描述作为默认prompt
|
||||
isActive: apiRule.isActive,
|
||||
area: apiRule.area || '', // 地区
|
||||
createdAt: apiRule.createdAt,
|
||||
updatedAt: apiRule.updatedAt
|
||||
};
|
||||
@@ -224,26 +226,6 @@ export default function RulesIndex() {
|
||||
// 使用 ref 跟踪是否正在加载数据,避免重复加载
|
||||
const isLoadingRef = useRef(false);
|
||||
|
||||
// 查询参数记忆 key 与保存/恢复
|
||||
const SEARCH_PARAMS_STORAGE_KEY = 'rules.searchParams';
|
||||
const persistSearchParams = (params: URLSearchParams) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
sessionStorage.setItem(SEARCH_PARAMS_STORAGE_KEY, params.toString());
|
||||
}
|
||||
};
|
||||
|
||||
// 首次进入页且 URL 无参数时尝试恢复
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
const hasAnyParam = Array.from(searchParams.keys()).length > 0;
|
||||
const stored = sessionStorage.getItem(SEARCH_PARAMS_STORAGE_KEY);
|
||||
if (!hasAnyParam && stored) {
|
||||
setSearchParams(new URLSearchParams(stored));
|
||||
}
|
||||
// 仅初始化检查一次
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// 获取当前的ruleType值
|
||||
const ruleTypeParam = searchParams.get('ruleType');
|
||||
|
||||
@@ -500,10 +482,9 @@ export default function RulesIndex() {
|
||||
|
||||
// 切换筛选条件时,重置到第一页
|
||||
newParams.set('page', '1');
|
||||
persistSearchParams(newParams);
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
|
||||
// 搜索评查点
|
||||
const handleSearch = (keyword: string) => {
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
@@ -512,10 +493,9 @@ export default function RulesIndex() {
|
||||
} else {
|
||||
newParams.delete('keyword');
|
||||
}
|
||||
|
||||
|
||||
// 搜索时,重置到第一页
|
||||
newParams.set('page', '1');
|
||||
persistSearchParams(newParams);
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
@@ -651,7 +631,6 @@ export default function RulesIndex() {
|
||||
const handlePageChange = (page: number) => {
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
newParams.set('page', page.toString());
|
||||
persistSearchParams(newParams);
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
@@ -660,10 +639,9 @@ export default function RulesIndex() {
|
||||
const newParams = new URLSearchParams(searchParams);
|
||||
newParams.set('pageSize', size.toString());
|
||||
newParams.set('page', '1'); // 更改每页条数时,重置到第一页
|
||||
persistSearchParams(newParams);
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
|
||||
// 处理重置筛选
|
||||
const handleReset = () => {
|
||||
const input = document.querySelector('input[placeholder="输入评查点名称或编码"]');
|
||||
@@ -672,9 +650,6 @@ export default function RulesIndex() {
|
||||
}
|
||||
|
||||
const newParams = new URLSearchParams();
|
||||
if (typeof window !== 'undefined') {
|
||||
sessionStorage.removeItem(SEARCH_PARAMS_STORAGE_KEY);
|
||||
}
|
||||
setSearchParams(newParams);
|
||||
};
|
||||
|
||||
@@ -707,7 +682,7 @@ export default function RulesIndex() {
|
||||
dataIndex: "code" as keyof Rule,
|
||||
key: "code",
|
||||
align: "left" as const,
|
||||
width: "20%",
|
||||
width: "15%",
|
||||
className: "whitespace-normal break-all",
|
||||
render: (value: string) => (
|
||||
<div className="whitespace-normal break-all overflow-visible">{value}</div>
|
||||
@@ -718,13 +693,13 @@ export default function RulesIndex() {
|
||||
dataIndex: "name" as keyof Rule,
|
||||
key: "name",
|
||||
align: "left" as const,
|
||||
width: "20%"
|
||||
width: "15%"
|
||||
},
|
||||
{
|
||||
title: "评查点类型",
|
||||
key: "ruleType",
|
||||
align: "left" as const,
|
||||
width: "12%",
|
||||
width: "10%",
|
||||
render: (_: unknown, record: Rule) => {
|
||||
const typeColor = RULE_TYPE_COLORS[record.ruleType] as TagColor;
|
||||
return (
|
||||
@@ -741,11 +716,19 @@ export default function RulesIndex() {
|
||||
align: "left" as const,
|
||||
width: "10%"
|
||||
},
|
||||
{
|
||||
title: "地区",
|
||||
dataIndex: "area" as keyof Rule,
|
||||
key: "area",
|
||||
align: "left" as const,
|
||||
width: "6%",
|
||||
render: (value: string) => value || '-'
|
||||
},
|
||||
{
|
||||
title: "优先级",
|
||||
key: "priority",
|
||||
align: "left" as const,
|
||||
width: "8%",
|
||||
width: "6%",
|
||||
render: (_: unknown, record: Rule) => {
|
||||
const priorityColor = RULE_PRIORITY_COLORS[record.priority] as TagColor;
|
||||
return (
|
||||
@@ -759,7 +742,7 @@ export default function RulesIndex() {
|
||||
title: "状态",
|
||||
key: "isActive",
|
||||
align: "left" as const,
|
||||
width: "8%",
|
||||
width: "6%",
|
||||
render: (_: unknown, record: Rule) => (
|
||||
<StatusDot status={record.isActive} text={record.isActive ? "启用" : "禁用"} />
|
||||
)
|
||||
@@ -775,7 +758,7 @@ export default function RulesIndex() {
|
||||
title: "操作",
|
||||
key: "operation",
|
||||
align: "left" as const,
|
||||
width: "10%",
|
||||
width: "150px",
|
||||
render: (_: unknown, record: Rule) => (
|
||||
<div className="operations-cell">
|
||||
{/* ✅ 查看/编辑和复制按钮 - 需要查看权限 */}
|
||||
@@ -943,6 +926,7 @@ export default function RulesIndex() {
|
||||
rowKey="id"
|
||||
// emptyText={loading ? "正在加载数据..." : "暂无评查点数据"}
|
||||
className="rules-table"
|
||||
scroll={{ y: 700 }}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user