doway-coms 2.10.76 → 2.10.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2169,7 +2169,7 @@ export default {
|
|
|
2169
2169
|
//防止报错 有slots值就走前面 没有slots这个键key就走后面
|
|
2170
2170
|
if (
|
|
2171
2171
|
originCol.controlType !== controlType.operation &&
|
|
2172
|
-
originCol.filter === true
|
|
2172
|
+
(originCol.filter === true || originCol.filters === true) //兼容来的模式filters筛选
|
|
2173
2173
|
) {
|
|
2174
2174
|
let filterTypeName = `${originCol.controlType}_filter`
|
|
2175
2175
|
if (originCol.filterControlType) {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { encode } from 'gbk.js' // 修正包名
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
export function getPrinterPath() {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const websocket = new WebSocket(process.env.VUE_APP_PRINT_USB_URL)
|
|
6
|
+
|
|
7
|
+
websocket.onopen = function() {
|
|
8
|
+
websocket.send(JSON.stringify({ usb_list: [] }))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
websocket.onmessage = function(event) {
|
|
12
|
+
try {
|
|
13
|
+
const data = JSON.parse(event.data)
|
|
14
|
+
if ('usb_list' in data) {
|
|
15
|
+
if (data.usb_list.length === 0) {
|
|
16
|
+
reject(new Error('未找到USB打印机'))
|
|
17
|
+
} else {
|
|
18
|
+
resolve(data.usb_list[0].USBPath)
|
|
19
|
+
}
|
|
20
|
+
websocket.close()
|
|
21
|
+
}
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(new Error('获取打印机信息失败: ' + e))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
websocket.onerror = function(error) {
|
|
28
|
+
reject(new Error('WebSocket连接失败: ' + error))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 设置超时
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
websocket.close()
|
|
34
|
+
reject(new Error('获取打印机超时'))
|
|
35
|
+
}, 5000)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function printLabel(printerPath, command) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const websocket = new WebSocket(process.env.VUE_APP_PRINT_USB_URL)
|
|
42
|
+
|
|
43
|
+
websocket.onopen = function() {
|
|
44
|
+
const encodedCommand = btoa(
|
|
45
|
+
Array.from(encode(command))
|
|
46
|
+
.map(val => String.fromCharCode(val))
|
|
47
|
+
.join('')
|
|
48
|
+
)
|
|
49
|
+
const printObj = {
|
|
50
|
+
functions_inorder: [
|
|
51
|
+
{ openport_usb: printerPath },
|
|
52
|
+
{ sendUint8Array: encodedCommand },
|
|
53
|
+
{ closeport: '' }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
websocket.send(JSON.stringify(printObj))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
websocket.onmessage = function(event) {
|
|
60
|
+
if (event.data === 'Finished') {
|
|
61
|
+
websocket.close()
|
|
62
|
+
resolve()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
websocket.onerror = function(error) {
|
|
67
|
+
reject(new Error('打印失败: ' + error))
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function printLabelByte(printerPath, encodedCommands) {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
const websocket = new WebSocket(process.env.VUE_APP_PRINT_USB_URL)
|
|
75
|
+
websocket.onopen = function() {
|
|
76
|
+
const printObj = {
|
|
77
|
+
functions_inorder: [
|
|
78
|
+
{ openport_usb: printerPath }
|
|
79
|
+
// {"sendUint8Array": encodedCommand},
|
|
80
|
+
// {"sendUint8Array": encodedCommand},
|
|
81
|
+
// {"closeport": ""}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
XEUtils.arrayEach(encodedCommands, encodedCommand => {
|
|
85
|
+
printObj.functions_inorder.push({ sendUint8Array: encodedCommand })
|
|
86
|
+
})
|
|
87
|
+
printObj.functions_inorder.push({ closeport: '' })
|
|
88
|
+
websocket.send(JSON.stringify(printObj))
|
|
89
|
+
}
|
|
90
|
+
websocket.onmessage = function(event) {
|
|
91
|
+
if (event.data === 'Finished') {
|
|
92
|
+
websocket.close()
|
|
93
|
+
resolve()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
websocket.onerror = function(error) {
|
|
98
|
+
reject(new Error('打印失败: ' + error))
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}
|