$(function(){ var focusId; $('#locationCode').focus(); //如不使用延迟执行, 有时候会无效 setTimeout(function() { var $warehouseCode = localStorage.getItem('$warehouseCode'); $("#warehouseCode").val($warehouseCode); $('#locationCode').focus(); }, 1000); //提交库位号 $('#locationCode').keyup(function (event) { if (event.keyCode != "13") {return false;} $("#locationCode").val(trimStr($("#locationCode").val())); if($('#locationCode').val()!=''){ //播放扫描声音 playSound('../raw/scan.wav'); console.log('locationCode:') setFocus("barcode") } }); //提交商品条码 $('#barcode').keyup(function (event) { if (event.keyCode != "13") {return false;} $("#barcode").val(trimStr($("#barcode").val())); if($("#barcode").val() !='' ){ //播放扫描声音 playSound('../raw/scan.wav'); console.log('barcode:') submitBarcode(); } }); }); //提交商品条码 var inventoryMap = {}; var outShelfInventoryId = -1; function submitBarcode() { outShelfInventoryId = -1; var locationCode = $("#locationCode").val(); var barcode = $("#barcode").val(); var msgBody = {}; msgBody.locationCode = locationCode; msgBody.warehouseCode = $("#warehouseCode").val(); msgBody.barcode = barcode; //序列化成字符串 var msgBodyStr = JSON.stringify(msgBody) var appRequest = $appRequest; //复制请求封装对象 appRequest.opType = OP_TYPE_MENU.LOCATION_INVENTORY; appRequest.msg = msgBodyStr; //msg是消息内容主体 $.ajax({ type: 'POST', url: $appRequestUrl, contentType: "application/json; charset=utf-8", data: JSON.stringify(appRequest), success: function(appResponse) { if(!appResponse.success || appResponse.extend.length==0) { playSound('../raw/error.wav'); mui.toast("该库位和商品条码未查到库存"); return; } $("#barcodeShow").val(barcode); console.log('respnse:'+appResponse) var listInventory = appResponse.extend; if(listInventory.length > 1) { //出现多条记录时选择 var listLi = []; for(var i = 0; i < listInventory.length; i++) { var inventorySingle = listInventory[i]; inventoryMap[inventorySingle.id] = inventorySingle; listLi.push('