Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
factory_front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinjianhui
factory_front
Commits
955dc3f6
Commit
955dc3f6
authored
Sep 11, 2025
by
zhuzhequan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生产单查询添加手动打印按钮
parent
87191ff5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
143 deletions
+23
-143
src/components/searchProdOrder.vue
+23
-143
No files found.
src/components/searchProdOrder.vue
View file @
955dc3f6
...
@@ -4,9 +4,10 @@ import { SearchOrderRes } from '@/types/api/podOrder.ts'
...
@@ -4,9 +4,10 @@ import { SearchOrderRes } from '@/types/api/podOrder.ts'
import
{
nextTick
,
ref
}
from
'vue'
import
{
nextTick
,
ref
}
from
'vue'
import
{
DocumentCopy
}
from
'@element-plus/icons-vue'
import
{
DocumentCopy
}
from
'@element-plus/icons-vue'
import
{
copyText
}
from
'@/utils'
import
{
copyText
}
from
'@/utils'
import
useLodop
,
{
LODOPObject
}
from
'@/utils/hooks/useLodop.ts'
import
useLodop
from
'@/utils/hooks/useLodop.ts'
import
{
ElMessage
}
from
'element-plus'
import
{
ElMessage
}
from
'element-plus'
import
{
filePath
}
from
'@/api/axios.ts'
import
{
filePath
}
from
'@/api/axios.ts'
import
{
print
}
from
'@/components/print.ts'
const
{
getCLodop
}
=
useLodop
()
const
{
getCLodop
}
=
useLodop
()
const
type
=
{
const
type
=
{
...
@@ -27,6 +28,7 @@ const detail = ref<SearchOrderRes>({
...
@@ -27,6 +28,7 @@ const detail = ref<SearchOrderRes>({
id
:
0
,
id
:
0
,
})
})
const
printDevice
=
ref
(
''
)
const
printDevice
=
ref
(
''
)
const
searchData
=
ref
()
const
isPrint
=
ref
(
false
)
const
isPrint
=
ref
(
false
)
const
printList
=
ref
<
string
[]
>
([])
const
printList
=
ref
<
string
[]
>
([])
type
AudioKey
=
keyof
typeof
audios
// 创建一个类型,确保 key 只能是 audios 对象的键之一
type
AudioKey
=
keyof
typeof
audios
// 创建一个类型,确保 key 只能是 audios 对象的键之一
...
@@ -76,14 +78,23 @@ const playAudio = (key: AudioKey, message?: string) => {
...
@@ -76,14 +78,23 @@ const playAudio = (key: AudioKey, message?: string) => {
console
.
error
(
`No audio found for key:
${
key
}
`
)
console
.
error
(
`No audio found for key:
${
key
}
`
)
}
}
}
}
const
getPrintData
=
async
()
=>
{
if
(
!
searchData
.
value
)
return
const
user
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
||
'{}'
)
const
data
=
await
printProductionQrCode
(
searchData
.
value
.
id
,
user
.
factory
?.
countryCode
.
toLowerCase
(),
)
// const path = 'http://10.168.1.209/local_files/factory' + data.message
const
path
=
filePath
+
data
.
message
print
(
path
,
printDevice
.
value
)
}
const
trackcodeInput
=
async
()
=>
{
const
trackcodeInput
=
async
()
=>
{
if
(
!
TrackingNumber
.
value
)
{
if
(
!
TrackingNumber
.
value
)
{
// ElMessage.warning('请扫描生产单号')
// ElMessage.warning('请扫描生产单号')
playAudio
(
'weight_search_error'
)
playAudio
(
'weight_search_error'
)
return
return
}
}
const
user
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
||
'{}'
)
// let orderNumber: string
// let orderNumber: string
// const underscoreCount = (TrackingNumber.value.match(/_/g) || []).length
// const underscoreCount = (TrackingNumber.value.match(/_/g) || []).length
...
@@ -101,15 +112,11 @@ const trackcodeInput = async () => {
...
@@ -101,15 +112,11 @@ const trackcodeInput = async () => {
if
(
!
res
.
data
)
{
if
(
!
res
.
data
)
{
return
ElMessage
.
error
(
'生产单不存在'
)
return
ElMessage
.
error
(
'生产单不存在'
)
}
}
searchData
.
value
=
res
.
data
if
(
printDevice
.
value
&&
isPrint
.
value
)
{
if
(
printDevice
.
value
&&
isPrint
.
value
)
{
const
data
=
await
printProductionQrCode
(
getPrintData
()
res
.
data
.
id
,
user
.
factory
?.
countryCode
.
toLowerCase
(),
)
// const path = 'http://10.168.1.209/local_files/factory' + data.message
const
path
=
filePath
+
data
.
message
print
(
path
)
}
}
res
.
data
.
inputNum
=
TrackingNumber
.
value
res
.
data
.
inputNum
=
TrackingNumber
.
value
TrackingNumber
.
value
=
''
TrackingNumber
.
value
=
''
if
(
typeof
res
.
data
.
imageAry
===
'string'
)
{
if
(
typeof
res
.
data
.
imageAry
===
'string'
)
{
...
@@ -166,140 +173,12 @@ const initPrintDevice = () => {
...
@@ -166,140 +173,12 @@ const initPrintDevice = () => {
// }
// }
printList
.
value
=
arr
printList
.
value
=
arr
}
}
const
printPdf
=
()
=>
{
const
lodopCall
=
async
(
fn
:
(
lodop
:
LODOPObject
)
=>
string
)
=>
{
if
(
!
printDevice
.
value
)
return
ElMessage
.
warning
(
'请选择打印机'
)
if
(
!
window
.
_lodop
)
{
if
(
!
searchData
.
value
)
return
ElMessage
.
warning
(
'请先查询生产单'
)
window
.
_lodop
=
getCLodop
(
null
,
null
)
getPrintData
()
if
(
window
.
_lodop
)
{
window
.
_lodop
.
On_Return_Remain
=
true
window
.
_lodop
.
SET_PRINT_MODE
(
'CATCH_PRINT_STATUS'
,
true
)
window
.
_lodopCallback
=
{}
window
.
_lodop
.
On_Return
=
function
(
id
,
value
)
{
const
cb
=
window
.
_lodopCallback
[
id
]
if
(
!
cb
)
return
delete
window
.
_lodopCallback
[
id
]
cb
(
value
)
}
}
}
return
new
Promise
((
resolve
)
=>
{
let
id
if
(
window
.
_lodop
)
{
id
=
fn
(
window
.
_lodop
)
}
window
.
_lodopCallback
[
id
||
0
]
=
resolve
})
}
function
downloadPDF
(
url
:
string
)
{
if
(
!
/^https
?
:/i
.
test
(
url
))
return
url
let
xhr
,
arrybuffer
=
false
,
dataArray
=
null
if
(
window
.
XMLHttpRequest
)
{
xhr
=
new
XMLHttpRequest
()
}
else
{
xhr
=
new
window
.
ActiveXObject
(
'MSXML2.XMLHTTP'
)
}
xhr
.
open
(
'GET'
,
url
,
false
)
//同步方式
if
(
xhr
.
overrideMimeType
)
try
{
xhr
.
responseType
=
'arraybuffer'
arrybuffer
=
true
}
catch
(
err
)
{
xhr
.
overrideMimeType
(
'text/plain; charset=x-user-defined'
)
}
xhr
.
send
(
null
)
const
data
=
xhr
.
response
||
xhr
.
responseBody
if
(
typeof
Uint8Array
!==
'undefined'
)
{
if
(
arrybuffer
)
{
dataArray
=
new
Uint8Array
(
data
)
}
else
{
dataArray
=
new
Uint8Array
(
data
.
length
)
for
(
let
i
=
0
;
i
<
dataArray
.
length
;
i
++
)
{
dataArray
[
i
]
=
data
.
charCodeAt
(
i
)
}
}
}
else
{
dataArray
=
window
.
VBS_BinaryToArray
(
data
).
toArray
()
//兼容IE低版本
}
const
digits
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
let
strData
=
''
for
(
let
i
=
0
,
ii
=
dataArray
.
length
;
i
<
ii
;
i
+=
3
)
{
if
(
isNaN
(
dataArray
[
i
]))
break
const
b1
=
dataArray
[
i
]
&
0xff
,
b2
=
dataArray
[
i
+
1
]
&
0xff
,
b3
=
dataArray
[
i
+
2
]
&
0xff
const
d1
=
b1
>>
2
,
d2
=
((
b1
&
3
)
<<
4
)
|
(
b2
>>
4
)
const
d3
=
i
+
1
<
ii
?
((
b2
&
0xf
)
<<
2
)
|
(
b3
>>
6
)
:
64
const
d4
=
i
+
2
<
ii
?
b3
&
0x3f
:
64
strData
+=
digits
.
substring
(
d1
,
d1
+
1
)
+
digits
.
substring
(
d2
,
d2
+
1
)
+
digits
.
substring
(
d3
,
d3
+
1
)
+
digits
.
substring
(
d4
,
d4
+
1
)
}
return
strData
}
}
const
print
=
async
(
url
:
string
)
=>
{
const
lodop
=
getCLodop
(
null
,
null
)
//调用getLodop获取LODOP对象
if
(
!
lodop
)
return
lodop
.
PRINT_INIT
(
'打印内容'
)
// SET_PRINTER_INDEX 指定打印设备
const
setPrintRes
=
lodop
.
SET_PRINTER_INDEX
(
printDevice
.
value
)
if
(
!
setPrintRes
)
{
ElMessage
.
warning
(
'设置面单打印机出错'
)
return
}
lodop
.
ADD_PRINT_PDF
(
0
,
0
,
'100%'
,
'100%'
,
downloadPDF
(
url
))
console
.
log
(
lodop
)
if
(
lodop
.
CVERSION
)
{
const
startTime
=
Date
.
now
()
const
jobCode
=
await
lodopCall
((
lodop
:
LODOPObject
)
=>
{
lodop
.
SET_PRINT_MODE
(
'CATCH_PRINT_STATUS'
,
true
)
return
lodop
.
PRINT
()
})
console
.
log
(
'[LODOP] job '
+
jobCode
)
// eslint-disable-next-line no-constant-condition
while
(
true
)
{
const
ok
=
await
lodopCall
((
lodop
:
LODOPObject
)
=>
lodop
.
GET_VALUE
(
'PRINT_STATUS_OK'
,
jobCode
),
)
if
(
ok
==
1
)
{
// 打印状态:成功
return
}
// 如果打印状态表示未成功或者返回了空,继续获取任务是否存在
const
exist
=
await
lodopCall
((
lodop
:
LODOPObject
)
=>
lodop
.
GET_VALUE
(
'PRINT_STATUS_EXIST'
,
jobCode
),
)
console
.
log
(
'[LODOP] PRINT_STATUS OK,EXIST'
,
jobCode
,
ok
,
exist
,
`(
${
Date
.
now
()
-
startTime
}
ms)`
,
)
if
(
exist
==
0
)
{
// 任务不存在了
return
}
await
new
Promise
((
r
)
=>
setTimeout
(
r
,
500
))
if
(
Date
.
now
()
-
startTime
>=
30000
)
{
ElMessage
.
error
(
'打印超时(30秒)'
)
return
}
}
}
else
{
lodop
.
PRINT
()
}
}
// 处理打印机选择变化,保存到 localStorage
// 处理打印机选择变化,保存到 localStorage
const
handlePrinterChange
=
(
value
:
string
)
=>
{
const
handlePrinterChange
=
(
value
:
string
)
=>
{
printDevice
.
value
=
value
printDevice
.
value
=
value
...
@@ -355,11 +234,12 @@ onMounted(() => {
...
@@ -355,11 +234,12 @@ onMounted(() => {
:value=
"item"
:value=
"item"
></el-option>
></el-option>
</el-select>
</el-select>
<el-button
style=
"margin-left: 5px"
type=
"primary"
@
click=
"printPdf"
>
打印生产码
</el-button>
<el-checkbox
<el-checkbox
v-model=
"isPrint"
v-model=
"isPrint"
:disabled=
"!printDevice"
:disabled=
"!printDevice"
style=
"margin-left: 10px"
style=
"margin-left: 10px"
>
打印生产码
</el-checkbox
>
自动打印
</el-checkbox
>
>
</div>
</div>
<div
class=
"div-text"
>
<div
class=
"div-text"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment