From 0d2024eabd0f07bc4ab3341dddc10464d31938f8 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期六, 21 十二月 2024 18:47:12 +0800
Subject: [PATCH] #新增订单筛选物料界面

---
 static/js/printerjobs.js |  322 ++++++++++++++++++++++++++--------------------------
 1 files changed, 161 insertions(+), 161 deletions(-)

diff --git a/static/js/printerjobs.js b/static/js/printerjobs.js
index e5608b7..5787949 100644
--- a/static/js/printerjobs.js
+++ b/static/js/printerjobs.js
@@ -1,162 +1,162 @@
-const commands = require('./commands.js');
-const TextEncoder = require('./encodeing').TextEncoder;
-
-const printerJobs = function () {
-  this._queue = Array.from(commands.HARDWARE.HW_INIT);
-  this._encoder = new TextEncoder("gb2312", {NONSTANDARD_allowLegacyEncoding: true});
-  this._enqueue = function (cmd) {
-    this._queue.push.apply(this._queue, cmd);
-  }
-};
-
-/**
- * 澧炲姞鎵撳嵃鍐呭
- * @param  {string} content  鏂囧瓧鍐呭
- */
-printerJobs.prototype.text = function (content) {
-  if (content) {
-    let uint8Array = this._encoder.encode(content);
-    let encoded = Array.from(uint8Array);
-    this._enqueue(encoded);
-  }
-  return this;
-};
-
-/**
- * 鎵撳嵃鏂囧瓧
- * @param  {string} content  鏂囧瓧鍐呭
- */
-printerJobs.prototype.print = function (content) {
-  this.text(content);
-  this._enqueue(commands.LF);
-  return this;
-};
-
-/**
- * 鎵撳嵃鏂囧瓧骞舵崲琛�
- * @param  {string}  content  鏂囧瓧鍐呭
- */
-printerJobs.prototype.println = function (content = '') {
-  return this.print(content + commands.EOL);
-};
-
-/**
- * 璁剧疆瀵归綈鏂瑰紡
- * @param {string} align 瀵归綈鏂瑰紡 LT/CT/RT
- */
-printerJobs.prototype.setAlign = function (align) {
-  this._enqueue(commands.TEXT_FORMAT['TXT_ALIGN_' + align.toUpperCase()]);
-  return this;
-};
-
-/**
- * 璁剧疆瀛椾綋
- * @param  {string} family A/B/C
- */
-printerJobs.prototype.setFont = function (family) {
-  this._enqueue(commands.TEXT_FORMAT['TXT_FONT_' + family.toUpperCase()]);
-  return this;
-};
-
-/**
- * 璁惧畾瀛椾綋灏哄
- * @param  {number} width 瀛椾綋瀹藉害 1~2
- * @param  {number} height 瀛椾綋楂樺害 1~2
- */
-printerJobs.prototype.setSize = function (width, height) {
-  if (2 >= width && 2 >= height) {
-    this._enqueue(commands.TEXT_FORMAT.TXT_NORMAL);
-    if (2 === width && 2 === height) {
-      this._enqueue(commands.TEXT_FORMAT.TXT_4SQUARE);
-    } else if (1 === width && 2 === height) {
-      this._enqueue(commands.TEXT_FORMAT.TXT_2HEIGHT);
-    } else if (2 === width && 1 === height) {
-      this._enqueue(commands.TEXT_FORMAT.TXT_2WIDTH);
-    }
-  }
-  return this;
-};
-
-/**
- * 璁惧畾瀛椾綋鏄惁鍔犵矖
- * @param  {boolean} bold
- */
-printerJobs.prototype.setBold = function (bold) {
-  if (typeof bold !== 'boolean') {
-    bold = true;
-  }
-  this._enqueue(bold ? commands.TEXT_FORMAT.TXT_BOLD_ON : commands.TEXT_FORMAT.TXT_BOLD_OFF);
-  return this;
-};
-
-/**
- * 璁惧畾鏄惁寮�鍚笅鍒掔嚎
- * @param  {boolean} underline
- */
-printerJobs.prototype.setUnderline = function (underline) {
-  if (typeof underline !== 'boolean') {
-    underline = true;
-  }
-  this._enqueue(underline ? commands.TEXT_FORMAT.TXT_UNDERL_ON : commands.TEXT_FORMAT.TXT_UNDERL_OFF);
-  return this;
-};
-
-/**
- * 璁剧疆琛岄棿璺濅负 n 鐐硅,榛樿鍊艰闂磋窛鏄� 30 鐐�
- * @param {number} n 0鈮鈮�255
- */
-printerJobs.prototype.setLineSpacing = function (n) {
-  if (n === undefined || n === null) {
-    this._enqueue(commands.LINE_SPACING.LS_DEFAULT);
-  } else {
-    this._enqueue(commands.LINE_SPACING.LS_SET);
-    this._enqueue([n]);
-  }
-  return this;
-};
-
-/**
- * 鎵撳嵃绌鸿
- * @param {number} n
- */
-printerJobs.prototype.lineFeed = function (n = 1) {
-  return this.print(new Array(n).fill(commands.EOL).join(''));
-};
-
-/**
- *  璁剧疆瀛椾綋棰滆壊锛岄渶瑕佹墦鍗版満鏀寔
- *  @param  {number} color - 0 榛樿棰滆壊榛戣壊 1 绾㈣壊
- */
-printerJobs.prototype.setColor = function (color) {
-  this._enqueue(commands.COLOR[color === 1 ? 1 : 0]);
-  return this;
-};
-
-/**
- * https://support.loyverse.com/hardware/printers/use-the-beeper-in-a-escpos-printers
- * 铚傞福璀︽姤锛岄渶瑕佹墦鍗版満鏀寔
- * @param  {number} n    铚傞福娆℃暟,1-9
- * @param  {number} t 铚傞福闀跨煭,1-9
- */
-printerJobs.prototype.beep = function (n, t) {
-  this._enqueue(commands.BEEP);
-  this._enqueue([n, t]);
-  return this;
-};
-
-/**
- * 娓呯┖浠诲姟
- */
-printerJobs.prototype.clear = function () {
-  this._queue = Array.from(commands.HARDWARE.HW_INIT);
-  return this;
-};
-
-/**
- * 杩斿洖ArrayBuffer
- */
-printerJobs.prototype.buffer = function () {
-  return new Uint8Array(this._queue).buffer;
-};
-
+const commands = require('./commands.js');
+const TextEncoder = require('./encodeing').TextEncoder;
+
+const printerJobs = function () {
+  this._queue = Array.from(commands.HARDWARE.HW_INIT);
+  this._encoder = new TextEncoder("gb2312", {NONSTANDARD_allowLegacyEncoding: true});
+  this._enqueue = function (cmd) {
+    this._queue.push.apply(this._queue, cmd);
+  }
+};
+
+/**
+ * 澧炲姞鎵撳嵃鍐呭
+ * @param  {string} content  鏂囧瓧鍐呭
+ */
+printerJobs.prototype.text = function (content) {
+  if (content) {
+    let uint8Array = this._encoder.encode(content);
+    let encoded = Array.from(uint8Array);
+    this._enqueue(encoded);
+  }
+  return this;
+};
+
+/**
+ * 鎵撳嵃鏂囧瓧
+ * @param  {string} content  鏂囧瓧鍐呭
+ */
+printerJobs.prototype.print = function (content) {
+  this.text(content);
+  this._enqueue(commands.LF);
+  return this;
+};
+
+/**
+ * 鎵撳嵃鏂囧瓧骞舵崲琛�
+ * @param  {string}  content  鏂囧瓧鍐呭
+ */
+printerJobs.prototype.println = function (content = '') {
+  return this.print(content + commands.EOL);
+};
+
+/**
+ * 璁剧疆瀵归綈鏂瑰紡
+ * @param {string} align 瀵归綈鏂瑰紡 LT/CT/RT
+ */
+printerJobs.prototype.setAlign = function (align) {
+  this._enqueue(commands.TEXT_FORMAT['TXT_ALIGN_' + align.toUpperCase()]);
+  return this;
+};
+
+/**
+ * 璁剧疆瀛椾綋
+ * @param  {string} family A/B/C
+ */
+printerJobs.prototype.setFont = function (family) {
+  this._enqueue(commands.TEXT_FORMAT['TXT_FONT_' + family.toUpperCase()]);
+  return this;
+};
+
+/**
+ * 璁惧畾瀛椾綋灏哄
+ * @param  {number} width 瀛椾綋瀹藉害 1~2
+ * @param  {number} height 瀛椾綋楂樺害 1~2
+ */
+printerJobs.prototype.setSize = function (width, height) {
+  if (2 >= width && 2 >= height) {
+    this._enqueue(commands.TEXT_FORMAT.TXT_NORMAL);
+    if (2 === width && 2 === height) {
+      this._enqueue(commands.TEXT_FORMAT.TXT_4SQUARE);
+    } else if (1 === width && 2 === height) {
+      this._enqueue(commands.TEXT_FORMAT.TXT_2HEIGHT);
+    } else if (2 === width && 1 === height) {
+      this._enqueue(commands.TEXT_FORMAT.TXT_2WIDTH);
+    }
+  }
+  return this;
+};
+
+/**
+ * 璁惧畾瀛椾綋鏄惁鍔犵矖
+ * @param  {boolean} bold
+ */
+printerJobs.prototype.setBold = function (bold) {
+  if (typeof bold !== 'boolean') {
+    bold = true;
+  }
+  this._enqueue(bold ? commands.TEXT_FORMAT.TXT_BOLD_ON : commands.TEXT_FORMAT.TXT_BOLD_OFF);
+  return this;
+};
+
+/**
+ * 璁惧畾鏄惁寮�鍚笅鍒掔嚎
+ * @param  {boolean} underline
+ */
+printerJobs.prototype.setUnderline = function (underline) {
+  if (typeof underline !== 'boolean') {
+    underline = true;
+  }
+  this._enqueue(underline ? commands.TEXT_FORMAT.TXT_UNDERL_ON : commands.TEXT_FORMAT.TXT_UNDERL_OFF);
+  return this;
+};
+
+/**
+ * 璁剧疆琛岄棿璺濅负 n 鐐硅,榛樿鍊艰闂磋窛鏄� 30 鐐�
+ * @param {number} n 0鈮鈮�255
+ */
+printerJobs.prototype.setLineSpacing = function (n) {
+  if (n === undefined || n === null) {
+    this._enqueue(commands.LINE_SPACING.LS_DEFAULT);
+  } else {
+    this._enqueue(commands.LINE_SPACING.LS_SET);
+    this._enqueue([n]);
+  }
+  return this;
+};
+
+/**
+ * 鎵撳嵃绌鸿
+ * @param {number} n
+ */
+printerJobs.prototype.lineFeed = function (n = 1) {
+  return this.print(new Array(n).fill(commands.EOL).join(''));
+};
+
+/**
+ *  璁剧疆瀛椾綋棰滆壊锛岄渶瑕佹墦鍗版満鏀寔
+ *  @param  {number} color - 0 榛樿棰滆壊榛戣壊 1 绾㈣壊
+ */
+printerJobs.prototype.setColor = function (color) {
+  this._enqueue(commands.COLOR[color === 1 ? 1 : 0]);
+  return this;
+};
+
+/**
+ * https://support.loyverse.com/hardware/printers/use-the-beeper-in-a-escpos-printers
+ * 铚傞福璀︽姤锛岄渶瑕佹墦鍗版満鏀寔
+ * @param  {number} n    铚傞福娆℃暟,1-9
+ * @param  {number} t 铚傞福闀跨煭,1-9
+ */
+printerJobs.prototype.beep = function (n, t) {
+  this._enqueue(commands.BEEP);
+  this._enqueue([n, t]);
+  return this;
+};
+
+/**
+ * 娓呯┖浠诲姟
+ */
+printerJobs.prototype.clear = function () {
+  this._queue = Array.from(commands.HARDWARE.HW_INIT);
+  return this;
+};
+
+/**
+ * 杩斿洖ArrayBuffer
+ */
+printerJobs.prototype.buffer = function () {
+  return new Uint8Array(this._queue).buffer;
+};
+
 module.exports = printerJobs;
\ No newline at end of file

--
Gitblit v1.9.1