diff --git a/app/components/rules/new/BasicInfo.tsx b/app/components/rules/new/BasicInfo.tsx index 3afd207..d77274a 100644 --- a/app/components/rules/new/BasicInfo.tsx +++ b/app/components/rules/new/BasicInfo.tsx @@ -1,49 +1,105 @@ -import { useState } from 'react'; +import React, { useState } from 'react'; interface BasicInfoProps { onChange?: (data: Record) => void; } +// 定义表单数据类型 +interface FormDataType { + name: string; + code: string; + risk: string; + is_enabled: boolean; + description: string; + references_laws: { + name: string; + articles: string[]; + content: string; + }; + evaluation_point_groups_id: number | null; + type: string; +} + export function BasicInfo({ onChange }: BasicInfoProps) { - const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false); - const [formData, setFormData] = useState({ + const [formData, setFormData] = useState({ name: '', code: '', - riskLevel: 'medium', - type: '', - group: 'contract-base', - enabled: true, + risk: 'medium', + is_enabled: true, description: '', - lawName: '', - lawArticles: '', - lawContent: '' + references_laws: { + name: '', + articles: [], + content: '' + }, + evaluation_point_groups_id: null, + type: '' }); - const toggleDescription = () => { - setIsDescriptionExpanded(!isDescriptionExpanded); + const [isDescExpanded, setIsDescExpanded] = useState(false); + const [lawArticlesInput, setLawArticlesInput] = useState(''); + + const handleToggleDescription = () => { + setIsDescExpanded(!isDescExpanded); }; const handleInputChange = (e: React.ChangeEvent) => { const { id, value } = e.target; - let fieldName = id; + const newData = { ...formData }; // 映射id到表单字段名 switch(id) { - case 'checkpoint-name': fieldName = 'name'; break; - case 'checkpoint-code': fieldName = 'code'; break; - case 'risk-level': fieldName = 'riskLevel'; break; - case 'checkpointType': fieldName = 'type'; break; - case 'rule-group': fieldName = 'group'; break; - case 'is-enabled': fieldName = 'enabled'; break; - case 'checkpoint-description': fieldName = 'description'; break; - case 'law-name': fieldName = 'lawName'; break; - case 'law-articles': fieldName = 'lawArticles'; break; - case 'law-content': fieldName = 'lawContent'; break; + case 'rule-name': + newData.name = value; + break; + case 'rule-code': + newData.code = value; + break; + case 'risk-level': + newData.risk = value; + break; + case 'is-enabled': + newData.is_enabled = value === 'true'; + break; + case 'rule-description': + newData.description = value; + break; + case 'law-name': + newData.references_laws.name = value; + break; + case 'law-content': + newData.references_laws.content = value; + break; + case 'law-articles': + setLawArticlesInput(value); + break; + case 'evaluation-point-group': + newData.evaluation_point_groups_id = value ? parseInt(value) : null; + break; + case 'checkpoint-type': + newData.type = value; + break; } + setFormData(newData); + + if (onChange) { + onChange(newData); + } + }; + + const handleLawArticlesChange = (value: string) => { + setLawArticlesInput(value); + const articles = value.split(',') + .map(article => article.trim()) + .filter(article => article !== ''); + const newData = { ...formData, - [fieldName]: id === 'is-enabled' ? value === 'true' : value + references_laws: { + ...formData.references_laws, + articles + } }; setFormData(newData); @@ -61,28 +117,28 @@ export function BasicInfo({ onChange }: BasicInfoProps) {
-
-
- +
@@ -143,7 +202,7 @@ export function BasicInfo({ onChange }: BasicInfoProps) {
创建后是否立即启用此评查点
+
{ if (e.key === 'Enter' || e.key === ' ') { - toggleDescription(); + handleToggleDescription(); } }} - aria-expanded={isDescriptionExpanded} - aria-controls="description-section" + tabIndex={0} + role="button" > -

评查点描述与法律依据

+
-
+
- -
详细描述有助于其他用户了解该评查点的用途
- + {/* 引用法典输入区域 */}
@@ -194,7 +251,7 @@ export function BasicInfo({ onChange }: BasicInfoProps) { className="form-input" placeholder="例如:《中华人民共和国民法典》" id="law-name" - value={formData.lawName} + value={formData.references_laws.name} onChange={handleInputChange} />
@@ -206,8 +263,8 @@ export function BasicInfo({ onChange }: BasicInfoProps) { className="form-input" placeholder="例如:第五百八十五条,第五百八十六条" id="law-articles" - value={formData.lawArticles} - onChange={handleInputChange} + value={lawArticlesInput} + onChange={(e) => handleLawArticlesChange(e.target.value)} />
多个条款用逗号分隔,将自动转换为数组格式
@@ -219,7 +276,7 @@ export function BasicInfo({ onChange }: BasicInfoProps) { style={{ minHeight: '60px' }} placeholder="例如:当事人应当按照约定全面履行自己的义务。" id="law-content" - value={formData.lawContent} + value={formData.references_laws.content} onChange={handleInputChange} >
@@ -233,12 +290,13 @@ export function BasicInfo({ onChange }: BasicInfoProps) {
预览效果
- {formData.lawName || '《中华人民共和国民法典》'} + {formData.references_laws.name || '《中华人民共和国民法典》'}
- {formData.lawArticles ? formData.lawArticles.split(',').map((article, index) => ( - {article.trim()} - )) : ( + {formData.references_laws.articles.length > 0 ? + formData.references_laws.articles.map((article, index) => ( + {article} + )) : ( <> 第五百八十五条 第五百八十六条 @@ -246,7 +304,7 @@ export function BasicInfo({ onChange }: BasicInfoProps) { )}
- {formData.lawContent || '当事人应当按照约定全面履行自己的义务。'} + {formData.references_laws.content || '当事人应当按照约定全面履行自己的义务。'}
diff --git a/app/components/rules/new/ExtractionSettings.tsx b/app/components/rules/new/ExtractionSettings.tsx index a6fc131..26c3d64 100644 --- a/app/components/rules/new/ExtractionSettings.tsx +++ b/app/components/rules/new/ExtractionSettings.tsx @@ -84,7 +84,7 @@ export function ExtractionSettings({ onChange }: ExtractionSettingsProps) { // 更新全局Context中的字段 if (ruleContext) { - ruleContext.updateExtractionFields(allFields); + ruleContext.updateFields(allFields); } // 触发自定义事件,通知字段已更新(兼容非Context的实现) diff --git a/app/components/rules/new/PageHeader.tsx b/app/components/rules/new/PageHeader.tsx index f1b907e..37b342a 100644 --- a/app/components/rules/new/PageHeader.tsx +++ b/app/components/rules/new/PageHeader.tsx @@ -1,6 +1,3 @@ -import React from 'react'; -import { Link } from '@remix-run/react'; - interface PageHeaderProps { title: string; onSave?: () => void; @@ -8,7 +5,7 @@ interface PageHeaderProps { export function PageHeader({ title, onSave }: PageHeaderProps) { return ( -
+

{title}

@@ -1220,19 +1264,19 @@ export function ReviewSettings({ onChange }: ReviewSettingsProps) { className="form-textarea" style={{ height: '80px', minHeight: '60px' }} placeholder="请输入对用户的建议信息" - value={suggestMessage} + value={suggestion_message} onChange={(e) => handleMessageChange('suggest', e.target.value)} >
- {/* 不通过提示类别 */} + {/* 建议信息类别 */}

建议信息类别

-
+
handleSeverityChange('info')} @@ -1242,24 +1286,24 @@ export function ReviewSettings({ onChange }: ReviewSettingsProps) { } }} role="radio" - aria-checked={errorSeverity === 'info'} + aria-checked={suggestion_message_type === 'info'} tabIndex={0} > handleSeverityChange('info')} /> - +
提示 (Info)
-
提示性信息,不影响
+
建议性提示,不影响评查结果
- {errorSeverity === 'info' && ( + {suggestion_message_type === 'info' && (
@@ -1267,7 +1311,7 @@ export function ReviewSettings({ onChange }: ReviewSettingsProps) {
handleSeverityChange('warning')} @@ -1277,24 +1321,24 @@ export function ReviewSettings({ onChange }: ReviewSettingsProps) { } }} role="radio" - aria-checked={errorSeverity === 'warning'} + aria-checked={suggestion_message_type === 'warning'} tabIndex={0} > handleSeverityChange('warning')} /> - +
警告 (Warning)
-
警告信息,建议修改但不强制
+
需引起注意的问题
- {errorSeverity === 'warning' && ( + {suggestion_message_type === 'warning' && (
@@ -1302,7 +1346,7 @@ export function ReviewSettings({ onChange }: ReviewSettingsProps) {
handleSeverityChange('error')} @@ -1312,24 +1356,24 @@ export function ReviewSettings({ onChange }: ReviewSettingsProps) { } }} role="radio" - aria-checked={errorSeverity === 'error'} + aria-checked={suggestion_message_type === 'error'} tabIndex={0} > handleSeverityChange('error')} /> - +
错误 (Error)
严重错误,必须修正
- {errorSeverity === 'error' && ( + {suggestion_message_type === 'error' && (
@@ -1341,17 +1385,17 @@ export function ReviewSettings({ onChange }: ReviewSettingsProps) { {/* 评查后动作 */}
-