Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Satini_pvduc
/
ocrpdf
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
tien_nemo
2025-08-14 11:07:12 +0700
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
fbe7f92844a6569b16a0bf2536b5e0a9bcecf73f
fbe7f928
1 parent
08b68353
fix focus use box ori
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
resources/views/ocr/index.blade.php
resources/views/ocr/index.blade.php
View file @
fbe7f92
...
...
@@ -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
=
[];
...
...
Please
register
or
sign in
to post a comment