(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 \n \n \n 样机标签打印-1\n \n \n \n \n \n \n `,t=`\n \n \n \n 样机标签打印-2\n \n \n \n \n \n \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}}]);