From 3f3638f3d01f66fc9a0c2f22e59b39ddbabfc00a Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Wed, 21 Jun 2023 16:50:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/print.html | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/public/print.html b/public/print.html index 6b82190..9d0265a 100644 --- a/public/print.html +++ b/public/print.html @@ -84,7 +84,10 @@ foreground: '#000000', }); var canvas = qrcode.find('canvas').get(0); - var img = new Image(); + var img = new Image(); + var str = decodeURI(decodeURI(printObji['zichanmingcheng'])) + var wzlx = decodeURI(decodeURI(printObji['wuzileixing'])) + var zcbm = decodeURI(decodeURI(printObji['wuzibianma'])) img.src = canvas.toDataURL('image/png'); img.onload = function() { canvas.width = canvaswidth; @@ -98,10 +101,14 @@ ctx.textAlign = 'left'; //文字描述 ctx.fillText("苏州河道管理处", 100, 30); - ctx.fillText("物资编码:" + decodeURI(decodeURI(printObji['wuzibianma'])), qrcodeleft + 120, 65); - ctx.fillText("资产名称:" + decodeURI(decodeURI(printObji['zichanmingcheng'])), qrcodeleft + 120, 95); - ctx.fillText("物资类型:" + decodeURI(decodeURI(printObji['wuzileixing'])), qrcodeleft + 120, 125); - // ctx.fillText("入库数量:" + printObji['rukushuliang'], qrcodeleft + 140, 155); + ctx.fillText("物资编码:" + zcbm, qrcodeleft + 120, 65); + ctx.fillText("物资类型:" + wzlx, qrcodeleft + 120, 155); + if(str.length<=4){ + ctx.fillText("资产名称:"+str, qrcodeleft + 120, 95); + }else{ + ctx.fillText("资产名称:"+str.substring(0,4), qrcodeleft + 120, 95); + ctx.fillText(str.substring(4,str.length), qrcodeleft + 120, 125); + } ctx.drawImage(img, qrcodeleft, qrcodetop); var data = canvas.toDataURL('image/png', 1); var imgOk = new Image();