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-12 11:32:04 +0700
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
37bc9da9d249b91ad9fcff704509307cfaf98cd4
37bc9da9
1 parent
a8852132
demo
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
select.html
select.html
View file @
37bc9da
...
...
@@ -134,7 +134,7 @@
selectingIndex
:
null
,
isMappingManually
:
false
,
isSelecting
:
false
,
activeField
:
null
,
activeIndex
:
null
,
manualField
:
""
,
formData
:
{
export_date
:
""
,
order_code
:
""
,
customer
:
""
,
address
:
""
,
staff
:
""
},
fieldOptions
:
[
...
...
@@ -193,7 +193,7 @@
this
.
imageWidth
=
img
.
naturalWidth
;
this
.
imageHeight
=
img
.
naturalHeight
;
},
getBoxStyle
(
item
)
{
getBoxStyle
(
item
,
index
)
{
if
(
!
this
.
imageWidth
||
!
this
.
imageHeight
||
!
this
.
$refs
.
pdfImage
)
return
{};
const
[
x1
,
y1
,
x2
,
y2
]
=
item
.
bbox
;
...
...
@@ -209,8 +209,8 @@
top
:
`
${
Math
.
round
(
y1
*
scaleY
)}
px`
,
width
:
`
${
Math
.
round
((
x2
-
x1
)
*
scaleX
)}
px`
,
height
:
`
${
Math
.
round
((
y2
-
y1
)
*
scaleY
)}
px`
,
border
:
item
.
hideBorder
?
'none'
:
'2px solid '
+
(
this
.
activeField
===
item
.
field
?
'#199601'
:
'#ff5252'
),
//backgroundColor: item.hideBorder ? 'transparent' : (this.activeField
=== item.field ? 'rgba(33,150,243,0.3)' : 'rgba(255,82,82,0.2)'),
border
:
item
.
hideBorder
?
'none'
:
'2px solid '
+
(
index
===
this
.
activeIndex
?
'#199601'
:
'#ff5252'
),
//backgroundColor: item.hideBorder ? 'transparent' : (this.activeIndex
=== item.field ? 'rgba(33,150,243,0.3)' : 'rgba(255,82,82,0.2)'),
boxSizing
:
'border-box'
,
cursor
:
'pointer'
,
zIndex
:
item
.
isManual
?
30
:
10
...
...
@@ -218,7 +218,16 @@
},
highlightField
(
field
)
{
this
.
activeField
=
field
;
// tìm box gần nhất match field này
let
idx
=
-
1
;
for
(
let
i
=
this
.
ocrData
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
it
=
this
.
ocrData
[
i
];
if
(
!
it
.
isDeleted
&&
it
.
field
===
field
)
{
idx
=
i
;
break
;
}
}
this
.
activeIndex
=
idx
;
// nếu không tìm thấy thì = -1
},
startSelect
(
e
)
{
...
...
@@ -307,14 +316,14 @@
if
(
item
&&
item
.
isManual
)
{
this
.
manualIndex
=
this
.
selectingIndex
;
this
.
manualField
=
item
.
field
;
// đảm bảo sync field hiện tại
this
.
manualField
=
item
.
field
||
""
;
this
.
applyManualMapping
();
return
;
}
if
(
item
.
field
)
{
this
.
formData
[
item
.
field
]
=
item
.
text
;
this
.
activeField
=
item
.
field
;
this
.
activeIndex
=
this
.
selectingIndex
;
}
this
.
selectingIndex
=
null
;
},
...
...
@@ -335,9 +344,9 @@
const
finalText
=
combinedText
.
join
(
" "
);
this
.
ocrData
[
manualIndex
].
field
=
this
.
manualField
;
this
.
formData
[
this
.
manualField
]
=
finalText
;
this
.
activeField
=
this
.
manualField
;
this
.
activeIndex
=
manualIndex
;
console
.
log
(
'manualField'
,
this
.
manualField
,
this
.
manualIndex
)
console
.
log
(
'manualField'
,
this
.
manualField
,
this
.
manualIndex
)
// Reset trạng thái chọn
this
.
isMappingManually
=
false
;
this
.
selectBox
.
show
=
false
;
...
...
@@ -372,7 +381,7 @@
return
text
.
substring
(
startIndex
,
endIndex
).
trim
();
},
getSelectStyle
(
item
)
{
if
(
!
this
.
imageWidth
)
return
{
position
:
'absolute'
};
if
(
!
this
.
imageWidth
)
return
{
position
:
'absolute'
};
const
[
x1
,
y1
,
x2
,
y2
]
=
item
.
bbox
;
const
displayedWidth
=
this
.
$refs
.
pdfImage
.
clientWidth
;
...
...
@@ -394,4 +403,5 @@
</script>
</body></html>
</body>
</html>
...
...
Please
register
or
sign in
to post a comment