Showing
1 changed file
with
2 additions
and
73 deletions
| ... | @@ -104,7 +104,7 @@ | ... | @@ -104,7 +104,7 @@ |
| 104 | 104 | ||
| 105 | 105 | ||
| 106 | <!-- Dropdown OCR --> | 106 | <!-- Dropdown OCR --> |
| 107 | - <select v-if="selectingIndex !== null" | 107 | + <select v-if="selectingIndex !== null && ocrData[selectingIndex].isManual" |
| 108 | :style="getSelectStyle(ocrData[selectingIndex])" | 108 | :style="getSelectStyle(ocrData[selectingIndex])" |
| 109 | v-model="ocrData[selectingIndex].field" | 109 | v-model="ocrData[selectingIndex].field" |
| 110 | @change="applyMapping" | 110 | @change="applyMapping" |
| ... | @@ -440,54 +440,6 @@ | ... | @@ -440,54 +440,6 @@ |
| 440 | 440 | ||
| 441 | }, | 441 | }, |
| 442 | 442 | ||
| 443 | - | ||
| 444 | - // Tìm box OCR phù hợp nhất để map với field | ||
| 445 | - findBestMatchingBox(fieldName, fieldValue) { | ||
| 446 | - let bestMatchIndex = -1; | ||
| 447 | - let bestScore = 0; | ||
| 448 | - | ||
| 449 | - this.ocrData.forEach((item, index) => { | ||
| 450 | - if (item.isDeleted) return; | ||
| 451 | - | ||
| 452 | - // Nếu box này đã được map field khác, bỏ qua | ||
| 453 | - if (item.field && item.field !== fieldName) return; | ||
| 454 | - | ||
| 455 | - // Tính điểm phù hợp dựa trên text | ||
| 456 | - const text = item.text || ''; | ||
| 457 | - const score = this.calculateTextSimilarity(text, fieldValue); | ||
| 458 | - | ||
| 459 | - if (score > bestScore) { | ||
| 460 | - bestScore = score; | ||
| 461 | - bestMatchIndex = index; | ||
| 462 | - } | ||
| 463 | - }); | ||
| 464 | - | ||
| 465 | - // Chỉ map nếu điểm phù hợp đủ cao (ví dụ > 0.5) | ||
| 466 | - return bestScore > 0.5 ? bestMatchIndex : -1; | ||
| 467 | - }, | ||
| 468 | - | ||
| 469 | - // Tính điểm tương đồng giữa 2 text | ||
| 470 | - calculateTextSimilarity(text1, text2) { | ||
| 471 | - if (!text1 || !text2) return 0; | ||
| 472 | - | ||
| 473 | - const t1 = text1.toLowerCase().trim(); | ||
| 474 | - const t2 = text2.toLowerCase().trim(); | ||
| 475 | - // Nếu text giống hệt nhau | ||
| 476 | - if (t1 === t2) return 1.0; | ||
| 477 | - | ||
| 478 | - // Nếu một text là subset của text kia | ||
| 479 | - if (t1.includes(t2) || t2.includes(t1)) return 0.8; | ||
| 480 | - | ||
| 481 | - // Tính điểm dựa trên số ký tự giống nhau | ||
| 482 | - let commonChars = 0; | ||
| 483 | - const minLength = Math.min(t1.length, t2.length); | ||
| 484 | - | ||
| 485 | - for (let i = 0; i < minLength; i++) { | ||
| 486 | - if (t1[i] === t2[i]) commonChars++; | ||
| 487 | - } | ||
| 488 | - | ||
| 489 | - return commonChars / Math.max(t1.length, t2.length); | ||
| 490 | - }, | ||
| 491 | onImageLoad() { | 443 | onImageLoad() { |
| 492 | const img = this.$refs.pdfImage; | 444 | const img = this.$refs.pdfImage; |
| 493 | this.imageWidth = img.naturalWidth; | 445 | this.imageWidth = img.naturalWidth; |
| ... | @@ -529,32 +481,9 @@ | ... | @@ -529,32 +481,9 @@ |
| 529 | zIndex: item.isManual ? 30 : 10 | 481 | zIndex: item.isManual ? 30 : 10 |
| 530 | }; | 482 | }; |
| 531 | }, | 483 | }, |
| 532 | - | ||
| 533 | - // highlightField(field) { | ||
| 534 | - // let idx = -1; | ||
| 535 | - // for (let i = this.ocrData.length - 1; i >= 0; i--) { | ||
| 536 | - // const it = this.ocrData[i]; | ||
| 537 | - // if (!it.isDeleted && it.field === field) { | ||
| 538 | - // idx = i; | ||
| 539 | - // break; | ||
| 540 | - // } | ||
| 541 | - // } | ||
| 542 | - // | ||
| 543 | - // if (idx !== -1) { | ||
| 544 | - // // Set active index (chuyển trạng thái active và màu xanh) | ||
| 545 | - // this.activeIndex = idx; | ||
| 546 | - // // Scroll đến box tương ứng | ||
| 547 | - // this.scrollToBox(idx); | ||
| 548 | - // // Focus vào box để người dùng thấy rõ | ||
| 549 | - // this.focusOnBox(idx); | ||
| 550 | - // } else { | ||
| 551 | - // this.activeIndex = null; | ||
| 552 | - // } | ||
| 553 | - // }, | ||
| 554 | - | ||
| 555 | highlightField(field) { | 484 | highlightField(field) { |
| 556 | // Xóa tất cả manual box cũ trước khi tạo mới | 485 | // Xóa tất cả manual box cũ trước khi tạo mới |
| 557 | - // this.ocrData = this.ocrData.filter(b => !b.isManual); | 486 | + //this.ocrData = this.ocrData.filter(b => !b.isManual); |
| 558 | 487 | ||
| 559 | let coords, text; | 488 | let coords, text; |
| 560 | 489 | ... | ... |
-
Please register or sign in to post a comment