From 5a7058c0360f5c459e7133df6edacbac4a2eebc5 Mon Sep 17 00:00:00 2001 From: yanran200830 Date: Mon, 21 Oct 2024 18:01:56 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91temu?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/print-lock.css | 6 +++ public/index.html | 63 ++++++++++++++++++++------ src/components/print/Print.vue | 12 ++++- src/components/print/customProvider.js | 27 +++++++---- 4 files changed, 82 insertions(+), 26 deletions(-) diff --git a/public/css/print-lock.css b/public/css/print-lock.css index aede018..fb55568 100644 --- a/public/css/print-lock.css +++ b/public/css/print-lock.css @@ -347,3 +347,9 @@ table.hiprint-printElement-tableTarget { text-align: left; clear: both; } + +.temuBarCode { + display: flex; + flex-direction: column; + padding: 1pt 3pt; +} diff --git a/public/index.html b/public/index.html index 6697364..f3256a9 100644 --- a/public/index.html +++ b/public/index.html @@ -1,18 +1,51 @@ - - - - - - - TEMU助手 - - - -
- - + + + + + + + + TEMU助手 + + + + + +
+ + + diff --git a/src/components/print/Print.vue b/src/components/print/Print.vue index 8f176c8..3b63a5d 100644 --- a/src/components/print/Print.vue +++ b/src/components/print/Print.vue @@ -210,7 +210,7 @@ // eslint-disable-next-line no-undef $('#hiprint-printTemplate').empty() this.hiprintTemplate = newHiprintPrintTemplate('temulables', { - template: template, + template: {}, settingContainer: '#PrintElementOptionSetting', fields: [{ field: 'html', @@ -281,8 +281,9 @@ elementToString(el) { const node = document.createElement('div') - node.appendChild(el) + node.innerHTML = el.html() + document.querySelector('body').appendChild(node) return node.innerHTML }, @@ -295,6 +296,7 @@ getHtml() { const list = this.labels + console.log(printData) this.html = this.elementToString(this.hiprintTemplate.getHtml(printData)) console.log(this.html) @@ -316,6 +318,12 @@ .print { height: 100%; + .temuBarCode { + display: flex; + flex-direction: column; + padding: 1pt 3pt; + } + .print-wrapper { display: flex; height: calc(100vh - 180px); diff --git a/src/components/print/customProvider.js b/src/components/print/customProvider.js index 144a879..d29ce14 100644 --- a/src/components/print/customProvider.js +++ b/src/components/print/customProvider.js @@ -11,16 +11,22 @@ export const customProvider = function (options) { type: 'html', formatter: function (title, options, templateData) { console.log(options, templateData) + var elId = 'barCode-' + new Date().getTime() + $('body').append('') - setTimeout(() => { - // eslint-disable-next-line no-undef - JsBarcode("#barcode", "1234567890", { - format: "code128", // 条形码类型 - width: 2, // 条的宽度 - height: 50, // 条形码的高度 - }); + console.log(options.width * 0.8) + JsBarcode('#'+ elId, '1234567890', { + format: "code128", + width: 2, + height: options.height * 0.6, + margin: 0, + displayValue: false }) - return ` + + const codeHtml = $(`#${elId}`).html() + $(`#${elId}`).remove() + + var html = `
(AA+AAA)*20PCS
@@ -28,7 +34,9 @@ export const customProvider = function (options) {
- + + ${codeHtml} +
@@ -37,6 +45,7 @@ export const customProvider = function (options) {
` + return html }, options: { width: 316,