Showing
1 changed file
with
25 additions
and
10 deletions
| ... | @@ -184,10 +184,7 @@ | ... | @@ -184,10 +184,7 @@ |
| 184 | } | 184 | } |
| 185 | }, | 185 | }, |
| 186 | methods: { | 186 | methods: { |
| 187 | - removeManualBoxes() { | 187 | + |
| 188 | - this.ocrData = this.ocrData.filter(b => !b.isManual); | ||
| 189 | - this.activeIndex = null; | ||
| 190 | - }, | ||
| 191 | // Map field cho box (không set active, chỉ dùng để load data từ DB) | 188 | // Map field cho box (không set active, chỉ dùng để load data từ DB) |
| 192 | mapFieldToBox(index, fieldName, text = null) { | 189 | mapFieldToBox(index, fieldName, text = null) { |
| 193 | if (index == null) return; | 190 | if (index == null) return; |
| ... | @@ -511,15 +508,18 @@ | ... | @@ -511,15 +508,18 @@ |
| 511 | } else { | 508 | } else { |
| 512 | // Kiểm tra xem ocrData đã có box nào với field này chưa | 509 | // Kiểm tra xem ocrData đã có box nào với field này chưa |
| 513 | const existingBox = this.ocrData.find(b => b.field === field && !b.isDeleted); | 510 | const existingBox = this.ocrData.find(b => b.field === field && !b.isDeleted); |
| 514 | - if (existingBox) { | 511 | + // console.log(`Checking existing box for field "${field}":`, existingBox); |
| 515 | - coords = existingBox.bbox; | 512 | + // console.log(`Checking existing manualBoxData for field "${field}":`, this.manualBoxData[field]); |
| 516 | - text = existingBox.text; | 513 | + |
| 517 | - console.log(`Using existing box for field "${field}":`, coords, text); | 514 | + if (this.manualBoxData[field]) { |
| 518 | - } else if (this.manualBoxData[field]) { | ||
| 519 | // Nếu không có trong ocrData, dùng manualBoxData (tọa độ mới) | 515 | // Nếu không có trong ocrData, dùng manualBoxData (tọa độ mới) |
| 520 | coords = this.manualBoxData[field].coords; | 516 | coords = this.manualBoxData[field].coords; |
| 521 | text = this.manualBoxData[field].text; | 517 | text = this.manualBoxData[field].text; |
| 522 | console.log(`Using manualBoxData (new coordinates) for field "${field}":`, coords, text); | 518 | console.log(`Using manualBoxData (new coordinates) for field "${field}":`, coords, text); |
| 519 | + }else if (existingBox) { | ||
| 520 | + coords = existingBox.bbox; | ||
| 521 | + text = existingBox.text; | ||
| 522 | + console.log(`Using existing box for field "${field}":`, coords, text); | ||
| 523 | } | 523 | } |
| 524 | } | 524 | } |
| 525 | 525 | ||
| ... | @@ -754,6 +754,13 @@ | ... | @@ -754,6 +754,13 @@ |
| 754 | const item = this.ocrData[this.selectingIndex]; | 754 | const item = this.ocrData[this.selectingIndex]; |
| 755 | if (!item) return; | 755 | if (!item) return; |
| 756 | 756 | ||
| 757 | + this.ocrData.forEach((box, i) => { | ||
| 758 | + if (i !== this.selectingIndex && box.field === item.field) { | ||
| 759 | + box.field = ''; | ||
| 760 | + } | ||
| 761 | + }); | ||
| 762 | + | ||
| 763 | + console.log(`mapping box ${this.selectingIndex} with field "${item.field}" item.isManual: ${item.isManual}`); | ||
| 757 | if (item.isManual) { | 764 | if (item.isManual) { |
| 758 | // Nếu là manual box, chuyển sang chế độ manual mapping | 765 | // Nếu là manual box, chuyển sang chế độ manual mapping |
| 759 | this.manualIndex = this.selectingIndex; | 766 | this.manualIndex = this.selectingIndex; |
| ... | @@ -766,7 +773,7 @@ | ... | @@ -766,7 +773,7 @@ |
| 766 | if (item.field) { | 773 | if (item.field) { |
| 767 | // Nếu box đã có field, cập nhật lại | 774 | // Nếu box đã có field, cập nhật lại |
| 768 | const oldField = item.field; | 775 | const oldField = item.field; |
| 769 | - | 776 | + console.log(`Updating box OCR at index ${this.selectingIndex} from field "${oldField}" to "${item.field}" "${item.bbox}"`); |
| 770 | // Cập nhật formData để hiển thị trong input | 777 | // Cập nhật formData để hiển thị trong input |
| 771 | this.formData[item.field] = item.text || ''; | 778 | this.formData[item.field] = item.text || ''; |
| 772 | 779 | ||
| ... | @@ -796,6 +803,14 @@ | ... | @@ -796,6 +803,14 @@ |
| 796 | 803 | ||
| 797 | const newBbox = this.ocrData[manualIndex].bbox; | 804 | const newBbox = this.ocrData[manualIndex].bbox; |
| 798 | 805 | ||
| 806 | + | ||
| 807 | + console.log(` manual for field "${this.manualField}" at index ${manualIndex} with bbox:`, newBbox); | ||
| 808 | + this.ocrData.forEach((box, i) => { | ||
| 809 | + if (i !== manualIndex && box.field === this.ocrData[manualIndex].field) { | ||
| 810 | + box.field = ''; | ||
| 811 | + } | ||
| 812 | + }); | ||
| 813 | + | ||
| 799 | let combinedText = []; | 814 | let combinedText = []; |
| 800 | let foundItems = []; | 815 | let foundItems = []; |
| 801 | 816 | ... | ... |
-
Please register or sign in to post a comment