$(function(){ var focusId; $("input").focus(function(){ //记住焦点位置 focusId = this.id; //this.scrollIntoView(true);//回到顶部 //window.setTimeout("myScrollIntoView()",100); }); //如不使用延迟执行, 有时候会无效 setTimeout(function() { var $warehouseCode = localStorage.getItem('$warehouseCode'); $("#warehouseCode").val($warehouseCode); $('#outShelfLocationCode').focus(); }, 1000); //当失去焦点按回车时,焦点回到之前焦点位置 $(window).keydown(function(event){ if((event.keyCode==13)) { if(document.activeElement.id == null || document.activeElement.id ==''){ //回到上次焦点地方 //$("#"+focusId).focus(); } } }); //提交下架库位 $('#outShelfLocationCode').keyup(function (event) { if (event.keyCode != "13") {return false;} $("#outShelfLocationCode").val(trimStr($("#outShelfLocationCode").val())); if($('#outShelfLocationCode').val()!=''){ //播放扫描声音 playSound('../raw/scan.wav'); submitOutShelfLocationCode(); } }); //提交商品条码 $('#barcode').keyup(function (event) { console.log("barcode:"+event.keyCode) if (event.keyCode != "13") {return false;} console.log("barcode") $("#barcode").val(trimStr($("#barcode").val())); if($("#barcode").val() !='' ){ //播放扫描声音 playSound('../raw/scan.wav'); submitBarcode(); } }); //输入转移数量 $('#qty').keyup(function (event) { if (event.keyCode != "13") {return false;} $("#qty").val(trimStr($("#qty").val())); if($("#qty").val() =='' || $("#qty").val() == 0){ return; } if(isNaN($("#qty").val())){ playSound('../raw/error.wav'); mui.toast($("#qty").val()+'不是一个数字'); return; } if(parseInt($("#sysQty").val()) < parseInt($("#qty").val())){ playSound('../raw/error.wav'); mui.toast('转移数量不能大于可用数量'); return; } if(parseInt($("#qty").val())<=0){ playSound('../raw/error.wav'); mui.toast('转移数量不能小于等于0'); return; } playSound('../raw/scan.wav'); //输入数量回车,光标到上架库位 setFocus('onShelfLocationCode') }); //提交上架库位 $('#onShelfLocationCode').keyup(function (event) { if (event.keyCode != "13") {return false;} $("#onShelfLocationCode").val(trimStr($("#onShelfLocationCode").val())); if($("#onShelfLocationCode").val() !='' ){ submitInventoryMv(); } }); }); //提交下架库位 function submitOutShelfLocationCode(){ var outShelfLocationCode=$("#outShelfLocationCode").val(); var msgBody = {}; msgBody.outShelfLocationCode=outShelfLocationCode; msgBody.warehouseCode=$("#warehouseCode").val(); //序列化成字符串 var msgBodyStr=JSON.stringify(msgBody) var appRequest = $appRequest;//复制请求封装对象 appRequest.opType = OP_TYPE_MENU.INVENTORY_RANDOM_MV_1; 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){ playSound('../raw/error.wav'); mui.toast(appResponse.msg); return; } mui.toast(appResponse.msg); setFocus('barcode'); }, error: function () { playSound('../raw/error.wav'); mui.toast('网络断开或服务器发生异常'); } }); } //提交商品条码 var inventoryMap = {}; var outShelfInventoryId = -1; function submitBarcode() { outShelfInventoryId = -1; var outShelfLocationCode = $("#outShelfLocationCode").val(); var barcode = $("#barcode").val(); var msgBody = {}; msgBody.outShelfLocationCode = outShelfLocationCode; msgBody.warehouseCode = $("#warehouseCode").val(); msgBody.barcode = barcode; //序列化成字符串 var msgBodyStr = JSON.stringify(msgBody) var appRequest = $appRequest; //复制请求封装对象 appRequest.opType = OP_TYPE_MENU.INVENTORY_RANDOM_MV_2; appRequest.msg = msgBodyStr; //msg是消息内容主体 console.log("$appRequestUrl:"+$appRequestUrl) $.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; } $("#barcodeShow").val(barcode); 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('