location_inventory.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. $(function(){
  2. var focusId;
  3. $('#locationCode').focus();
  4. //如不使用延迟执行, 有时候会无效
  5. setTimeout(function() {
  6. var $warehouseCode = localStorage.getItem('$warehouseCode');
  7. $("#warehouseCode").val($warehouseCode);
  8. $('#locationCode').focus();
  9. }, 1000);
  10. //提交库位号
  11. $('#locationCode').keyup(function (event) {
  12. if (event.keyCode != "13") {return false;}
  13. $("#locationCode").val(trimStr($("#locationCode").val()));
  14. if($('#locationCode').val()!=''){
  15. //播放扫描声音
  16. playSound('../raw/scan.wav');
  17. console.log('locationCode:')
  18. setFocus("barcode")
  19. }
  20. });
  21. //提交商品条码
  22. $('#barcode').keyup(function (event) {
  23. if (event.keyCode != "13") {return false;}
  24. $("#barcode").val(trimStr($("#barcode").val()));
  25. if($("#barcode").val() !='' ){
  26. //播放扫描声音
  27. playSound('../raw/scan.wav');
  28. console.log('barcode:')
  29. submitBarcode();
  30. }
  31. });
  32. });
  33. //提交商品条码
  34. var inventoryMap = {};
  35. var outShelfInventoryId = -1;
  36. function submitBarcode() {
  37. outShelfInventoryId = -1;
  38. var locationCode = $("#locationCode").val();
  39. var barcode = $("#barcode").val();
  40. var msgBody = {};
  41. msgBody.locationCode = locationCode;
  42. msgBody.warehouseCode = $("#warehouseCode").val();
  43. msgBody.barcode = barcode;
  44. //序列化成字符串
  45. var msgBodyStr = JSON.stringify(msgBody)
  46. var appRequest = $appRequest; //复制请求封装对象
  47. appRequest.opType = OP_TYPE_MENU.LOCATION_INVENTORY;
  48. appRequest.msg = msgBodyStr; //msg是消息内容主体
  49. $.ajax({
  50. type: 'POST',
  51. url: $appRequestUrl,
  52. contentType: "application/json; charset=utf-8",
  53. data: JSON.stringify(appRequest),
  54. success: function(appResponse) {
  55. if(!appResponse.success || appResponse.extend.length==0) {
  56. playSound('../raw/error.wav');
  57. mui.toast("该库位和商品条码未查到库存");
  58. return;
  59. }
  60. $("#barcodeShow").val(barcode);
  61. console.log('respnse:'+appResponse)
  62. var listInventory = appResponse.extend;
  63. if(listInventory.length > 1) { //出现多条记录时选择
  64. var listLi = [];
  65. for(var i = 0; i < listInventory.length; i++) {
  66. var inventorySingle = listInventory[i];
  67. inventoryMap[inventorySingle.id] = inventorySingle;
  68. listLi.push('<li class="mui-table-view-cell" onclick="selectInventory(\'' + inventorySingle.id + '\')">批次:' + inventorySingle.batchNo + '; 商品品质:' + inventorySingle.qualityName + '; 溯源:' + inventorySingle.inOrderNo1 + '; 可用数量:' + inventorySingle.qtyAvail + ' </li>');
  69. }
  70. var listLiStr = listLi.join('')
  71. $("#inventoryListDetail").html(listLiStr);
  72. mui("#inventoryListShow").popover('show'); //show hide toggle
  73. return
  74. }
  75. var inventorySingle = listInventory[0];
  76. $("#inOrderNo").val(inventorySingle.inOrderNo1);
  77. $("#batchNo").val(inventorySingle.batchNo)
  78. $("#qualityName").val(inventorySingle.qualityName)
  79. $("#sysQty").val(inventorySingle.qtyAvail)
  80. $("#qtyTotal").val(inventorySingle.qtyTotal)
  81. $("#expiryDate").val(fmtDate(inventorySingle.expiryDate))
  82. outShelfInventoryId = inventorySingle.id;
  83. console.log("outShelfInventoryId:" + outShelfInventoryId)
  84. },
  85. error: function() {
  86. playSound('../raw/error.wav');
  87. mui.toast('网络断开或服务器发生异常');
  88. }
  89. });
  90. }
  91. //选择一个库存
  92. function selectInventory(inventoryId){
  93. outShelfInventoryId = inventoryId;
  94. var inventorySingle=inventoryMap[outShelfInventoryId]
  95. $("#inOrderNo").val(inventorySingle.inOrderNo1);
  96. $("#batchNo").val(inventorySingle.batchNo)
  97. $("#qualityName").val(inventorySingle.qualityName)
  98. $("#sysQty").val(inventorySingle.qtyAvail)
  99. $("#qtyTotal").val(inventorySingle.qtyTotal)
  100. $("#expiryDate").val(fmtDate(inventorySingle.expiryDate))
  101. mui('#inventoryListShow').popover('toggle');
  102. setFocus('qty');
  103. }
  104. //下一个转移任务
  105. function cleanAll() {
  106. $(".allowClear").each(function() {
  107. $(this).val("")
  108. })
  109. $("#locationCode").focus();
  110. }