From 57ee51bf0bbfb69255aeece4557347de6e46486e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=82=E7=B3=96?= Date: Thu, 24 Jul 2025 10:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- klp-ui/src/views/wms/stockIo/index.vue | 2 +- .../src/views/wms/stockIo/panels/barcode.vue | 131 +++++++++++------- 2 files changed, 85 insertions(+), 48 deletions(-) diff --git a/klp-ui/src/views/wms/stockIo/index.vue b/klp-ui/src/views/wms/stockIo/index.vue index 29060cb2..c5373cfe 100644 --- a/klp-ui/src/views/wms/stockIo/index.vue +++ b/klp-ui/src/views/wms/stockIo/index.vue @@ -209,7 +209,7 @@ diff --git a/klp-ui/src/views/wms/stockIo/panels/barcode.vue b/klp-ui/src/views/wms/stockIo/panels/barcode.vue index c50bf942..b12002b7 100644 --- a/klp-ui/src/views/wms/stockIo/panels/barcode.vue +++ b/klp-ui/src/views/wms/stockIo/panels/barcode.vue @@ -2,12 +2,7 @@
-
- 缩放: - - {{ Math.round(previewScale*100) }}% -
-
+
@@ -32,29 +27,44 @@ + + + + + + + + + + + + + + + + + 纵向 + 横向 + + 打印 - - - - - - - - - - - +
+
条码 {{ idx + 1 }}
+ + + + + + + + + +
@@ -80,7 +90,11 @@ export default { barcodeHeight: 180, // 二维码建议宽高一致 barcodeConfigs: [], // [{code, count, textTpl}] previewScale: 1, // 预览缩放比例 - activeTab: 'layout' + activeTab: 'layout', + paperSize: 'A4', + paperOrientation: 'portrait', + customPaperWidth: 210, + customPaperHeight: 297 }; }, computed: { @@ -125,26 +139,16 @@ export default { return rows; }, iframeStyle() { + const { width, height } = this.getPaperPx(); return { - transform: `scale(${this.previewScale})`, - 'transform-origin': 'top left', - width: '794px', - height: 'auto', - overflow: 'hidden', + width: width + 'px', + minHeight: height + 'px', + height: height + 'px', background: '#fff', border: 'none', - display: 'block' - }; - }, - iframeWrapperStyle() { - return { - width: `${794 * this.previewScale}px`, - minHeight: `${1123 * this.previewScale}px`, - overflow: 'auto', - background: '#f8f8f8', - padding: '16px 0', - display: 'flex', - justifyContent: 'center' + display: 'block', + margin: 0, + padding: 0 }; } }, @@ -171,7 +175,11 @@ export default { perRow() { this.$nextTick(this.renderPreviewIframe); }, barcodeWidth() { this.$nextTick(this.renderPreviewIframe); }, barcodeHeight() { this.$nextTick(this.renderPreviewIframe); }, - previewScale() {} + previewScale() { this.$nextTick(this.renderPreviewIframe); }, + paperSize() { this.$nextTick(this.renderPreviewIframe); }, + paperOrientation() { this.$nextTick(this.renderPreviewIframe); }, + customPaperWidth() { this.$nextTick(this.renderPreviewIframe); }, + customPaperHeight() { this.$nextTick(this.renderPreviewIframe); } }, methods: { getBarcodeId(row, col) { @@ -188,14 +196,36 @@ export default { } return code; }, + getPaperPx() { + // mm to px, 1mm ≈ 3.78px + let width, height; + if (this.paperSize === 'A4') { + width = 210 * 3.78; + height = 297 * 3.78; + } else if (this.paperSize === 'A5') { + width = 148 * 3.78; + height = 210 * 3.78; + } else if (this.paperSize === 'A6') { + width = 105 * 3.78; + height = 148 * 3.78; + } else { + width = this.customPaperWidth * 3.78; + height = this.customPaperHeight * 3.78; + } + if (this.paperOrientation === 'landscape') { + return { width: height, height: width }; + } + return { width, height }; + }, getPrintHtml() { + const { width, height } = this.getPaperPx(); let html = ` 打印二维码