{"code":"(window[\"webpackJsonp\"]=window[\"webpackJsonp\"]||[]).push([[\"certificate\"],{1557:function(t,n,e){\"use strict\";e(\"ef80\")},b13e:function(t,n,e){t.exports=e.p+\"img/background.646883a5.jpg\"},c735:function(t,n,e){\"use strict\";e.r(n);var a=function(){var t=this,n=t._self._c;return n(\"div\",{staticClass:\"certificate-container\"},[n(\"div\",{staticClass:\"print-buttons no-print\"},[n(\"button\",{staticClass:\"print-btn\",on:{click:t.printCertificate}},[t._v(\"打印证书\")]),n(\"button\",{staticClass:\"print-btn download-btn\",on:{click:t.downloadCertificate}},[t._v(\"下载证书\")])]),n(\"div\",{staticClass:\"containerQuali\",style:{backgroundImage:\"url(\".concat(t.backgroundImageUrl,\")\")},attrs:{id:\"certificate-content\"}},[n(\"div\",{staticClass:\"left\"},[n(\"div\",{staticClass:\"title\"},[t._v(\"结业证书\")]),n(\"div\",{staticClass:\"headphoto\"},[n(\"img\",{attrs:{src:t.trainCertificateInfo.certificatePhoto,alt:\"证书照片\"}})]),n(\"div\",{staticClass:\"infolist\"},[n(\"div\",{staticClass:\"infolistul\"},[n(\"div\",{staticClass:\"infolistspan info4\"},[n(\"span\",{staticClass:\"infostrong\"},[t._v(\"证书编号: \")]),n(\"span\",{staticClass:\"infoem\"},[t._v(t._s(t.trainCertificateInfo.certificateNo||\"\"))])])])])]),n(\"div\",{staticClass:\"right\"},[n(\"div\",{staticClass:\"nr1\",staticStyle:{\"margin-bottom\":\"10px\",\"margin-left\":\"0\"}},[n(\"span\",{staticClass:\"nrname\",staticStyle:{\"margin-left\":\"0\"}},[t._v(\"   \"+t._s(t.trainCertificateInfo.personName||\"\")+\"   \")]),t._v(\":\\n \")]),n(\"div\",{staticClass:\"nr2\",staticStyle:{\"text-indent\":\"40px\"}},[t._v(\"于   \"),n(\"span\",[t._v(t._s(t.trainCertificateInfo.startTime||\"\")+\"\\n \")]),t._v(\"   至    \"),n(\"span\",[t._v(t._s(t.trainCertificateInfo.endTime||\"\"))]),t._v(\",\\n 参加  \"),n(\"span\",[t._v(t._s(t.trainCertificateInfo.certificateType||\"\"))]),t._v(\"  保安员技能培训,完成培训计划规定的所有课程,成绩合格,准予结业。\")]),n(\"div\",{staticClass:\"nr4\"},[n(\"span\",{staticClass:\"nrfzDate\"},[t._v(t._s(t.trainCertificateInfo.trainName||\"\"))])]),n(\"div\",{staticClass:\"nr5\"},[n(\"span\",{staticClass:\"nrfztitle\"},[t._v(\"颁发日期:\")]),n(\"span\",{staticClass:\"nrfzDate\"},[t._v(t._s(t.trainCertificateInfo.certificateDate||\"\"))])])])])])},i=[],o=(e(\"ac6a\"),e(\"96cf\"),e(\"3b8d\")),r=e(\"b13e\"),s=e.n(r),l={data:function(){return{info:{userInfo:{credential:{}}},trainCertificateInfo:{},isDownloading:!1,backgroundImageUrl:s.a}},mounted:function(){var t=this.$route.query;this.trainCertificateInfo=t},methods:{printCertificate:function(){setTimeout((function(){window.print()}),500)},loadHtml2Canvas:function(){var t=Object(o[\"a\"])(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(window.html2canvas){t.next=6;break}return n=document.createElement(\"script\"),n.src=\"https://html2canvas.hertzen.com/dist/html2canvas.min.js\",n.async=!0,document.body.appendChild(n),t.abrupt(\"return\",new Promise((function(t){n.onload=function(){return t(window.html2canvas)}})));case 6:return t.abrupt(\"return\",Promise.resolve(window.html2canvas));case 7:case\"end\":return t.stop()}}),t)})));function n(){return t.apply(this,arguments)}return n}(),loadJsPDF:function(){var t=Object(o[\"a\"])(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(window.jspdf){t.next=6;break}return n=document.createElement(\"script\"),n.src=\"https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js\",n.async=!0,document.body.appendChild(n),t.abrupt(\"return\",new Promise((function(t){n.onload=function(){return t(window.jspdf)}})));case 6:return t.abrupt(\"return\",Promise.resolve(window.jspdf));case 7:case\"end\":return t.stop()}}),t)})));function n(){return t.apply(this,arguments)}return n}(),preloadImage:function(t){return new Promise((function(n,e){var a=new Image;a.onload=function(){return n(a)},a.onerror=function(){return e(new Error(\"Failed to load image: \".concat(t)))},a.src=t}))},downloadCertificate:function(){var t=Object(o[\"a\"])(regeneratorRuntime.mark((function t(){var n,e,a,i,o,r,s,l,d,c,p,A,f,C,g,x,u,m,h,b,v;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(!this.isDownloading){t.next=2;break}return t.abrupt(\"return\");case 2:return this.isDownloading=!0,t.prev=3,this.$message?this.$message({message:\"正在生成PDF,请稍候...\",type:\"info\",duration:5e3,showClose:!1}):alert(\"正在生成PDF,请稍候...\"),t.next=7,this.loadHtml2Canvas();case 7:return t.next=9,this.loadJsPDF();case 9:return n=document.getElementById(\"certificate-content\"),e=this.backgroundImageUrl,t.prev=11,t.next=14,this.preloadImage(e);case 14:if(!this.trainCertificateInfo.certificatePhoto){t.next=17;break}return t.next=17,this.preloadImage(this.trainCertificateInfo.certificatePhoto);case 17:t.next=21;break;case 19:t.prev=19,t.t0=t[\"catch\"](11);case 21:return a=document.createElement(\"div\"),a.style.position=\"absolute\",a.style.left=\"-9999px\",a.style.top=\"-9999px\",document.body.appendChild(a),i=n.cloneNode(!0),a.appendChild(i),this.copyComputedStyles(n,i),i.style.backgroundImage=\"url(\".concat(e,\")\"),i.style.backgroundSize=\"cover\",i.style.backgroundPosition=\"center\",i.style.backgroundRepeat=\"no-repeat\",i.style.width=n.offsetWidth+\"px\",i.style.height=n.offsetHeight+\"px\",o=i.querySelector(\".headphoto\"),o&&(o.style.display=\"flex\",o.style.justifyContent=\"center\",o.style.alignItems=\"center\",o.style.margin=\"0 auto 80px\",r=o.querySelector(\"img\"),r&&(r.style.width=\"100%\",r.style.height=\"100%\",r.style.objectFit=\"fill\",r.style.display=\"block\")),s=i.querySelectorAll(\"span, div\"),s.forEach((function(t){var n=window.getComputedStyle(t);\"rgba(0, 0, 0, 0)\"!==n.color&&\"transparent\"!==n.color||(t.style.color=\"#000000\"),n.fontFamily&&(t.style.fontFamily=n.fontFamily)})),t.next=41,html2canvas(i,{scale:3,useCORS:!0,backgroundColor:null,logging:!1,allowTaint:!0,imageTimeout:0,onclone:function(t,n){var e=n.querySelector(\".headphoto\");if(e){e.style.display=\"flex\",e.style.justifyContent=\"center\",e.style.alignItems=\"center\",e.style.margin=\"0 auto 80px\";var a=e.querySelector(\"img\");a&&(a.style.width=\"100%\",a.style.height=\"100%\",a.style.objectFit=\"fill\",a.style.display=\"block\")}}});case 41:l=t.sent,document.body.removeChild(a),d=n.offsetWidth,c=n.offsetHeight,p=96*window.devicePixelRatio,A=25.4,f=d/p*A,C=c/p*A,g=210,x=1.2,f>g&&(u=g/f,f=g,C*=u),f*=x,C*=x,m=f/C,h=l.toDataURL(\"image/jpeg\",1),b=window.jspdf.jsPDF,v=new b({orientation:m>1?\"l\":\"p\",unit:\"mm\",format:[f,C],compress:!0,hotfixes:[\"px_scaling\"]}),v.addImage(h,\"JPEG\",0,0,f,C,void 0,\"FAST\"),v.save(\"证书_\".concat(this.trainCertificateInfo.personName||\"未命名\",\".pdf\")),t.next=65;break;case 62:t.prev=62,t.t1=t[\"catch\"](3),alert(\"下载证书失败,请稍后重试。错误详情: \"+t.t1.message);case 65:return t.prev=65,this.isDownloading=!1,t.finish(65);case 68:case\"end\":return t.stop()}}),t,this,[[3,62,65,68],[11,19]])})));function n(){return t.apply(this,arguments)}return n}(),saveAsImage:function(){var t=Object(o[\"a\"])(regeneratorRuntime.mark((function t(){var n,e,a,i,o,r,s,l,d,c;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(!this.isDownloading){t.next=2;break}return t.abrupt(\"return\");case 2:return this.isDownloading=!0,t.prev=3,this.$message?this.$message({message:\"正在生成图片,请稍候...\",type:\"info\",duration:5e3,showClose:!1}):alert(\"正在生成图片,请稍候...\"),t.next=7,this.loadHtml2Canvas();case 7:return n=document.getElementById(\"certificate-content\"),e=this.backgroundImageUrl,t.prev=9,t.next=12,this.preloadImage(e);case 12:if(!this.trainCertificateInfo.certificatePhoto){t.next=15;break}return t.next=15,this.preloadImage(this.trainCertificateInfo.certificatePhoto);case 15:t.next=19;break;case 17:t.prev=17,t.t0=t[\"catch\"](9);case 19:return a=document.createElement(\"div\"),a.style.position=\"absolute\",a.style.left=\"-9999px\",a.style.top=\"-9999px\",document.body.appendChild(a),i=n.cloneNode(!0),a.appendChild(i),this.copyComputedStyles(n,i),i.style.backgroundImage=\"url(\".concat(e,\")\"),i.style.backgroundSize=\"cover\",i.style.backgroundPosition=\"center\",i.style.backgroundRepeat=\"no-repeat\",i.style.width=n.offsetWidth+\"px\",i.style.height=n.offsetHeight+\"px\",o=i.querySelector(\".headphoto\"),o&&(o.style.display=\"flex\",o.style.justifyContent=\"center\",o.style.alignItems=\"center\",o.style.margin=\"0 auto 80px\",r=o.querySelector(\"img\"),r&&(r.style.width=\"100%\",r.style.height=\"100%\",r.style.objectFit=\"fill\",r.style.display=\"block\")),s=i.querySelectorAll(\"span, div\"),s.forEach((function(t){var n=window.getComputedStyle(t);\"rgba(0, 0, 0, 0)\"!==n.color&&\"transparent\"!==n.color||(t.style.color=\"#000000\"),n.fontFamily&&(t.style.fontFamily=n.fontFamily)})),t.next=39,html2canvas(i,{scale:3,useCORS:!0,backgroundColor:null,logging:!1,allowTaint:!0,imageTimeout:0,onclone:function(t,n){var e=n.querySelector(\".headphoto\");if(e){e.style.display=\"flex\",e.style.justifyContent=\"center\",e.style.alignItems=\"center\",e.style.margin=\"0 auto 80px\";var a=e.querySelector(\"img\");a&&(a.style.width=\"100%\",a.style.height=\"100%\",a.style.objectFit=\"fill\",a.style.display=\"block\")}}});case 39:l=t.sent,document.body.removeChild(a),d=l.toDataURL(\"image/png\",1),c=document.createElement(\"a\"),c.href=d,c.download=\"证书_\".concat(this.trainCertificateInfo.personName||\"未命名\",\".png\"),document.body.appendChild(c),c.click(),document.body.removeChild(c),this.$message?this.$message({message:\"图片已保存\",type:\"success\",duration:3e3}):alert(\"图片已保存\"),t.next=54;break;case 51:t.prev=51,t.t1=t[\"catch\"](3),alert(\"保存图片失败,请稍后重试。错误详情: \"+t.t1.message);case 54:return t.prev=54,this.isDownloading=!1,t.finish(54);case 57:case\"end\":return t.stop()}}),t,this,[[3,51,54,57],[9,17]])})));function n(){return t.apply(this,arguments)}return n}(),copyComputedStyles:function(t,n){var e=function(t,n){for(var a=window.getComputedStyle(t),i=0;i