tien_nemo

fix focus use box ori

......@@ -184,10 +184,7 @@
}
},
methods: {
removeManualBoxes() {
this.ocrData = this.ocrData.filter(b => !b.isManual);
this.activeIndex = null;
},
// Map field cho box (không set active, chỉ dùng để load data từ DB)
mapFieldToBox(index, fieldName, text = null) {
if (index == null) return;
......@@ -511,15 +508,18 @@
} else {
// Kiểm tra xem ocrData đã có box nào với field này chưa
const existingBox = this.ocrData.find(b => b.field === field && !b.isDeleted);
if (existingBox) {
coords = existingBox.bbox;
text = existingBox.text;
console.log(`Using existing box for field "${field}":`, coords, text);
} else if (this.manualBoxData[field]) {
// console.log(`Checking existing box for field "${field}":`, existingBox);
// console.log(`Checking existing manualBoxData for field "${field}":`, this.manualBoxData[field]);
if (this.manualBoxData[field]) {
// Nếu không có trong ocrData, dùng manualBoxData (tọa độ mới)
coords = this.manualBoxData[field].coords;
text = this.manualBoxData[field].text;
console.log(`Using manualBoxData (new coordinates) for field "${field}":`, coords, text);
}else if (existingBox) {
coords = existingBox.bbox;
text = existingBox.text;
console.log(`Using existing box for field "${field}":`, coords, text);
}
}
......@@ -754,6 +754,13 @@
const item = this.ocrData[this.selectingIndex];
if (!item) return;
this.ocrData.forEach((box, i) => {
if (i !== this.selectingIndex && box.field === item.field) {
box.field = '';
}
});
console.log(`mapping box ${this.selectingIndex} with field "${item.field}" item.isManual: ${item.isManual}`);
if (item.isManual) {
// Nếu là manual box, chuyển sang chế độ manual mapping
this.manualIndex = this.selectingIndex;
......@@ -766,7 +773,7 @@
if (item.field) {
// Nếu box đã có field, cập nhật lại
const oldField = item.field;
console.log(`Updating box OCR at index ${this.selectingIndex} from field "${oldField}" to "${item.field}" "${item.bbox}"`);
// Cập nhật formData để hiển thị trong input
this.formData[item.field] = item.text || '';
......@@ -796,6 +803,14 @@
const newBbox = this.ocrData[manualIndex].bbox;
console.log(` manual for field "${this.manualField}" at index ${manualIndex} with bbox:`, newBbox);
this.ocrData.forEach((box, i) => {
if (i !== manualIndex && box.field === this.ocrData[manualIndex].field) {
box.field = '';
}
});
let combinedText = [];
let foundItems = [];
......