feat: sync rule management and review ui fixes
This commit is contained in:
@@ -7,8 +7,8 @@ import { FilterPanel, FilterSelect, SearchFilter } from '~/components/ui/FilterP
|
||||
import { Pagination } from '~/components/ui/Pagination';
|
||||
import { Table } from '~/components/ui/Table';
|
||||
import { Tag, type TagColor } from '~/components/ui/Tag';
|
||||
import { loadRuleConfigPacks } from '~/utils/rules-config-packs.server';
|
||||
import type { RuleSummary, RuleYamlPack } from '~/utils/rules-yaml-mock.server';
|
||||
import { loadRuleConfigPackSummaries, type RuleConfigPackSummary } from '~/utils/rules-config-packs.server';
|
||||
import type { RuleSummary } from '~/utils/rules-yaml-mock.server';
|
||||
import styles from '~/styles/pages/rules_test.css?url';
|
||||
|
||||
export const links = () => [
|
||||
@@ -31,12 +31,12 @@ type RuleRow = RuleSummary & {
|
||||
mainType: string;
|
||||
subtype: string;
|
||||
yamlName: string;
|
||||
yamlStatus: RuleYamlPack['sourceStatus'];
|
||||
yamlStatus: RuleConfigPackSummary['sourceStatus'];
|
||||
isPlaceholder?: boolean;
|
||||
};
|
||||
|
||||
type LoaderData = {
|
||||
rows: RuleRow[];
|
||||
packs: RuleYamlPack[];
|
||||
filters: {
|
||||
documentType: string;
|
||||
mainType: string;
|
||||
@@ -61,7 +61,7 @@ function unique(values: string[]): string[] {
|
||||
return Array.from(new Set(values.filter(Boolean)));
|
||||
}
|
||||
|
||||
function resolveDocumentScope(pack: Pick<RuleYamlPack, 'documentType' | 'mainType' | 'moduleType'>): string {
|
||||
function resolveDocumentScope(pack: Pick<RuleConfigPackSummary, 'documentType' | 'mainType' | 'moduleType'>): string {
|
||||
const values = [pack.documentType, pack.mainType, pack.moduleType].join(' ');
|
||||
if (values.includes('合同')) return '合同';
|
||||
if (values.includes('案卷') || values.includes('卷宗') || values.includes('行政处罚') || values.includes('行政许可')) {
|
||||
@@ -71,7 +71,7 @@ function resolveDocumentScope(pack: Pick<RuleYamlPack, 'documentType' | 'mainTyp
|
||||
return pack.documentType || pack.mainType || pack.moduleType || '未分类';
|
||||
}
|
||||
|
||||
function resolveBusinessType(pack: Pick<RuleYamlPack, 'businessType' | 'mainType'>): string {
|
||||
function resolveBusinessType(pack: Pick<RuleConfigPackSummary, 'businessType' | 'mainType'>): string {
|
||||
return pack.businessType || pack.mainType || '';
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
pageSize: [10, 20, 30, 50].includes(requestedPageSize) ? requestedPageSize : 10
|
||||
};
|
||||
|
||||
const packs = await loadRuleConfigPacks(request);
|
||||
const packs = await loadRuleConfigPackSummaries(request);
|
||||
const packScopes = packs.map(pack => ({
|
||||
pack,
|
||||
scope: resolveDocumentScope(pack),
|
||||
@@ -158,11 +158,11 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
moduleType: pack.moduleType,
|
||||
mainType: resolveBusinessType(pack),
|
||||
subtype: pack.subtype,
|
||||
yamlName: pack.metadata.name || '待配置 YAML',
|
||||
yamlName: pack.yamlName || '待配置 YAML',
|
||||
yamlStatus: pack.sourceStatus,
|
||||
id: `${pack.id}-empty`,
|
||||
ruleId: '-',
|
||||
name: '暂无规则配置',
|
||||
name: `${pack.subtype}待配置`,
|
||||
group: '待配置',
|
||||
risk: '-',
|
||||
score: '-',
|
||||
@@ -176,7 +176,10 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
stageCount: 0,
|
||||
appliesIn: [],
|
||||
prompt: '',
|
||||
description: '当前文档类型已保留规则列表与 YAML 配置页流程,等待后续接入规则文件。'
|
||||
description: pack.sourceStatus === 'missing'
|
||||
? '当前规则集已建立,但生效版本正文暂未成功加载,请进入配置页检查并重新保存。'
|
||||
: '当前子类型还没有正式评查点,请进入配置页补充字段、子文档与评查规则。',
|
||||
isPlaceholder: true,
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -188,7 +191,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
moduleType: pack.moduleType,
|
||||
mainType: resolveBusinessType(pack),
|
||||
subtype: pack.subtype,
|
||||
yamlName: pack.metadata.name,
|
||||
yamlName: pack.yamlName,
|
||||
yamlStatus: pack.sourceStatus
|
||||
}));
|
||||
}).filter(row => {
|
||||
@@ -207,7 +210,6 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
|
||||
return Response.json({
|
||||
rows,
|
||||
packs,
|
||||
filters: {
|
||||
...filters,
|
||||
page: currentPage
|
||||
@@ -292,7 +294,7 @@ export default function RulesTestList() {
|
||||
render: (_: unknown, record: RuleRow) => (
|
||||
<div className="rule-name">
|
||||
<strong>{record.name}</strong>
|
||||
<span>{record.ruleId}</span>
|
||||
<span>{record.isPlaceholder ? record.description : record.ruleId}</span>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
@@ -320,7 +322,9 @@ export default function RulesTestList() {
|
||||
width: '8%',
|
||||
align: 'center' as const,
|
||||
render: (_: unknown, record: RuleRow) => (
|
||||
<Tag color={riskColor(record.risk)} size="sm">{record.risk}</Tag>
|
||||
<Tag color={record.isPlaceholder ? (record.yamlStatus === 'missing' ? 'orange' : 'blue') : riskColor(record.risk)} size="sm">
|
||||
{record.isPlaceholder ? (record.yamlStatus === 'missing' ? '待修复' : '待配置') : record.risk}
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
@@ -329,7 +333,7 @@ export default function RulesTestList() {
|
||||
width: '8%',
|
||||
align: 'center' as const,
|
||||
render: (_: unknown, record: RuleRow) => (
|
||||
<Tag color="gray" size="sm">{record.score}</Tag>
|
||||
<Tag color="gray" size="sm">{record.isPlaceholder ? '-' : record.score}</Tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
@@ -337,7 +341,7 @@ export default function RulesTestList() {
|
||||
key: 'dependencies',
|
||||
width: '20%',
|
||||
render: (_: unknown, record: RuleRow) => (
|
||||
<span>{record.dependencies.length > 0 ? record.dependencies.slice(0, 3).join('、') : '-'}</span>
|
||||
<span>{record.isPlaceholder ? '先进入配置页补规则与依赖' : (record.dependencies.length > 0 ? record.dependencies.slice(0, 3).join('、') : '-')}</span>
|
||||
)
|
||||
},
|
||||
{
|
||||
@@ -347,7 +351,7 @@ export default function RulesTestList() {
|
||||
align: 'center' as const,
|
||||
render: (_: unknown, record: RuleRow) => (
|
||||
<Link className="operation-btn" to={`/rulesTest/detail?packId=${encodeURIComponent(record.packId)}&ruleId=${encodeURIComponent(record.ruleId || record.id)}`}>
|
||||
<i className="ri-settings-3-line"></i> 配置
|
||||
<i className="ri-settings-3-line"></i> {record.isPlaceholder ? '去配置' : '配置'}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user