$(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'); $("#barcode").focus(); } }); //提交商品条码 $('#barcode').keyup(function (event) { if (event.keyCode != "13") {return false;} $("#barcode").val(trimStr($("#barcode").val())); if($("#barcode").val() !='' ){ //播放扫描声音 playSound('../raw/scan.wav'); submitBarcode(); } }); }); function submitBarcode() { var locationCode = $("#locationCode").val(); var barcode = $("#barcode").val(); var msgBody = {}; msgBody.warehouseCode = $("#warehouseCode").val(); msgBody.locationCode = locationCode; msgBody.barcode = barcode; //序列化成字符串 var msgBodyStr = JSON.stringify(msgBody) var appRequest = $appRequest; //复制请求封装对象 appRequest.opType = OP_TYPE_MENU.SKU_INVENTORY; appRequest.msg = msgBodyStr; //msg是消息内容主体 console.info(appRequest); $("#itemList").empty(); $.ajax({ type: 'POST', url: $appRequestUrl, contentType: "application/json; charset=utf-8", data: JSON.stringify(appRequest), success: function(appResponse) { if(!appResponse.success) { playSound('../raw/error.wav'); mui.toast(appResponse.msg); return; } var listInventory = appResponse.extend; if(listInventory.length <=0 ){ mui.toast('没有查到库存'); return; } var customerCode = ''; var sku = ''; var totalQty = 0; for(var i = 0; i < listInventory.length; i++) { var inventorySingle = listInventory[i]; customerCode = inventorySingle.customerCode; sku = inventorySingle.sku; totalQty += inventorySingle.qtyTotal; var tr = "