评查点,增改逻辑完善

This commit is contained in:
2025-04-07 01:49:24 +08:00
parent e0f1725c23
commit 8885aec931
3 changed files with 462 additions and 127 deletions
+8 -7
View File
@@ -28,6 +28,7 @@ export const handle = {
// 定义类型
interface RegexField {
id: string;
fieldName: string;
regex: string;
}
@@ -191,7 +192,7 @@ export default function RuleNew() {
}
},
ocr_regex: {
fields: []
fields: [{ id: '1', fieldName: '', regex: '' }]
}
},
@@ -372,7 +373,8 @@ export default function RuleNew() {
}
},
ocr_regex: {
fields: (extractionConfig.regex?.fields || []).map((field) => ({
fields: (extractionConfig.regex?.fields || []).map((field, index) => ({
id: String(index + 1),
fieldName: field.field || '',
regex: field.pattern || ''
}))
@@ -489,13 +491,14 @@ export default function RuleNew() {
// 根据抽取方法更新对应字段
const updatedExtractionConfig = { ...prevData.extraction_config };
// 更新正则抽取字段
// 更新正则抽取字段 - 修改这里,只要有字段名就保存,不要求正则必须有内容
if (regexFields) {
updatedExtractionConfig.ocr_regex.fields = regexFields
.filter(field => field.fieldName && field.regex)
.filter(field => field.fieldName && field.fieldName.trim() !== '')
.map(field => ({
id: field.id || `${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
fieldName: field.fieldName,
regex: field.regex
regex: field.regex || '' // 即使正则为空也保留
}));
}
@@ -544,8 +547,6 @@ export default function RuleNew() {
}
}
console.log('更新的抽取设置:', updatedExtractionConfig);
return {
...prevData,
extraction_config: updatedExtractionConfig