完善列表和编辑页面的数据验证和交互,实现服务端和客户端两重数据验证
This commit is contained in:
@@ -338,7 +338,7 @@ export default function ConfigNew() {
|
||||
case 'name':
|
||||
if(value.trim() === ""){
|
||||
return "配置名称不能为空";
|
||||
}else if(/^[a-zA-Z_]+$/.test(value)){
|
||||
}else if(!/^[a-zA-Z_]+$/.test(value)){
|
||||
return "配置名称只能包含英文字母和下划线";
|
||||
}else if(value.length > 100){
|
||||
return "配置名称不能超过100个字符";
|
||||
@@ -574,7 +574,7 @@ export default function ConfigNew() {
|
||||
{/* 配置名称和状态 */}
|
||||
<div className="form-row">
|
||||
<div className="form-group">
|
||||
<label htmlFor="name" className="form-label required">配置名称</label>
|
||||
<label htmlFor="name" className="form-label ">配置名称 <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="text"
|
||||
id="name"
|
||||
@@ -583,7 +583,6 @@ export default function ConfigNew() {
|
||||
value={formValues.name}
|
||||
onChange={handleInputChange}
|
||||
placeholder="请输入配置名称,如database_connection"
|
||||
required
|
||||
/>
|
||||
{touchedFields.name && formErrors.name && (
|
||||
<div className="error-message">{formErrors.name}</div>
|
||||
@@ -619,7 +618,7 @@ export default function ConfigNew() {
|
||||
|
||||
{/* 所属模块 */}
|
||||
<div className="form-group">
|
||||
<label htmlFor="type" className="form-label required">所属模块</label>
|
||||
<label htmlFor="type" className="form-label">所属模块 <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="hidden"
|
||||
name="type"
|
||||
@@ -633,7 +632,7 @@ export default function ConfigNew() {
|
||||
onChange={handleInputChange}
|
||||
name="type"
|
||||
placeholder="请输入或选择所属模块"
|
||||
required
|
||||
|
||||
/>
|
||||
{touchedFields.type && formErrors.type && (
|
||||
<div className="error-message">{formErrors.type}</div>
|
||||
@@ -657,7 +656,7 @@ export default function ConfigNew() {
|
||||
|
||||
{/* 环境 */}
|
||||
<div className="form-group">
|
||||
<label htmlFor="environment" className="form-label required">环境</label>
|
||||
<label htmlFor="environment" className="form-label">环境 <span className="text-red-500">*</span></label>
|
||||
<input
|
||||
type="hidden"
|
||||
name="environment"
|
||||
@@ -671,7 +670,6 @@ export default function ConfigNew() {
|
||||
onChange={handleInputChange}
|
||||
name="environment"
|
||||
placeholder="请输入或选择环境"
|
||||
required
|
||||
/>
|
||||
{touchedFields.environment && formErrors.environment && (
|
||||
<div className="error-message">{formErrors.environment}</div>
|
||||
@@ -695,7 +693,7 @@ export default function ConfigNew() {
|
||||
|
||||
{/* 配置数据 */}
|
||||
<div className="form-group">
|
||||
<label htmlFor="config" className="form-label required">配置数据 (JSON)</label>
|
||||
<label htmlFor="config" className="form-label ">配置数据 (JSON) <span className="text-red-500">*</span></label>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4" style={{ minHeight: '390px' }}>
|
||||
{/* 左侧JSON编辑区 */}
|
||||
<div className="h-full">
|
||||
@@ -705,7 +703,7 @@ export default function ConfigNew() {
|
||||
className={`json-editor ${touchedFields.config && formErrors.config ? 'input-error' : ''}`}
|
||||
value={formValues.config}
|
||||
onChange={handleConfigDataChange}
|
||||
required
|
||||
|
||||
placeholder='请输入JSON格式的配置数据'
|
||||
/>
|
||||
<div className="editor-actions">
|
||||
|
||||
Reference in New Issue
Block a user