Commit c1f871c8 authored by dragondean@qq.com's avatar dragondean@qq.com

打印标签前端生成二维码

parent b147953f
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
style="width: 80mm; margin: 0 auto;" :id="'order-print-tag' + item.num" style="width: 80mm; margin: 0 auto;" :id="'order-print-tag' + item.num"
:style="{display: index == 0 ? 'block':'none' }" :style="{display: index == 0 ? 'block':'none' }"
:key="item.num"> :key="item.num">
<div style="float: left; width: 28mm; border-bottom: 0.2mm solid #333; border-right: 0.2mm solid #333; " > <div style="float: left; text-align: center; width: 28mm; border-bottom: 0.2mm solid #333; border-right: 0.2mm solid #333; " >
<img class="qrcode" src="" :alt="item.url" style="width: 26mm" /> <img class="qrcode" src="" :alt="item.url" style="width: 26mm" />
<p class="tag" style=" text-align: center; height: 5mm; font-size: 3mm; -webkit-margin-before: 0em; -webkit-margin-after: 0em; margin-top: 0mm; " >{{item.tag}}</p> <p class="tag" style=" text-align: center; height: 5mm; font-size: 3mm; -webkit-margin-before: 0em; -webkit-margin-after: 0em; margin-top: 0mm; " >{{item.tag}}</p>
<p style="margin-top: -1mm; text-align: center"> <p style="margin-top: -1mm; text-align: center">
...@@ -144,7 +144,7 @@ export default { ...@@ -144,7 +144,7 @@ export default {
this.$nextTick(async () => { this.$nextTick(async () => {
const first = document.getElementsByClassName('order-print-tag-item')[0] const first = document.getElementsByClassName('order-print-tag-item')[0]
const tag = first.getElementsByClassName('tag')[0].innerText const tag = first.getElementsByClassName('tag')[0].innerText
const qrcode = await QRCode.toDataURL(tag) const qrcode = await QRCode.toDataURL(tag, {margin: 1})
first.getElementsByClassName('qrcode')[0].setAttribute("src", qrcode) first.getElementsByClassName('qrcode')[0].setAttribute("src", qrcode)
}) })
}) })
...@@ -162,15 +162,13 @@ export default { ...@@ -162,15 +162,13 @@ export default {
LODOP.SET_PRINT_STYLE("FontSize",18); LODOP.SET_PRINT_STYLE("FontSize",18);
LODOP.SET_PRINT_STYLE("Bold",1); LODOP.SET_PRINT_STYLE("Bold",1);
// LODOP.ADD_PRINT_TEXT(50,231,260,39,"打印页面部分内容"); // LODOP.ADD_PRINT_TEXT(50,231,260,39,"打印页面部分内容");
console.log({items})
LODOP.SET_PRINT_PAGESIZE(0, 800, 600, "TAG"); LODOP.SET_PRINT_PAGESIZE(0, 800, 600, "TAG");
let i = 0; let i = 0;
for(let item of items){ for(let item of items){
const tag = item.getElementsByClassName('tag')[0].innerText const tag = item.getElementsByClassName('tag')[0].innerText
const qrcode = await QRCode.toDataURL(tag) const qrcode = await QRCode.toDataURL(tag, {margin: 1})
item.getElementsByClassName('qrcode')[0].setAttribute("src", qrcode) item.getElementsByClassName('qrcode')[0].setAttribute("src", qrcode)
LODOP.ADD_PRINT_HTM("2mm",0,800,600, item.innerHTML); LODOP.ADD_PRINT_HTM("2mm",0,800,600, item.innerHTML);
console.log('item.innerHTML', item.innerHTML)
if(i < items.length){ if(i < items.length){
LODOP.NewPage() LODOP.NewPage()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment