Index: ssts-web/src/main/webapp/disinfectsystem/print/print.js =================================================================== diff -u -r30223 -r30344 --- ssts-web/src/main/webapp/disinfectsystem/print/print.js (.../print.js) (revision 30223) +++ ssts-web/src/main/webapp/disinfectsystem/print/print.js (.../print.js) (revision 30344) @@ -4204,14 +4204,63 @@ return newY; } +var xmlobj; //定义XMLHttpRequest对象 +function CreateXMLHttpRequest(){ + if(window.ActiveXObject){ + try { + xmlobj = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlobj = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlobj = false; + } + } + }else if(window.XMLHttpRequest){ + xmlobj = new XMLHttpRequest(); + } +} + +function isIE() { + if (!!window.ActiveXObject || "ActiveXObject" in window){ + return true; + }else{ + return false; + } +} + function getPrintBarcodeURL(obj){ var barcode = obj.barcode; - var url = WWWROOT + "/disinfectSystem/printBarcodeAction!printBarcodeImage.do?barcode=" + barcode+"&codeType="+getBarcodeCodeType(obj.codeType); - if (typeof(obj.barcodeImgWidth) != "undefined" && typeof(obj.barcodeImgWidth) != "undefined"){ - url += "&barcodeImgWidth=" + sstsConfig.barcodeImgWidth + "&barcodeImgHeight=" + sstsConfig.barcodeImgHeight; - } + if(isIE()){ + var url = WWWROOT + "/disinfectSystem/printBarcodeAction!printBarcodeImage.do?barcode=" + barcode+"&codeType="+getBarcodeCodeType(obj.codeType); + if (typeof(obj.barcodeImgWidth) != "undefined" && typeof(obj.barcodeImgWidth) != "undefined"){ + url += "&barcodeImgWidth=" + sstsConfig.barcodeImgWidth + "&barcodeImgHeight=" + sstsConfig.barcodeImgHeight; + } - return url; + return url; + }else { + CreateXMLHttpRequest() + var responseText; + var url = WWWROOT + "/disinfectSystem/printBarcodeAction!printBarcodeImage.do"; + var parm = "barcode="+barcode+"&codeType="+getBarcodeCodeType(obj.codeType)+"&returnFormat=base64"; + if (typeof(obj.barcodeImgWidth) != "undefined" && typeof(obj.barcodeImgWidth) != "undefined"){ + parm += "&barcodeImgWidth=" + sstsConfig.barcodeImgWidth + "&barcodeImgHeight=" + sstsConfig.barcodeImgHeight; + } + xmlobj.open("POST", url, false); + xmlobj.setRequestHeader("cache-control","no-cache"); + xmlobj.setRequestHeader("contentType","text/html;charset=uft-8") + xmlobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;"); + xmlobj.onreadystatechange = function(res){ + var xmlhttp = res.currentTarget; + if(xmlhttp.readyState==4){ + if(xmlhttp.status==200){ + responseText = xmlhttp.responseText; + } + } + }; + xmlobj.send(parm); + return 'data:image/jpg;base64,'+responseText; + } } function getBarcodeCodeType(codeType){ if(codeType){