禁止手动输入,只允许扫描枪
//*****2020-08-05**********条码输入窗口要设置成只能条码枪扫入,禁止键盘和复制粘贴的功能*****************************
var keyDownTime = 0; //按下的时间
var temp = 0; //用于检查相邻两次按键,上一次按键按下的时间
//按键按下记录摁下时间
YAHOO.util.Event.addListener("packSn","keydown",function(e){
var d = new Date(); //
keyDownTime = parseInt(d.getTime()); //按下的时间
});
//键盘释放时记录释放时间
YAHOO.util.Event.addListener("packSn","keyup",function(e){
var d = new Date();
var keyUpTime = d.getTime();//松开的时间
//console.log(keyDownTime);
//console.log(keyUpTime);
//console.log((keyUpTime-keyDownTime));
if((keyUpTime-keyDownTime) > 400 ){ //判断键按下到松开的时间
M.show("error","1禁止手动输入");
YAHOO.util.Dom.get("packSn").value="";
}else if(temp !=0 && (keyDownTime-temp) >400 ){ //按下第一个键和第二个键的时间间隔
//console.log((keyDownTime-temp)+((keyDownTime-temp)>400) );
M.show("error","2禁止手动输入");
YAHOO.util.Dom.get("packSn").value="";
}else{
var theEvent = e || window.event;
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if(code == 13){
//判断回车事件处理业务逻辑//
var scrapStatus=YAHOO.util.Dom.get("scrapStatus").value;
if(scrapStatus!="PCM不良"&&scrapStatus!="ORT"){
var mask = YAHOO.util.Dom.get("maskGroup").value;
PORTAL.page.main.bussiness.getMaskGroup();
YAHOO.util.Dom.get("packSn").focus();
YAHOO.util.Dom.get("packSn").select();
}else{
PORTAL.page.main.bussiness.saveAll();
}
keyDownTime = 0;
temp = 0;
}
}
temp = keyDownTime;
});
//*********结束*********条码输入窗口要设置成只能条码枪扫入,禁止键盘和复制粘贴的功能******************************