@alizadefaig/pos-server 1.2.7 → 1.2.9
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 +1 -1
- package/routes/common/tax.js +29 -0
- package/routes/desktop/api/printers.js +10 -2
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const {socketSendByFilter, findKeyByValue} = require("../../utils");
|
|
3
|
+
const serverSocket = require("../../app/socket/server")();
|
|
4
|
+
const router = express.Router();
|
|
5
|
+
const {createProxyMiddleware, fixRequestBody} = require("http-proxy-middleware");
|
|
6
|
+
const moment = require("moment/moment");
|
|
7
|
+
|
|
8
|
+
const proxy = createProxyMiddleware({
|
|
9
|
+
target: 'http://localhost:3005',
|
|
10
|
+
router: function (req) {
|
|
11
|
+
// Подставляем URL из query или тела запроса
|
|
12
|
+
const dynamicUrl = req.query.url || req.body?.url;
|
|
13
|
+
|
|
14
|
+
if (!dynamicUrl) {
|
|
15
|
+
return null; // не будет проксировать, Express продолжит обработку
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return dynamicUrl;
|
|
19
|
+
},
|
|
20
|
+
on: {
|
|
21
|
+
proxyReq: (proxyReq, req, res, options) => {
|
|
22
|
+
return fixRequestBody(proxyReq, req);
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
router.use('/tax', proxy)
|
|
28
|
+
|
|
29
|
+
module.exports = router;
|
|
@@ -108,15 +108,22 @@ router.get('/printers.get', async (req, res) => {
|
|
|
108
108
|
})
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
+
router.get('/printers.getUsbPrinters', async (req, res) => {
|
|
112
|
+
let usbPrinters = await getUsbPrinters();
|
|
113
|
+
res.json(usbPrinters);
|
|
114
|
+
})
|
|
115
|
+
|
|
111
116
|
router.post('/printers.print', async (req, res) => {
|
|
112
117
|
const device = getPrinterDevice(req.body.printer);
|
|
113
118
|
const printMethod = req.body.print_method || 'raster';
|
|
114
|
-
const printMode = req.body.
|
|
119
|
+
const printMode = req.body.mode;
|
|
120
|
+
const partHeight = req.body.height || 576;
|
|
121
|
+
const partWidth = req.body.width || 576;
|
|
115
122
|
if (!device) {
|
|
116
123
|
return res.send('bad').status(404);
|
|
117
124
|
}
|
|
118
125
|
|
|
119
|
-
const contentsBuffer = await splitImageByHeight(req.body.content,
|
|
126
|
+
const contentsBuffer = await splitImageByHeight(req.body.content, partHeight, partWidth);
|
|
120
127
|
const images = await new Promise(async (resolve, reject) => {
|
|
121
128
|
let _images = [];
|
|
122
129
|
for (const buffer of contentsBuffer) {
|
|
@@ -148,6 +155,7 @@ router.post('/printers.print', async (req, res) => {
|
|
|
148
155
|
return;
|
|
149
156
|
}
|
|
150
157
|
|
|
158
|
+
printer.align('CT');
|
|
151
159
|
images.map(image => {
|
|
152
160
|
if (printMethod === 'raster') {
|
|
153
161
|
printer.raster(image, printMode);
|