评查点,增改逻辑完善
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user