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
cf59893b
authored
Nov 21, 2023
by
LJM
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
香港wms-理货确认-打印标签
parent
7f901591
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
384 additions
and
338 deletions
pages/tag/print.vue
pages/tallyGoods/confirm.vue
util/util.js
pages/tag/print.vue
View file @
cf59893b
...
@@ -61,323 +61,234 @@
...
@@ -61,323 +61,234 @@
</template>
</template>
<
script
>
<
script
>
import
{
API
}
from
'@/util/api.js'
;
import
{
API
}
from
'@/util/api.js'
;
import
{
getPlatform
}
from
'@/util/util.js'
;
import
{
getPlatform
,
findIndexOrZero
}
from
'@/util/util.js'
;
const
ToBase64
=
require
(
'../../util/base64gb2312.js'
);
const
ToBase64
=
require
(
'../../util/base64gb2312.js'
);
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
print_number
:
0
,
print_number
:
0
,
serviceId
:
''
,
serviceId
:
''
,
deviceId
:
''
,
deviceId
:
''
,
device_name
:
''
,
device_name
:
''
,
characteristics
:
''
,
characteristics
:
''
,
text
:
'标签数量'
,
text
:
'标签数量'
,
index
:
-
1
,
index
:
-
1
,
index_erp_order_sn_pre
:
-
1
,
index_erp_order_sn_pre
:
-
1
,
index_print_type
:
1
,
index_print_type
:
1
,
items_erp_order_sn_pre
:
[
'A单号'
,
'B单号'
,
'D单号'
],
items_erp_order_sn_pre
:
[
'A单号'
,
'B单号'
,
'D单号'
],
items_print_type
:
[
'卡板'
,
'散箱'
],
items_print_type
:
[
'卡板'
,
'散箱'
],
traySelectOption
:
[],
traySelectOption
:
[],
sendData64
:
''
,
sendData64
:
''
,
printLabelData
:
[],
printLabelData
:
[],
print_text
:
'总箱数'
,
print_text
:
'总箱数'
,
platform
:
''
,
platform
:
''
,
wstyptll_id
:
''
,
wstyptll_id
:
''
,
batchArr
:
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
],
batchArr
:
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
],
flag
:
false
,
flag
:
false
,
numberList
:
[],
numberList
:
[],
numberArr
:
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
],
numberArr
:
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
],
numberIndex
:
0
,
numberIndex
:
0
,
form
:
{
form
:
{
batch
:
0
,
//批次
batch
:
0
,
//批次
print_type
:
2
,
//打印类型
print_type
:
2
,
//打印类型
erp_order_sn
:
''
,
//入仓号
erp_order_sn
:
''
,
//入仓号
label_num
:
'1'
,
//总箱数
label_num
:
'1'
,
//总箱数
number
:
1
,
number
:
1
,
numbers
:
[]
numbers
:
[]
},
printParams
:
{
board_num
:
''
,
//板子数
box_num
:
''
,
//箱子数
erp_order_sn
:
''
//入仓号
}
};
},
onLoad
(
option
)
{
this
.
platform
=
getPlatform
();
this
.
printParams
.
board_num
=
option
.
board_num
||
''
;
this
.
printParams
.
box_num
=
option
.
box_num
||
''
;
this
.
printParams
.
erp_order_sn
=
option
.
erp_order_sn
||
''
;
//如果【理货确认-箱】有数值,则【打印标签】打印类型为【散箱】并继承数据【标签数量】
if
(
this
.
printParams
.
box_num
)
{
this
.
index_print_type
=
1
;
this
.
form
.
label_num
=
this
.
printParams
.
box_num
;
this
.
form
.
erp_order_sn
=
this
.
printParams
.
erp_order_sn
;
}
}
};
},
onLoad
(
option
)
{
this
.
platform
=
getPlatform
();
//停止搜索,节省系统资源
//如果【理货确认-板】有数值,则【打印标签】打印类型为【卡板】并继承卡板数
uni
.
stopBluetoothDevicesDiscovery
({
if
(
this
.
printParams
.
board_num
)
{
success
:
res
=>
{
this
.
index_print_type
=
0
;
console
.
log
(
'停止搜索'
,
JSON
.
stringify
(
res
.
errMsg
));
this
.
form
.
erp_order_sn
=
this
.
printParams
.
erp_order_sn
;
this
.
numberIndex
=
findIndexOrZero
(
this
.
numberArr
,
Number
(
this
.
printParams
.
board_num
));
//匹配到卡板数就选中,否则就是默认0
}
}
});
try
{
//如果【理货确认-板/箱 均不为0】,则【打印标签】打印类型只继承入仓号,打印类型默认为【散箱】标签数量1 批次为0(保持原默认值)
uni
.
removeStorageSync
(
'device'
);
if
(
this
.
printParams
.
box_num
&&
this
.
printParams
.
board_num
)
{
}
catch
(
e
)
{
this
.
form
.
erp_order_sn
=
this
.
printParams
.
erp_order_sn
;
// error
}
}
},
//停止搜索,节省系统资源
onShow
()
{
uni
.
stopBluetoothDevicesDiscovery
({
//获取已连接蓝牙设备信息
const
deviceData
=
uni
.
getStorageSync
(
'device'
)
||
''
;
if
(
deviceData
)
{
this
.
deviceId
=
deviceData
.
deviceId
;
this
.
serviceId
=
deviceData
.
serviceId
;
this
.
characteristics
=
deviceData
.
characteristics
;
this
.
device_name
=
deviceData
.
name
;
}
else
{
this
.
deviceId
=
''
;
this
.
device_name
=
''
;
}
},
methods
:
{
scanChange
()
{
uni
.
scanCode
({
success
:
res
=>
{
success
:
res
=>
{
if
(
res
.
errMsg
==
'scanCode:ok'
)
{
console
.
log
(
'停止搜索'
,
JSON
.
stringify
(
res
.
errMsg
));
this
.
form
.
erp_order_sn
=
res
.
result
;
}
},
fail
:
function
(
res
)
{
uni
.
showToast
({
title
:
'扫码失败'
,
icon
:
'error'
});
}
}
});
});
},
/**
* 卡板数监听
*/
bindPickerChange
(
e
)
{
this
.
numberIndex
=
Number
(
e
.
detail
.
value
);
this
.
form
.
number
=
Number
(
e
.
target
.
value
)
+
1
;
if
(
this
.
form
.
number
>
1
)
{
try
{
this
.
flag
=
true
;
uni
.
removeStorageSync
(
'device'
);
this
.
numberList
=
[];
}
catch
(
e
)
{
this
.
form
.
numbers
=
[];
// error
for
(
var
i
=
0
;
i
<
this
.
form
.
number
;
i
++
)
{
if
(
i
<
this
.
form
.
number
-
1
)
{
this
.
numberList
.
push
(
i
);
this
.
form
.
numbers
.
push
({
value
:
''
});
}
}
}
else
{
this
.
flag
=
false
;
this
.
numberList
=
[];
this
.
form
.
numbers
=
[];
}
}
},
},
/**
onShow
()
{
* 批次监听
//获取已连接蓝牙设备信息
*/
const
deviceData
=
uni
.
getStorageSync
(
'device'
)
||
''
;
bindPickerChangeBatch
(
e
)
{
if
(
deviceData
)
{
this
.
form
.
batch
=
e
.
target
.
value
;
this
.
deviceId
=
deviceData
.
deviceId
;
},
this
.
serviceId
=
deviceData
.
serviceId
;
/**
this
.
characteristics
=
deviceData
.
characteristics
;
* 卡板数量list监听
this
.
device_name
=
deviceData
.
name
;
*/
}
else
{
onInput
(
e
,
index
)
{
this
.
deviceId
=
''
;
this
.
form
.
numbers
[
index
].
value
=
e
.
detail
.
value
;
this
.
device_name
=
''
;
}
},
},
submit
()
{
methods
:
{
if
(
!
this
.
device_name
)
{
scanChange
()
{
uni
.
showModal
({
uni
.
scanCode
({
title
:
'提示'
,
success
:
res
=>
{
content
:
'请连接蓝牙设备'
,
if
(
res
.
errMsg
==
'scanCode:ok'
)
{
showCancel
:
false
,
this
.
form
.
erp_order_sn
=
res
.
result
;
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
uni
.
navigateTo
({
url
:
'/pages/tag/deviceList'
});
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
},
fail
:
function
(
res
)
{
uni
.
showToast
({
title
:
'扫码失败'
,
icon
:
'error'
});
}
}
});
});
return
false
;
},
}
/**
if
(
!
this
.
form
.
erp_order_sn
)
{
* 卡板数监听
uni
.
showModal
({
*/
title
:
'提示'
,
bindPickerChange
(
e
)
{
content
:
'请输入入仓号'
,
this
.
numberIndex
=
Number
(
e
.
detail
.
value
);
showCancel
:
false
this
.
form
.
number
=
Number
(
e
.
target
.
value
)
+
1
;
});
return
false
;
}
if
(
!
this
.
form
.
label_num
)
{
uni
.
showModal
({
title
:
'提示'
,
content
:
'请输入'
+
this
.
text
,
showCancel
:
false
});
return
false
;
}
if
(
!
/
(
^
[
0-9
]
*$
)
/
.
test
(
this
.
form
.
label_num
))
{
uni
.
showModal
({
title
:
'提示'
,
content
:
this
.
text
+
'为纯数字'
,
showCancel
:
false
});
return
false
;
}
if
(
this
.
index_print_type
==
0
&&
this
.
form
.
number
>
1
)
{
let
label_num
=
this
.
form
.
label_num
*
1
;
//总箱数
let
num
=
0
;
if
(
this
.
form
.
numbers
.
length
>
0
)
{
if
(
this
.
form
.
number
>
1
)
{
for
(
let
i
=
0
;
i
<
this
.
form
.
numbers
.
length
;
i
++
)
{
this
.
flag
=
true
;
num
+=
this
.
form
.
numbers
[
i
].
value
*
1
;
this
.
numberList
=
[];
this
.
form
.
numbers
=
[];
for
(
var
i
=
0
;
i
<
this
.
form
.
number
;
i
++
)
{
if
(
i
<
this
.
form
.
number
-
1
)
{
this
.
numberList
.
push
(
i
);
this
.
form
.
numbers
.
push
({
value
:
''
});
}
}
}
}
else
{
this
.
flag
=
false
;
this
.
numberList
=
[];
this
.
form
.
numbers
=
[];
}
}
},
if
(
label_num
!=
num
)
{
/**
* 批次监听
*/
bindPickerChangeBatch
(
e
)
{
this
.
form
.
batch
=
e
.
target
.
value
;
},
/**
* 卡板数量list监听
*/
onInput
(
e
,
index
)
{
this
.
form
.
numbers
[
index
].
value
=
e
.
detail
.
value
;
},
submit
()
{
if
(
!
this
.
device_name
)
{
uni
.
showModal
({
title
:
'提示'
,
content
:
'请连接蓝牙设备'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
uni
.
navigateTo
({
url
:
'/pages/tag/deviceList'
});
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
return
false
;
}
if
(
!
this
.
form
.
erp_order_sn
)
{
uni
.
showModal
({
uni
.
showModal
({
title
:
'提示'
,
title
:
'提示'
,
content
:
'
卡板数量总和必须等于总箱数
'
,
content
:
'
请输入入仓号
'
,
showCancel
:
false
showCancel
:
false
});
});
return
false
;
return
false
;
}
}
}
let
params
=
Object
.
assign
(
this
.
form
,
{
if
(
!
this
.
form
.
label_num
)
{
is_add
:
0
});
this
.
request
(
API
.
checkRepeatPrintLabel
,
'POST'
,
params
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
this
.
printLabelChange
();
}
else
{
uni
.
showModal
({
uni
.
showModal
({
title
:
'提示'
,
title
:
'提示'
,
content
:
res
.
err_msg
,
content
:
'请输入'
+
this
.
text
,
confirmText
:
'继续打印'
,
showCancel
:
false
success
:
res
=>
{
if
(
res
.
confirm
)
{
this
.
printLabelChange
();
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
});
return
false
;
}
}
});
},
if
(
!
/
(
^
[
0-9
]
*$
)
/
.
test
(
this
.
form
.
label_num
))
{
printLabelChange
()
{
this
.
request
(
API
.
printLabel
,
'POST'
,
this
.
form
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
this
.
printLabelData
=
res
.
data
;
this
.
wstyptll_id
=
res
.
data
[
0
].
wstyptll_id
;
this
.
sendDataChange
();
//发送数据
}
else
{
uni
.
showModal
({
uni
.
showModal
({
title
:
'提示'
,
title
:
'提示'
,
content
:
res
.
err_msg
,
content
:
this
.
text
+
'为纯数字'
,
confirmText
:
'关闭'
showCancel
:
false
});
});
return
false
;
}
}
});
},
if
(
this
.
index_print_type
==
0
&&
this
.
form
.
number
>
1
)
{
/**
let
label_num
=
this
.
form
.
label_num
*
1
;
//总箱数
* 向蓝牙发送数据
let
num
=
0
;
*/
sendDataChange
()
{
if
(
this
.
form
.
numbers
.
length
>
0
)
{
try
{
for
(
let
i
=
0
;
i
<
this
.
form
.
numbers
.
length
;
i
++
)
{
uni
.
showLoading
({
num
+=
this
.
form
.
numbers
[
i
].
value
*
1
;
title
:
'打印中...'
}
});
}
console
.
log
(
'第'
+
this
.
print_number
+
'次开始打印start...'
);
let
data
=
[];
if
(
label_num
!=
num
)
{
if
(
this
.
printLabelData
.
length
>
0
)
{
uni
.
showModal
({
data
.
push
(
'! 60 200 200 300 1\r\n'
);
title
:
'提示'
,
data
.
push
(
'SETMAG 3 4\r\n'
);
content
:
'卡板数量总和必须等于总箱数'
,
data
.
push
(
'T 7 0 10 20 '
+
this
.
printLabelData
[
this
.
print_number
].
erp_order_sn
+
'\r\n'
);
showCancel
:
false
data
.
push
(
'SETMAG 0 0\r\n'
);
});
if
(
this
.
form
.
print_type
==
1
)
{
return
false
;
data
.
push
(
'T 5 0 10 120 总箱数:'
+
this
.
printLabelData
[
this
.
print_number
].
label_num
+
'箱\r\n'
);
}
else
{
data
.
push
(
'T 5 0 10 120 箱号:'
+
this
.
printLabelData
[
this
.
print_number
].
label_sort
+
'/'
+
this
.
printLabelData
[
this
.
print_number
].
label_num
+
'\r\n'
);
}
}
data
.
push
(
'T 8 0 10 180 时间:'
+
this
.
printLabelData
[
this
.
print_number
].
create_time_cn
+
'\r\n'
);
data
.
push
(
'T 8 0 10 220 仓库代码:'
+
this
.
printLabelData
[
this
.
print_number
].
warehouse_code
+
'\r\n'
);
data
.
push
(
'T 8 0 10 260 流水号:'
+
this
.
printLabelData
[
this
.
print_number
].
wstyptll_id_sn
+
'\r\n'
);
data
.
push
(
'SETMAG 4 1'
+
'\r\n'
);
data
.
push
(
'T 8 0 350 30 '
+
this
.
printLabelData
[
this
.
print_number
].
batch
+
'\r\n'
);
data
.
push
(
'SETMAG 0 0'
+
'\r\n'
);
data
.
push
(
'B QR 260 120 M 2 U 8\r\n'
);
data
.
push
(
'MA,'
+
this
.
printLabelData
[
this
.
print_number
][
'box_code'
]
+
'|\r\n'
);
data
.
push
(
'ENDQR\r\n'
);
data
.
push
(
'FORM\r\n'
);
data
.
push
(
'PRINT\r\n'
);
}
}
console
.
log
(
data
.
join
(
''
));
this
.
cutCommand
(
data
.
join
(
''
));
let
params
=
Object
.
assign
(
this
.
form
,
{
}
catch
(
e
)
{
is_add
:
0
uni
.
hideLoading
();
uni
.
showModal
({
title
:
'提示'
,
content
:
'数据异常,请重试'
,
showCancel
:
false
,
confirmText
:
'关闭'
});
});
}
this
.
request
(
API
.
checkRepeatPrintLabel
,
'POST'
,
params
,
true
).
then
(
res
=>
{
},
if
(
res
.
err_code
===
0
)
{
/**
this
.
printLabelChange
();
* 分批传输数据
}
else
{
*/
cutCommand
:
function
(
data
)
{
var
packageLength
=
10
;
//安卓不超过10个字节传输
var
sendData64
=
[];
if
(
this
.
platform
==
'ios'
)
{
packageLength
=
30
;
}
console
.
log
(
'package长度:'
+
packageLength
);
for
(
let
i
=
0
;
i
<
Math
.
ceil
(
data
.
length
/
packageLength
);
i
++
)
{
sendData64
[
i
]
=
uni
.
base64ToArrayBuffer
(
ToBase64
.
encode64gb2312
(
data
.
substr
(
i
*
packageLength
,
packageLength
)));
}
this
.
sendData64
=
sendData64
;
console
.
log
(
sendData64
);
this
.
writeBLECharacteristicValue
(
1
);
},
/**
* 写入二进制数据
*/
writeBLECharacteristicValue
(
times
)
{
var
sendData64
=
this
.
sendData64
;
if
(
sendData64
.
length
>=
times
)
{
uni
.
writeBLECharacteristicValue
({
deviceId
:
this
.
deviceId
,
serviceId
:
this
.
serviceId
,
characteristicId
:
this
.
characteristics
,
value
:
sendData64
[
times
-
1
],
success
:
res
=>
{
this
.
writeBLECharacteristicValue
(
++
times
);
},
fail
:
res
=>
{
uni
.
hideLoading
();
uni
.
showModal
({
uni
.
showModal
({
title
:
'提示'
,
title
:
'提示'
,
content
:
'打印失败,请重新进入打印页面'
,
content
:
res
.
err_msg
,
showCancel
:
false
,
confirmText
:
'继续打印'
,
confirmText
:
'关闭'
,
success
:
res
=>
{
success
:
res
=>
{
if
(
res
.
confirm
)
{
if
(
res
.
confirm
)
{
this
.
characteristics
=
''
;
//连接蓝牙信息清空
this
.
printLabelChange
();
this
.
deviceId
=
''
;
//连接蓝牙信息清空
this
.
device_name
=
''
;
//连接蓝牙信息清空
this
.
print_number
=
0
;
//打印计数归零
this
.
printLabelData
=
[];
//打印数据清空
this
.
sendData64
=
''
;
//发送蓝牙数据清空
this
.
delErpOrderSnCodeManage
();
//及时作废
}
else
if
(
res
.
cancel
)
{
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
console
.
log
(
'用户点击取消'
);
}
}
...
@@ -385,71 +296,186 @@ export default {
...
@@ -385,71 +296,186 @@ export default {
});
});
}
}
});
});
}
else
{
},
this
.
print_number
++
;
printLabelChange
()
{
console
.
log
(
'第'
+
this
.
print_number
+
'次传输完成end'
);
this
.
request
(
API
.
printLabel
,
'POST'
,
this
.
form
,
true
).
then
(
res
=>
{
if
(
this
.
print_number
<
this
.
printLabelData
.
length
)
{
if
(
res
.
err_code
===
0
)
{
this
.
sendDataChange
();
this
.
printLabelData
=
res
.
data
;
}
else
{
this
.
wstyptll_id
=
res
.
data
[
0
].
wstyptll_id
;
this
.
sendDataChange
();
//发送数据
}
else
{
uni
.
showModal
({
title
:
'提示'
,
content
:
res
.
err_msg
,
confirmText
:
'关闭'
});
}
});
},
/**
* 向蓝牙发送数据
*/
sendDataChange
()
{
try
{
uni
.
showLoading
({
title
:
'打印中...'
});
console
.
log
(
'第'
+
this
.
print_number
+
'次开始打印start...'
);
let
data
=
[];
if
(
this
.
printLabelData
.
length
>
0
)
{
data
.
push
(
'! 60 200 200 300 1\r\n'
);
data
.
push
(
'SETMAG 3 4\r\n'
);
data
.
push
(
'T 7 0 10 20 '
+
this
.
printLabelData
[
this
.
print_number
].
erp_order_sn
+
'\r\n'
);
data
.
push
(
'SETMAG 0 0\r\n'
);
if
(
this
.
form
.
print_type
==
1
)
{
data
.
push
(
'T 5 0 10 120 总箱数:'
+
this
.
printLabelData
[
this
.
print_number
].
label_num
+
'箱\r\n'
);
}
else
{
data
.
push
(
'T 5 0 10 120 箱号:'
+
this
.
printLabelData
[
this
.
print_number
].
label_sort
+
'/'
+
this
.
printLabelData
[
this
.
print_number
].
label_num
+
'\r\n'
);
}
data
.
push
(
'T 8 0 10 180 时间:'
+
this
.
printLabelData
[
this
.
print_number
].
create_time_cn
+
'\r\n'
);
data
.
push
(
'T 8 0 10 220 仓库代码:'
+
this
.
printLabelData
[
this
.
print_number
].
warehouse_code
+
'\r\n'
);
data
.
push
(
'T 8 0 10 260 流水号:'
+
this
.
printLabelData
[
this
.
print_number
].
wstyptll_id_sn
+
'\r\n'
);
data
.
push
(
'SETMAG 4 1'
+
'\r\n'
);
data
.
push
(
'T 8 0 350 30 '
+
this
.
printLabelData
[
this
.
print_number
].
batch
+
'\r\n'
);
data
.
push
(
'SETMAG 0 0'
+
'\r\n'
);
data
.
push
(
'B QR 260 120 M 2 U 8\r\n'
);
data
.
push
(
'MA,'
+
this
.
printLabelData
[
this
.
print_number
][
'box_code'
]
+
'|\r\n'
);
data
.
push
(
'ENDQR\r\n'
);
data
.
push
(
'FORM\r\n'
);
data
.
push
(
'PRINT\r\n'
);
}
console
.
log
(
data
.
join
(
''
));
this
.
cutCommand
(
data
.
join
(
''
));
}
catch
(
e
)
{
uni
.
hideLoading
();
uni
.
hideLoading
();
//重置
this
.
print_number
=
0
;
//打印计数归零
this
.
printLabelData
=
[];
//打印数据清空
this
.
sendData64
=
''
;
//发送蓝牙数据清空
uni
.
showModal
({
uni
.
showModal
({
title
:
'提示'
,
title
:
'提示'
,
content
:
'
打印成功,请查看标签打印机
'
,
content
:
'
数据异常,请重试
'
,
showCancel
:
false
,
showCancel
:
false
,
confirmText
:
'关闭'
,
confirmText
:
'关闭'
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
);
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
});
}
}
}
},
},
/**
delErpOrderSnCodeManage
()
{
* 分批传输数据
this
.
request
(
API
.
delWstyptllIdErpOrderSnCodeManage
,
'POST'
,
{
wstyptll_id
:
this
.
wstyptll_id
},
false
).
then
(
res
=>
{
*/
if
(
res
.
err_code
===
0
)
{
cutCommand
:
function
(
data
)
{
}
else
{
var
packageLength
=
10
;
//安卓不超过10个字节传输
uni
.
showModal
({
var
sendData64
=
[];
title
:
'提示'
,
if
(
this
.
platform
==
'ios'
)
{
content
:
res
.
err_msg
,
packageLength
=
30
;
showCancel
:
false
,
}
confirmText
:
'关闭'
console
.
log
(
'package长度:'
+
packageLength
);
for
(
let
i
=
0
;
i
<
Math
.
ceil
(
data
.
length
/
packageLength
);
i
++
)
{
sendData64
[
i
]
=
uni
.
base64ToArrayBuffer
(
ToBase64
.
encode64gb2312
(
data
.
substr
(
i
*
packageLength
,
packageLength
)));
}
this
.
sendData64
=
sendData64
;
console
.
log
(
sendData64
);
this
.
writeBLECharacteristicValue
(
1
);
},
/**
* 写入二进制数据
*/
writeBLECharacteristicValue
(
times
)
{
var
sendData64
=
this
.
sendData64
;
if
(
sendData64
.
length
>=
times
)
{
uni
.
writeBLECharacteristicValue
({
deviceId
:
this
.
deviceId
,
serviceId
:
this
.
serviceId
,
characteristicId
:
this
.
characteristics
,
value
:
sendData64
[
times
-
1
],
success
:
res
=>
{
this
.
writeBLECharacteristicValue
(
++
times
);
},
fail
:
res
=>
{
uni
.
hideLoading
();
uni
.
showModal
({
title
:
'提示'
,
content
:
'打印失败,请重新进入打印页面'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
res
=>
{
if
(
res
.
confirm
)
{
this
.
characteristics
=
''
;
//连接蓝牙信息清空
this
.
deviceId
=
''
;
//连接蓝牙信息清空
this
.
device_name
=
''
;
//连接蓝牙信息清空
this
.
print_number
=
0
;
//打印计数归零
this
.
printLabelData
=
[];
//打印数据清空
this
.
sendData64
=
''
;
//发送蓝牙数据清空
this
.
delErpOrderSnCodeManage
();
//及时作废
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
});
});
}
else
{
this
.
print_number
++
;
console
.
log
(
'第'
+
this
.
print_number
+
'次传输完成end'
);
if
(
this
.
print_number
<
this
.
printLabelData
.
length
)
{
this
.
sendDataChange
();
}
else
{
uni
.
hideLoading
();
//重置
this
.
print_number
=
0
;
//打印计数归零
this
.
printLabelData
=
[];
//打印数据清空
this
.
sendData64
=
''
;
//发送蓝牙数据清空
uni
.
showModal
({
title
:
'提示'
,
content
:
'打印成功,请查看标签打印机'
,
showCancel
:
false
,
confirmText
:
'关闭'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
console
.
log
(
'用户点击确定'
);
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
}
}
}
});
},
},
delErpOrderSnCodeManage
()
{
change
(
index
,
type
)
{
this
.
request
(
API
.
delWstyptllIdErpOrderSnCodeManage
,
'POST'
,
{
wstyptll_id
:
this
.
wstyptll_id
},
false
).
then
(
res
=>
{
if
(
type
==
'print_type'
)
{
if
(
res
.
err_code
===
0
)
{}
else
{
//打印类型
uni
.
showModal
({
this
.
index_print_type
=
index
;
title
:
'提示'
,
if
(
index
==
0
)
{
content
:
res
.
err_msg
,
this
.
form
.
print_type
=
1
;
showCancel
:
false
,
this
.
text
=
'总箱数'
;
confirmText
:
'关闭'
this
.
print_text
=
'总箱数'
;
});
this
.
numberIndex
=
0
;
}
}
else
if
(
index
==
1
)
{
});
this
.
form
.
print_type
=
2
;
},
this
.
text
=
'标签数量'
;
change
(
index
,
type
)
{
this
.
print_text
=
'箱号'
;
if
(
type
==
'print_type'
)
{
//打印类型
this
.
index_print_type
=
index
;
if
(
index
==
0
)
{
this
.
form
.
print_type
=
1
;
this
.
text
=
'总箱数'
;
this
.
print_text
=
'总箱数'
;
this
.
numberIndex
=
0
;
}
else
if
(
index
==
1
)
{
this
.
form
.
print_type
=
2
;
this
.
text
=
'标签数量'
;
this
.
print_text
=
'箱号'
;
//置空卡板
//置空卡板
this
.
flag
=
false
;
this
.
flag
=
false
;
this
.
form
.
number
=
''
;
this
.
form
.
number
=
''
;
this
.
form
.
numbers
=
[];
this
.
form
.
numbers
=
[];
}
}
}
}
}
}
}
}
};
};
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
@import
'../../assets/css/tag/print.scss'
;
@import
'../../assets/css/tag/print.scss'
;
</
style
>
</
style
>
\ No newline at end of file
pages/tallyGoods/confirm.vue
View file @
cf59893b
...
@@ -110,6 +110,7 @@
...
@@ -110,6 +110,7 @@
</view>
</view>
</view>
</view>
<view
class=
"btn row rowCenter verCenter"
@
click=
"submit()"
:class=
"{ disabled: disabled }"
>
确认提交
</view>
<view
class=
"btn row rowCenter verCenter"
@
click=
"submit()"
:class=
"{ disabled: disabled }"
>
确认提交
</view>
<view
class=
"btn row rowCenter verCenter"
style=
"margin-top: 12rpx;background-color: #f00;"
@
click=
"submit(1)"
:class=
"{ disabled: disabled }"
>
确认提交并打印
</view>
</view>
</view>
</template>
</template>
...
@@ -456,9 +457,10 @@
...
@@ -456,9 +457,10 @@
this
.
form
.
customs_clearance_price
=
index
;
this
.
form
.
customs_clearance_price
=
index
;
},
},
/**
/**
* @param {Object} type 1提交并打印
* 提交
* 提交
*/
*/
submit
()
{
submit
(
type
)
{
if
(
!
this
.
form
.
erp_order_sn
)
{
if
(
!
this
.
form
.
erp_order_sn
)
{
uni
.
showModal
({
uni
.
showModal
({
title
:
'提示'
,
title
:
'提示'
,
...
@@ -524,11 +526,18 @@
...
@@ -524,11 +526,18 @@
showCancel
:
false
,
showCancel
:
false
,
success
:
res
=>
{
success
:
res
=>
{
if
(
res
.
confirm
)
{
if
(
res
.
confirm
)
{
setTimeout
(()
=>
{
if
(
type
==
1
)
{
uni
.
navigateBack
({
//点击【确认提交并打印】跳转至【打印标签】页面
delta
:
1
uni
.
navigateTo
({
});
url
:
'/pages/tag/print?board_num='
+
this
.
form
.
board_num
+
'&box_num='
+
this
.
form
.
box_num
+
'&erp_order_sn='
+
this
.
form
.
erp_order_sn
},
2000
);
})
}
else
{
setTimeout
(()
=>
{
uni
.
navigateBack
({
delta
:
1
});
},
2000
);
}
}
else
if
(
res
.
cancel
)
{
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
console
.
log
(
'用户点击取消'
);
}
}
...
...
util/util.js
View file @
cf59893b
...
@@ -86,7 +86,6 @@ const debounce = (fn, wait) => {
...
@@ -86,7 +86,6 @@ const debounce = (fn, wait) => {
}
}
}
}
/**
/**
* 来创建指定长度且所有元素都被初始化为 false 的数组
* 来创建指定长度且所有元素都被初始化为 false 的数组
*/
*/
...
@@ -94,11 +93,21 @@ const createArray = (length, value) => {
...
@@ -94,11 +93,21 @@ const createArray = (length, value) => {
return
Array
(
length
).
fill
(
value
);
return
Array
(
length
).
fill
(
value
);
}
}
/**
* 数组内找出对于的索引
*/
const
findIndexOrZero
=
(
arr
,
value
)
=>
{
var
index
=
arr
.
indexOf
(
value
);
return
index
!==
-
1
?
index
:
0
;
}
module
.
exports
=
{
module
.
exports
=
{
request
,
request
,
getPlatform
,
getPlatform
,
titleCase
,
titleCase
,
debounce
,
debounce
,
createArray
createArray
,
findIndexOrZero
}
}
\ No newline at end of file
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