Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
梁建民
/
wmsMin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1ea3c773
authored
Jan 22, 2022
by
liangjianmin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
js
parent
2fc34521
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
215 additions
and
21 deletions
pages/tag/print.vue
pages/tag/repairPrint.vue
pages/tag/print.vue
View file @
1ea3c773
...
...
@@ -38,7 +38,6 @@
import
{
API
}
from
'@/util/api.js'
;
import
{
getPlatform
}
from
'@/util/util.js'
const
ToBase64
=
require
(
'../../util/base64gb2312.js'
);
const
cpclExp
=
require
(
'../../util/cpcl-exp.js'
);
export
default
{
data
()
{
...
...
@@ -57,6 +56,7 @@
sendData64
:
''
,
platform
:
'android'
,
printLabelData
:
[],
print_text
:
'总箱数'
,
form
:
{
erp_order_sn_pre
:
''
,
print_type
:
1
,
...
...
@@ -132,7 +132,6 @@
this
.
request
(
API
.
printLabel
,
'POST'
,
this
.
form
,
false
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
this
.
printLabelData
=
res
.
data
;
this
.
sendDataChangeAll
();
this
.
openBluetoothAdapter
();
}
else
{
uni
.
showToast
({
...
...
@@ -240,8 +239,12 @@
var
h
=
0
;
//记录高度增量
data
.
push
(
"! 10 200 200 "
+
(
this
.
printLabelData
.
length
*
250
)
+
" 1\r\n"
);
for
(
let
i
=
0
;
i
<
this
.
printLabelData
.
length
;
i
++
)
{
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
1
))
-
(
30
*
1
)
+
h
)
+
" 入仓号:"
+
this
.
printLabelData
[
i
].
erp_order_sn
+
"\r\n"
)
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
1
))
-
(
30
*
1
)
+
h
)
+
" 入仓号:"
+
this
.
printLabelData
[
i
].
erp_order_sn
+
"\r\n"
);
if
(
this
.
form
.
print_type
==
1
)
{
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
2
))
-
(
30
*
1
)
+
h
)
+
" 总箱数:"
+
this
.
printLabelData
[
0
].
label_num
+
"箱\r\n"
);
}
else
{
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
2
))
-
(
30
*
1
)
+
h
)
+
" 箱号:"
+
this
.
printLabelData
[
i
].
label_sort
+
'/'
+
this
.
printLabelData
[
0
].
label_num
+
"\r\n"
);
}
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
3
))
-
(
30
*
1
)
+
h
)
+
" 时间:"
+
this
.
printLabelData
[
i
].
create_time_cn
+
"\r\n"
);
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
4
))
-
(
30
*
1
)
+
h
)
+
" 仓库代码:"
+
i
+
"\r\n"
);
data
.
push
(
"B QR 290 "
+
((
50
*
(
i
+
1
))
-
(
30
*
1
)
+
h
)
+
" M 2 U 8\r\n"
);
...
...
@@ -341,9 +344,11 @@
if
(
index
==
0
)
{
this
.
form
.
print_type
=
1
;
this
.
text
=
'总箱数'
;
this
.
print_text
=
'总箱数'
;
}
else
if
(
index
==
1
)
{
this
.
text
=
'标签数量'
;
this
.
form
.
print_type
=
2
;
this
.
text
=
'标签数量'
;
this
.
print_text
=
'箱号'
;
}
}
}
...
...
pages/tag/repairPrint.vue
View file @
1ea3c773
...
...
@@ -21,14 +21,25 @@
</
template
>
<
script
>
import
{
API
}
from
'@/util/api.js'
;
import
{
API
}
from
'@/util/api.js'
;
import
{
getPlatform
}
from
'@/util/util.js'
const
ToBase64
=
require
(
'../../util/base64gb2312.js'
);
export
default
{
export
default
{
data
()
{
return
{
print_number
:
0
,
serviceId
:
''
,
deviceId
:
''
,
characteristics
:
''
,
text
:
'标签数量'
,
index_erp_order_sn_pre
:
-
1
,
items_erp_order_sn_pre
:
[
'A单号'
,
'B单号'
,
'D单号'
],
sendData64
:
''
,
platform
:
'android'
,
printLabelData
:
[],
print_text
:
'总箱数'
,
print_type
:
1
,
form
:
{
erp_order_sn_pre
:
''
,
erp_order_sn_number
:
''
,
...
...
@@ -38,17 +49,19 @@ export default {
},
methods
:
{
onKeyInput
:
function
(
event
)
{
if
(
event
.
target
.
value
.
length
>
3
)
{
if
(
event
.
target
.
value
.
length
>
3
)
{
this
.
getErpOrderSnPrintLabelType
();
}
},
getErpOrderSnPrintLabelType
()
{
this
.
request
(
API
.
getErpOrderSnPrintLabelType
,
'POST'
,
{
erp_order_sn
:
this
.
form
.
erp_order_sn_pre
+
this
.
form
.
erp_order_sn_number
},
false
).
then
(
res
=>
{
getErpOrderSnPrintLabelType
()
{
this
.
request
(
API
.
getErpOrderSnPrintLabelType
,
'POST'
,
{
erp_order_sn
:
this
.
form
.
erp_order_sn_pre
+
this
.
form
.
erp_order_sn_number
},
false
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
if
(
res
.
data
==
1
){
this
.
text
=
'标签数量'
;
}
else
{
this
.
text
=
'子箱号'
;
if
(
res
.
data
==
1
)
{
this
.
text
=
'标签数量'
;
this
.
print_type
=
2
;
}
else
{
this
.
text
=
'子箱号'
;
this
.
print_type
=
1
;
}
}
});
...
...
@@ -93,8 +106,170 @@ export default {
return
false
;
}
this
.
request
(
API
.
getPrintLabel
,
'POST'
,
{
erp_order_sn
:
this
.
form
.
erp_order_sn_pre
+
this
.
form
.
erp_order_sn_number
,
label_sort
:
this
.
form
.
label_sort
},
true
).
then
(
res
=>
{
this
.
request
(
API
.
getPrintLabel
,
'POST'
,
{
erp_order_sn
:
this
.
form
.
erp_order_sn_pre
+
this
.
form
.
erp_order_sn_number
,
label_sort
:
this
.
form
.
label_sort
},
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
this
.
printLabelData
=
res
.
data
;
this
.
sendDataChangeAll
();
this
.
openBluetoothAdapter
();
}
else
{
uni
.
showToast
({
title
:
res
.
err_msg
,
icon
:
'error'
});
}
});
},
openBluetoothAdapter
()
{
//先查看系统蓝牙状态
let
that
=
this
;
uni
.
openBluetoothAdapter
({
success
(
res
)
{
that
.
startBluetoothDevicesDiscovery
();
},
fail
()
{
uni
.
showToast
({
title
:
'请打开蓝牙'
,
icon
:
'error'
});
}
});
},
startBluetoothDevicesDiscovery
()
{
//搜索附近的蓝牙设备并且监听寻找到新设备的事件
let
that
=
this
;
uni
.
showLoading
({
title
:
'连接设备中'
,
mask
:
true
});
uni
.
startBluetoothDevicesDiscovery
({
success
:
function
(
res
)
{
console
.
log
(
'搜索设备start'
,
res
);
uni
.
onBluetoothDeviceFound
(
function
(
el
)
{
//找到对应蓝牙设备名字
if
(
el
.
devices
[
0
].
name
==
'HM-A300-87d9'
)
{
that
.
deviceId
=
el
.
devices
[
0
].
deviceId
;
//成功后存储设备id
that
.
stopBluetoothDevicesDiscovery
();
//关闭搜索
console
.
log
(
"成功搜索设备"
,
el
);
console
.
log
(
el
.
devices
[
0
].
deviceId
);
}
});
},
fail
:
function
()
{
uni
.
hideLoading
();
uni
.
showToast
({
title
:
'请断开蓝牙,重新连接'
,
icon
:
'error'
});
}
});
},
stopBluetoothDevicesDiscovery
()
{
//成功找到对应蓝牙设备后 停止搜寻附近的蓝牙外围设备
let
that
=
this
;
uni
.
stopBluetoothDevicesDiscovery
({
success
(
res
)
{
console
.
log
(
'停止搜索'
,
res
);
that
.
getBLEDeviceServices
();
}
});
},
getBLEDeviceServices
()
{
//来获取蓝牙设备所有服务
let
that
=
this
;
uni
.
createBLEConnection
({
deviceId
:
this
.
deviceId
,
success
:
res
=>
{
console
.
log
(
'连接成功'
,
JSON
.
stringify
(
res
));
//需延时连接,不然会报错
setTimeout
(
function
()
{
uni
.
getBLEDeviceServices
({
deviceId
:
that
.
deviceId
,
success
:
res
=>
{
console
.
log
(
'获取蓝牙设备所有服务'
,
res
);
that
.
serviceId
=
res
.
services
[
0
].
uuid
;
that
.
getBLEDeviceCharacteristics
();
}
});
},
0
);
}
});
},
getBLEDeviceCharacteristics
()
{
//获取蓝牙设备某个服务中所有特征值
let
that
=
this
;
uni
.
getBLEDeviceCharacteristics
({
deviceId
:
that
.
deviceId
,
serviceId
:
that
.
serviceId
,
success
:
res
=>
{
that
.
characteristics
=
res
.
characteristics
[
0
].
uuid
;
that
.
sendDataChangeAll
();
console
.
log
(
'服务功能特征值'
,
res
);
},
fail
:
res
=>
{
console
.
log
(
'失败'
,
res
);
}
});
},
sendDataChangeAll
()
{
console
.
log
(
'第'
+
this
.
print_number
+
'次打印'
);
//发送数据 二进制
let
data
=
[];
var
h
=
0
;
//记录高度增量
data
.
push
(
"! 10 200 200 "
+
(
this
.
printLabelData
.
length
*
250
)
+
" 1\r\n"
);
for
(
let
i
=
0
;
i
<
this
.
printLabelData
.
length
;
i
++
)
{
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
1
))
-
(
30
*
1
)
+
h
)
+
" 入仓号:"
+
this
.
printLabelData
[
i
].
erp_order_sn
+
"\r\n"
);
if
(
this
.
print_type
==
1
)
{
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
2
))
-
(
30
*
1
)
+
h
)
+
" 总箱数:"
+
this
.
printLabelData
[
0
].
label_num
+
"箱\r\n"
);
}
else
{
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
2
))
-
(
30
*
1
)
+
h
)
+
" 箱号:"
+
this
.
printLabelData
[
i
].
label_sort
+
'/'
+
this
.
printLabelData
[
0
].
label_num
+
"\r\n"
);
}
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
3
))
-
(
30
*
1
)
+
h
)
+
" 时间:"
+
this
.
printLabelData
[
i
].
create_time_cn
+
"\r\n"
);
data
.
push
(
"T 8 0 10 "
+
((
50
*
(
i
+
4
))
-
(
30
*
1
)
+
h
)
+
" 仓库代码:"
+
i
+
"\r\n"
);
data
.
push
(
"B QR 290 "
+
((
50
*
(
i
+
1
))
-
(
30
*
1
)
+
h
)
+
" M 2 U 8\r\n"
);
data
.
push
(
"MA,"
+
this
.
printLabelData
[
i
].
erp_order_sn
+
"\r\n"
);
data
.
push
(
"ENDQR\r\n"
);
h
+=
210
;
}
data
.
push
(
"PRINT\r\n"
);
let
arrayBuffer
=
uni
.
base64ToArrayBuffer
(
ToBase64
.
encode64gb2312
(
data
.
join
(
''
)));
this
.
sendData64
=
arrayBuffer
;
this
.
writeBLECharacteristicValue
();
console
.
log
(
data
.
join
(
''
))
},
sendDataChange
()
{
console
.
log
(
'第'
+
this
.
print_number
+
'次打印'
);
//发送数据 二进制
let
data
=
""
;
if
(
this
.
printLabelData
.
length
>
0
)
{
data
=
"! 10 200 200 250 1\r\n"
+
"T 8 0 10 10 入仓号:"
+
this
.
printLabelData
[
this
.
print_number
].
erp_order_sn
+
"\r\n"
+
"T 8 0 10 50 箱号:"
+
this
.
printLabelData
[
this
.
print_number
].
label_sort
+
'/'
+
this
.
printLabelData
[
0
].
label_num
+
"\r\n"
+
"T 8 0 10 90 时间:"
+
this
.
printLabelData
[
this
.
print_number
].
create_time_cn
+
"\r\n"
+
"T 8 0 10 130 仓库代码:"
+
this
.
print_number
+
"\r\n"
+
"B QR 290 0 M 2 U 8\r\n"
+
"MA,"
+
this
.
printLabelData
[
this
.
print_number
].
erp_order_sn
+
"\r\n"
+
"ENDQR\r\n"
+
"PRINT\r\n"
;
}
console
.
log
(
data
)
let
arrayBuffer
=
uni
.
base64ToArrayBuffer
(
ToBase64
.
encode64gb2312
(
data
));
this
.
sendData64
=
arrayBuffer
;
this
.
writeBLECharacteristicValue
();
},
writeBLECharacteristicValue
()
{
//写入二进制数据
let
that
=
this
;
uni
.
writeBLECharacteristicValue
({
deviceId
:
that
.
deviceId
,
serviceId
:
that
.
serviceId
,
characteristicId
:
that
.
characteristics
,
value
:
that
.
sendData64
,
success
(
res
)
{
console
.
log
(
'writeBLECharacteristicValue success'
,
res
.
errMsg
)
uni
.
hideLoading
();
uni
.
closeBLEConnection
({
deviceId
:
that
.
deviceId
,
success
(
res
)
{
uni
.
showModal
({
title
:
'提示'
,
content
:
'提交成功,打印中,请查看标签打印机'
,
...
...
@@ -103,18 +278,32 @@ export default {
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
);
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
else
{
uni
.
showToast
({
title
:
res
.
err_msg
,
icon
:
'error'
});
}
})
},
fail
()
{
uni
.
hideLoading
();
uni
.
showModal
({
title
:
'提示'
,
content
:
'无法打印,请查看标签打印机连接状态'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
})
},
change
(
index
,
type
)
{
if
(
type
==
'erp_order_sn_pre'
)
{
...
...
@@ -130,9 +319,9 @@ export default {
}
}
}
};
};
</
script
>
<
style
scoped
lang=
"scss"
>
@import
'../../assets/css/tag/print.scss'
;
@import
'../../assets/css/tag/print.scss'
;
</
style
>
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