(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2623da8b"],{"0545":function(e,n,t){},"99fc":function(e,n,t){"use strict";t("0545")},e7a6:function(e,n,t){"use strict";t.r(n);var i=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{staticClass:"app-container"},[t("el-row",{attrs:{gutter:20}},[t("el-col",{attrs:{span:12}},[t("el-card",{staticClass:"box-card"},[t("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[t("span",[e._v("样机标签打印")])]),t("el-form",{ref:"form",attrs:{model:e.form,rules:e.rules,"label-width":"100px"}},[t("el-form-item",{attrs:{label:"组别",prop:"groupName"}},[t("el-select",{staticStyle:{width:"100%"},attrs:{placeholder:"请选择组别"},model:{value:e.form.groupName,callback:function(n){e.$set(e.form,"groupName",n)},expression:"form.groupName"}},e._l(e.groupOptions,(function(e){return t("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1),t("el-form-item",{attrs:{label:"样机编号",prop:"prototypeCode"}},[t("el-input",{staticStyle:{width:"100%"},attrs:{placeholder:"请输入样机编号"},model:{value:e.form.prototypeCode,callback:function(n){e.$set(e.form,"prototypeCode",n)},expression:"form.prototypeCode"}})],1),t("el-form-item",[t("el-button",{attrs:{type:"primary",loading:e.printing},on:{click:e.handlePrint}},[t("i",{staticClass:"el-icon-printer"}),e._v(" 打印标签 ")])],1)],1)],1)],1),t("el-col",{attrs:{span:12}},[t("el-card",{staticClass:"box-card"},[t("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[t("span",[e._v("预览区域")])]),t("div",{staticClass:"print-area"},[t("div",{staticClass:"qrcode-container",attrs:{id:"printSection"}},[t("qrcode-vue",{attrs:{value:e.qrCodeValue,size:300,level:"H"}}),t("div",{staticClass:"info-text"},[t("div",{staticClass:"text-item"},[e._v("组别:"+e._s(e.form.groupName||"-"))]),t("div",{staticClass:"text-item"},[e._v("样机编号:"+e._s(e.form.prototypeCode||"-"))])])],1)])])],1)],1)],1)},o=[],r=t("d7b0"),a=t("d055"),s=t.n(a),d={name:"PrototypeLabelPrinting",components:{QrcodeVue:r["a"]},data(){return{printing:!1,form:{groupName:"",prototypeCode:""},rules:{groupName:[{required:!0,message:"请选择组别",trigger:"change"}],prototypeCode:[{required:!0,message:"请输入样机编号",trigger:"blur"}]},groupOptions:[{value:"研发一组",label:"研发一组"},{value:"研发二组",label:"研发二组"},{value:"研发三组",label:"研发三组研发三组"}]}},computed:{qrCodeValue(){return this.form.groupName&&this.form.prototypeCode?`${this.form.groupName}${this.form.prototypeCode}`:"暂无数据"}},methods:{handlePrint(){this.$refs.form.validate(async e=>{if(e){this.printing=!0;try{const e=await s.a.toDataURL(this.qrCodeValue,{width:800,margin:1,errorCorrectionLevel:"H"}),n=`\n <!DOCTYPE html>\n <html>\n <head>\n <title>样机标签打印-1</title>\n <style>\n @page {\n size: 100mm 100mm;\n margin: 0;\n }\n @media print {\n html, body {\n margin: 0;\n padding: 0;\n height: 100mm;\n page-break-after: avoid;\n page-break-before: avoid;\n }\n }\n .print-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100mm;\n height: 80mm;\n box-sizing: border-box;\n padding: 5mm;\n page-break-inside: avoid;\n }\n .qr-code {\n width: 80mm;\n height: 80mm;\n margin-bottom: 3mm;\n }\n .qr-code img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n }\n .info-text {\n text-align: center;\n font-size: 3mm;\n font-weight: bold;\n line-height: 1.5;\n }\n .info-text div {\n margin: 1mm 0;\n }\n </style>\n </head>\n <body>\n <div class="print-container">\n <div class="qr-code">\n <img src="${e}" alt="QR Code"/>\n </div>\n <div class="info-text">\n <div>组别:${this.form.groupName}</div>\n <div>样机编号:${this.form.prototypeCode}</div>\n <div>原始标签</div>\n </div>\n </div>\n </body>\n </html>\n `,t=`\n <!DOCTYPE html>\n <html>\n <head>\n <title>样机标签打印-2</title>\n <style>\n @page {\n size: 100mm 100mm;\n margin: 0;\n }\n @media print {\n html, body {\n margin: 0;\n padding: 0;\n height: 100mm;\n page-break-after: avoid;\n page-break-before: avoid;\n }\n }\n .print-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100mm;\n height: 80mm;\n box-sizing: border-box;\n padding: 5mm;\n page-break-inside: avoid;\n }\n .qr-code {\n width: 80mm;\n height: 80mm;\n margin-bottom: 3mm;\n }\n .qr-code img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n }\n .info-text {\n text-align: center;\n font-size: 3mm;\n font-weight: bold;\n line-height: 1.5;\n }\n .info-text div {\n margin: 1mm 0;\n color: red;\n }\n </style>\n </head>\n <body>\n <div class="print-container">\n <div class="qr-code">\n <img src="${e}" alt="QR Code"/>\n </div>\n <div class="info-text">\n <div>组别:${this.form.groupName}</div>\n <div>样机编号:${this.form.prototypeCode}</div>\n <div>备用标签</div>\n </div>\n </div>\n </body>\n </html>\n `,i=["Kyocera ECOSYS M4125idn KX","ZDesigner ZT411-300dpi ZPL"],o=[n,t];i.forEach((e,n)=>{var t;if(null!==(t=window.electron)&&void 0!==t&&t.isElectron)window.electron.ipcRenderer.send("silent-print",{content:o[n],printerName:e});else{const e=document.createElement("iframe");e.style.display="none",document.body.appendChild(e);const t=e.contentWindow.document;t.write(o[n]),t.close();const i=t.querySelector("img");i.complete?e.contentWindow.print():i.onload=()=>e.contentWindow.print(),setTimeout(()=>{document.body.removeChild(e)},1e3)}}),this.$message.success("打印任务已发送"),this.printing=!1}catch(n){console.error("打印失败:",n),this.$message.error("打印失败,请重试"),this.printing=!1}}})}}},l=d,m=(t("99fc"),t("2877")),c=Object(m["a"])(l,i,o,!1,null,"08f59b5e",null);n["default"]=c.exports}}]);
|