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
d6b15a65
authored
Feb 15, 2022
by
liangjianmin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
js
parent
9a824235
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
74 deletions
pages/tag/print.vue
pages/tag/repairPrint.vue
pages/tag/print.vue
View file @
d6b15a65
...
...
@@ -36,7 +36,6 @@
<
script
>
import
{
API
}
from
'@/util/api.js'
;
import
{
getPlatform
}
from
'@/util/util.js'
const
ToBase64
=
require
(
'../../util/base64gb2312.js'
);
export
default
{
...
...
@@ -54,7 +53,6 @@
items_print_type
:
[
'卡板'
,
'散箱'
],
traySelectOption
:
[],
sendData64
:
''
,
platform
:
'android'
,
printLabelData
:
[],
print_text
:
'总箱数'
,
form
:
{
...
...
@@ -67,7 +65,6 @@
};
},
created
()
{
this
.
platform
=
getPlatform
();
this
.
getTraySelectOption
();
},
methods
:
{
...
...
@@ -79,7 +76,6 @@
});
},
bindPickerChange
:
function
(
e
)
{
console
.
log
(
'picker发送选择改变,携带值为'
,
e
.
target
.
value
);
this
.
index
=
e
.
target
.
value
;
this
.
form
.
tray_remark
=
this
.
traySelectOption
[
e
.
target
.
value
].
wstylt_id
;
},
...
...
@@ -165,14 +161,13 @@
});
uni
.
startBluetoothDevicesDiscovery
({
success
:
function
(
res
)
{
console
.
log
(
'搜索设备start'
,
res
);
console
.
log
(
'搜索设备start'
,
JSON
.
stringify
(
res
.
errMsg
)
);
uni
.
onBluetoothDeviceFound
(
function
(
el
)
{
//找到对应蓝牙设备名字
if
(
el
.
devices
[
0
].
name
==
'HM-A300-647a'
)
{
that
.
deviceId
=
el
.
devices
[
0
].
deviceId
;
//成功后存储设备id
that
.
stopBluetoothDevicesDiscovery
();
//关闭搜索
console
.
log
(
"成功搜索设备"
,
el
);
console
.
log
(
el
.
devices
[
0
].
deviceId
);
console
.
log
(
"成功搜索设备"
,
el
.
devices
[
0
].
deviceId
);
}
});
},
...
...
@@ -190,7 +185,7 @@
let
that
=
this
;
uni
.
stopBluetoothDevicesDiscovery
({
success
(
res
)
{
console
.
log
(
'停止搜索'
,
res
);
console
.
log
(
'停止搜索'
,
JSON
.
stringify
(
res
.
errMsg
)
);
that
.
getBLEDeviceServices
();
}
});
...
...
@@ -201,18 +196,18 @@
uni
.
createBLEConnection
({
deviceId
:
this
.
deviceId
,
success
:
res
=>
{
console
.
log
(
'连接成功'
,
JSON
.
stringify
(
res
));
console
.
log
(
'连接成功'
,
JSON
.
stringify
(
res
.
errMsg
));
//需延时连接,不然会报错
setTimeout
(
function
()
{
setTimeout
(
()
=>
{
uni
.
getBLEDeviceServices
({
deviceId
:
that
.
deviceId
,
success
:
res
=>
{
console
.
log
(
'获取蓝牙设备所有服务'
,
res
);
console
.
log
(
'获取蓝牙设备所有服务'
,
JSON
.
stringify
(
res
.
errMsg
)
);
that
.
serviceId
=
res
.
services
[
0
].
uuid
;
that
.
getBLEDeviceCharacteristics
();
}
});
},
1000
)
;
},
1000
)
}
});
},
...
...
@@ -225,40 +220,13 @@
success
:
res
=>
{
that
.
characteristics
=
res
.
characteristics
[
0
].
uuid
;
that
.
sendDataChange
();
console
.
log
(
'服务功能特征值'
,
res
);
console
.
log
(
'服务功能特征值'
,
JSON
.
stringify
(
res
.
errMsg
)
);
},
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
.
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"
);
data
.
push
(
"MA,"
+
this
.
printLabelData
[
i
].
erp_order_sn
+
"\r\n"
);
data
.
push
(
"ENDQR\r\n"
);
h
+=
210
;
}
data
.
push
(
"FORM\r\n"
);
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
+
'次打印'
);
//发送数据 二进制
...
...
@@ -293,33 +261,36 @@
characteristicId
:
that
.
characteristics
,
value
:
that
.
sendData64
,
success
(
res
)
{
console
.
log
(
'writeBLECharacteristicValue success'
,
res
.
errMsg
)
that
.
print_number
++
;
console
.
log
(
'蓝牙写入成功:'
,
JSON
.
stringify
(
res
.
errMsg
))
console
.
log
(
'打印计数:'
+
that
.
print_number
)
if
(
that
.
print_number
<
that
.
printLabelData
.
length
)
{
setTimeout
(
function
()
{
that
.
sendDataChange
();
},
0
);
that
.
sendDataChange
();
}
else
{
uni
.
hideLoading
();
uni
.
closeBLEConnection
({
deviceId
:
that
.
deviceId
,
success
(
res
)
{
console
.
log
(
res
)
console
.
log
(
'关闭蓝牙连接:'
,
JSON
.
stringify
(
res
.
errMsg
));
//清空数据
that
.
print_number
=
0
;
that
.
printLabelData
=
[];
that
.
sendData64
=
''
;
uni
.
showModal
({
title
:
'提示'
,
content
:
'提交成功,请查看标签打印机'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
);
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
})
uni
.
showModal
({
title
:
'提示'
,
content
:
'提交成功,打印中,请查看标签打印机'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
);
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
},
fail
()
{
...
...
pages/tag/repairPrint.vue
View file @
d6b15a65
...
...
@@ -109,7 +109,6 @@
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
({
...
...
@@ -202,7 +201,7 @@
serviceId
:
that
.
serviceId
,
success
:
res
=>
{
that
.
characteristics
=
res
.
characteristics
[
0
].
uuid
;
that
.
sendDataChange
All
();
that
.
sendDataChange
();
console
.
log
(
'服务功能特征值'
,
res
);
},
fail
:
res
=>
{
...
...
@@ -281,22 +280,26 @@
uni
.
closeBLEConnection
({
deviceId
:
that
.
deviceId
,
success
(
res
)
{
console
.
log
(
res
)
console
.
log
(
'关闭蓝牙连接:'
,
JSON
.
stringify
(
res
.
errMsg
));
//清空数据
that
.
print_number
=
0
;
that
.
printLabelData
=
[];
that
.
sendData64
=
''
;
uni
.
showModal
({
title
:
'提示'
,
content
:
'提交成功,请查看标签打印机'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
);
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
})
uni
.
showModal
({
title
:
'提示'
,
content
:
'提交成功,打印中,请查看标签打印机'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
);
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
},
fail
()
{
...
...
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