完美版本
This commit is contained in:
@@ -627,7 +627,8 @@ export function ReviewSettings({
|
||||
initialConfig = {
|
||||
field: originalConfig.field || '',
|
||||
checkField: originalConfig.checkField || originalConfig.field || '',
|
||||
formatType: originalConfig.formatType || '',
|
||||
formatType: originalConfig.formatType || 'date',
|
||||
parameters: originalConfig.parameters || '',
|
||||
formatParams: originalConfig.formatParams || originalConfig.parameters || '',
|
||||
availableFields: availableFields
|
||||
};
|
||||
@@ -636,6 +637,9 @@ export function ReviewSettings({
|
||||
initialConfig = {
|
||||
conditions: Array.isArray(originalConfig.conditions) ? originalConfig.conditions : [],
|
||||
logic: originalConfig.logic || originalConfig.logicRelation || 'and',
|
||||
initialField: '',
|
||||
initialOperator: 'eq',
|
||||
initialValue: '',
|
||||
availableFields: availableFields
|
||||
};
|
||||
break;
|
||||
@@ -1260,10 +1264,16 @@ export function ReviewSettings({
|
||||
const field = (config.initialField as string) || '';
|
||||
const operator = e.target.value;
|
||||
|
||||
handleRuleConfigChange(id, {
|
||||
initialOperator: operator,
|
||||
conditions: [{ field, operator, value: '' }]
|
||||
});
|
||||
// 如果field已经设置,则创建完整的条件
|
||||
if (field) {
|
||||
handleRuleConfigChange(id, {
|
||||
initialOperator: operator,
|
||||
conditions: [{ field, operator, value: '' }]
|
||||
});
|
||||
} else {
|
||||
// 仅保存操作符值
|
||||
handleRuleConfigChange(id, { initialOperator: operator });
|
||||
}
|
||||
// 触发配置更新
|
||||
generateEvaluationConfig();
|
||||
}}
|
||||
@@ -1292,10 +1302,16 @@ export function ReviewSettings({
|
||||
const operator = (config.initialOperator as string) || 'eq';
|
||||
const value = e.target.value;
|
||||
|
||||
handleRuleConfigChange(id, {
|
||||
initialValue: value,
|
||||
conditions: [{ field, operator, value }]
|
||||
});
|
||||
// 如果已经设置了字段,则创建条件
|
||||
if (field) {
|
||||
handleRuleConfigChange(id, {
|
||||
initialValue: value,
|
||||
conditions: [{ field, operator, value }]
|
||||
});
|
||||
} else {
|
||||
// 否则只保存值
|
||||
handleRuleConfigChange(id, { initialValue: value });
|
||||
}
|
||||
// 触发配置更新
|
||||
generateEvaluationConfig();
|
||||
}}
|
||||
@@ -1314,10 +1330,19 @@ export function ReviewSettings({
|
||||
// 直接获取当前的conditions数组,或初始化为空数组
|
||||
const conditions = Array.isArray(config.conditions) ? [...(config.conditions as Condition[])] : [];
|
||||
|
||||
// 如果数组为空,尝试从初始字段创建条件
|
||||
if (conditions.length === 0 && config.initialField) {
|
||||
const field = config.initialField as string;
|
||||
const operator = (config.initialOperator as string) || 'eq';
|
||||
const value = (config.initialValue as string) || '';
|
||||
|
||||
if (field) {
|
||||
conditions.push({ field, operator, value });
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新的空白条件
|
||||
const newCondition = { field: '', operator: 'eq', value: '' };
|
||||
|
||||
// 无论如何,都添加一个新的空白行
|
||||
conditions.push(newCondition);
|
||||
|
||||
// 更新配置
|
||||
@@ -1384,7 +1409,7 @@ export function ReviewSettings({
|
||||
<select
|
||||
id={`regex-field-${id}`}
|
||||
className="form-select"
|
||||
value={config.checkField as string || ''}
|
||||
value={config.checkField as string || config.field as string || ''}
|
||||
onChange={(e) => {
|
||||
handleRuleConfigChange(id, {
|
||||
checkField: e.target.value,
|
||||
@@ -1402,11 +1427,12 @@ export function ReviewSettings({
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<label className="form-label" htmlFor={`regex-pattern-${id}`}>正则表达式 <span className="required-mark">*</span></label>
|
||||
<textarea
|
||||
<input
|
||||
type="text"
|
||||
id={`regex-pattern-${id}`}
|
||||
className="form-textarea"
|
||||
className="form-input"
|
||||
placeholder="请输入正则表达式"
|
||||
value={config.regexPattern as string || ''}
|
||||
value={config.regexPattern as string || config.pattern as string || ''}
|
||||
onChange={(e) => {
|
||||
handleRuleConfigChange(id, {
|
||||
regexPattern: e.target.value,
|
||||
@@ -1415,36 +1441,47 @@ export function ReviewSettings({
|
||||
// 直接触发配置更新
|
||||
generateEvaluationConfig();
|
||||
}}
|
||||
></textarea>
|
||||
/>
|
||||
<div className="form-tip">
|
||||
输入标准正则表达式,例如: "^[a-zA-Z0-9]+$" 表示仅允许字母和数字
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<fieldset>
|
||||
<legend className="form-label">匹配类型 <span className="required-mark">*</span></legend>
|
||||
<div className="form-radio-group">
|
||||
<label className="form-radio-item">
|
||||
<input
|
||||
type="radio"
|
||||
name={`regexMatchType_${id}`}
|
||||
className="form-radio"
|
||||
value="match"
|
||||
checked={!config.matchType || config.matchType === 'match'}
|
||||
onChange={(e) => handleRuleConfigChange(id, { matchType: e.target.value })}
|
||||
/>
|
||||
<span>必须匹配(符合为通过)</span>
|
||||
</label>
|
||||
<label className="form-radio-item">
|
||||
<input
|
||||
type="radio"
|
||||
name={`regexMatchType_${id}`}
|
||||
className="form-radio"
|
||||
value="not_match"
|
||||
checked={config.matchType === 'not_match'}
|
||||
onChange={(e) => handleRuleConfigChange(id, { matchType: e.target.value })}
|
||||
/>
|
||||
<span>不得匹配(不符合为通过)</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<label className="form-label" htmlFor={`match-type-${id}`}>匹配类型 <span className="required-mark">*</span></label>
|
||||
<div className="form-radio-group">
|
||||
<label className="form-radio-item">
|
||||
<input
|
||||
type="radio"
|
||||
id={`match-type-match-${id}`}
|
||||
name={`match_type_${id}`}
|
||||
className="form-radio"
|
||||
value="match"
|
||||
checked={!config.matchType || config.matchType === 'match'}
|
||||
onChange={(e) => {
|
||||
handleRuleConfigChange(id, { matchType: e.target.value });
|
||||
// 直接触发配置更新
|
||||
generateEvaluationConfig();
|
||||
}}
|
||||
/>
|
||||
<span>必须匹配(符合为通过)</span>
|
||||
</label>
|
||||
<label className="form-radio-item">
|
||||
<input
|
||||
type="radio"
|
||||
id={`match-type-not-match-${id}`}
|
||||
name={`match_type_${id}`}
|
||||
className="form-radio"
|
||||
value="not_match"
|
||||
checked={config.matchType === 'not_match'}
|
||||
onChange={(e) => {
|
||||
handleRuleConfigChange(id, { matchType: e.target.value });
|
||||
// 直接触发配置更新
|
||||
generateEvaluationConfig();
|
||||
}}
|
||||
/>
|
||||
<span>不得匹配(不符合为通过)</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -1600,11 +1637,11 @@ export function ReviewSettings({
|
||||
return (
|
||||
<div className="config-section">
|
||||
<div className="mb-4">
|
||||
<label className="form-label" htmlFor={`format-field-${id}`}>判断字段 <span className="required-mark">*</span></label>
|
||||
<label className="form-label" htmlFor={`format-field-${id}`}>检查字段 <span className="required-mark">*</span></label>
|
||||
<select
|
||||
id={`format-field-${id}`}
|
||||
className="form-select"
|
||||
value={config.checkField as string || ''}
|
||||
value={config.checkField as string || config.field as string || ''}
|
||||
onChange={(e) => {
|
||||
handleRuleConfigChange(id, {
|
||||
checkField: e.target.value,
|
||||
@@ -1614,7 +1651,7 @@ export function ReviewSettings({
|
||||
generateEvaluationConfig();
|
||||
}}
|
||||
>
|
||||
<option value="">请选择判断字段</option>
|
||||
<option value="">请选择检查字段</option>
|
||||
{availableFields.map((field, idx) => (
|
||||
<option key={`format-field-${idx}`} value={field}>{field}</option>
|
||||
))}
|
||||
@@ -1624,8 +1661,8 @@ export function ReviewSettings({
|
||||
<label className="form-label" htmlFor={`format-type-${id}`}>格式类型 <span className="required-mark">*</span></label>
|
||||
<select
|
||||
id={`format-type-${id}`}
|
||||
className="form-select format-type"
|
||||
value={config.formatType as string || ''}
|
||||
className="form-select"
|
||||
value={config.formatType as string || 'date'}
|
||||
onChange={(e) => {
|
||||
handleRuleConfigChange(id, { formatType: e.target.value });
|
||||
// 直接触发配置更新
|
||||
@@ -1637,29 +1674,32 @@ export function ReviewSettings({
|
||||
<option value="number">数字格式</option>
|
||||
<option value="phone">电话号码</option>
|
||||
<option value="email">电子邮箱</option>
|
||||
<option value="bankcard">银行卡号</option>
|
||||
<option value="idcard">身份证号码</option>
|
||||
<option value="zipcode">邮政编码</option>
|
||||
<option value="uscc">统一社会信用代码</option>
|
||||
<option value="bank">银行卡号</option>
|
||||
<option value="id">身份证号码</option>
|
||||
<option value="postal">邮政编码</option>
|
||||
<option value="credit">统一社会信用代码</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="mb-4">
|
||||
<label className="form-label" htmlFor={`format-params-${id}`}>参数设置</label>
|
||||
<input
|
||||
type="text"
|
||||
id={`format-params-${id}`}
|
||||
<label className="form-label" htmlFor={`format-parameters-${id}`}>格式参数</label>
|
||||
<input
|
||||
type="text"
|
||||
id={`format-parameters-${id}`}
|
||||
className="form-input"
|
||||
placeholder="请输入参数设置"
|
||||
value={config.formatParams as string || ''}
|
||||
value={config.formatParams as string || config.parameters as string || ''}
|
||||
placeholder="输入格式参数,如日期格式YYYY-MM-DD"
|
||||
onChange={(e) => {
|
||||
handleRuleConfigChange(id, {
|
||||
formatParams: e.target.value,
|
||||
parameters: e.target.value // 同步更新内部参数字段
|
||||
parameters: e.target.value
|
||||
});
|
||||
// 直接触发配置更新
|
||||
generateEvaluationConfig();
|
||||
}}
|
||||
/>
|
||||
<div className="form-tip">
|
||||
根据格式类型传入特定参数,如日期格式可传入"YYYY-MM-DD"
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user