import { useState } from 'react'; interface BasicInfoProps { onChange?: (data: Record) => void; } export function BasicInfo({ onChange }: BasicInfoProps) { const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false); const [formData, setFormData] = useState({ name: '', code: '', riskLevel: 'medium', type: '', group: 'contract-base', enabled: true, description: '', lawName: '', lawArticles: '', lawContent: '' }); const toggleDescription = () => { setIsDescriptionExpanded(!isDescriptionExpanded); }; const handleInputChange = (e: React.ChangeEvent) => { const { id, value } = e.target; let fieldName = id; // 映射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; } const newData = { ...formData, [fieldName]: id === 'is-enabled' ? value === 'true' : value }; setFormData(newData); if (onChange) { onChange(newData); } }; return (

基本信息

请使用简洁明了的名称,不超过30个字符
用于系统标识的唯一编码
请定义评查点的风险等级
评查点类型用于分类管理,便于规则统一调用
创建后是否立即启用此评查点
{ if (e.key === 'Enter' || e.key === ' ') { toggleDescription(); } }} aria-expanded={isDescriptionExpanded} aria-controls="description-section" >

评查点描述与法律依据

详细描述有助于其他用户了解该评查点的用途
{/* 引用法典输入区域 */}
多个条款用逗号分隔,将自动转换为数组格式
引用的法律条文将在评查结果中显示,帮助用户理解评查规则的法律依据
{/* 预览区域 */}
预览效果
{formData.lawName || '《中华人民共和国民法典》'}
{formData.lawArticles ? formData.lawArticles.split(',').map((article, index) => ( {article.trim()} )) : ( <> 第五百八十五条 第五百八十六条 )}
{formData.lawContent || '当事人应当按照约定全面履行自己的义务。'}
); }