sku_inventory.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. $("#barcode").focus();
  18. }
  19. });
  20. //提交商品条码
  21. $('#barcode').keyup(function (event) {
  22. if (event.keyCode != "13") {return false;}
  23. $("#barcode").val(trimStr($("#barcode").val()));
  24. if($("#barcode").val() !='' ){
  25. //播放扫描声音
  26. playSound('../raw/scan.wav');
  27. submitBarcode();
  28. }
  29. });
  30. });
  31. function submitBarcode() {
  32. var locationCode = $("#locationCode").val();
  33. var barcode = $("#barcode").val();
  34. var msgBody = {};
  35. msgBody.warehouseCode = $("#warehouseCode").val();
  36. msgBody.locationCode = locationCode;
  37. msgBody.barcode = barcode;
  38. //序列化成字符串
  39. var msgBodyStr = JSON.stringify(msgBody)
  40. var appRequest = $appRequest; //复制请求封装对象
  41. appRequest.opType = OP_TYPE_MENU.SKU_INVENTORY;
  42. appRequest.msg = msgBodyStr; //msg是消息内容主体
  43. console.info(appRequest);
  44. $("#itemList").empty();
  45. $.ajax({
  46. type: 'POST',
  47. url: $appRequestUrl,
  48. contentType: "application/json; charset=utf-8",
  49. data: JSON.stringify(appRequest),
  50. success: function(appResponse) {
  51. if(!appResponse.success) {
  52. playSound('../raw/error.wav');
  53. mui.toast(appResponse.msg);
  54. return;
  55. }
  56. var listInventory = appResponse.extend;
  57. if(listInventory.length <=0 ){
  58. mui.toast('没有查到库存');
  59. return;
  60. }
  61. var customerCode = '';
  62. var sku = '';
  63. var totalQty = 0;
  64. for(var i = 0; i < listInventory.length; i++) {
  65. var inventorySingle = listInventory[i];
  66. customerCode = inventorySingle.customerCode;
  67. sku = inventorySingle.sku;
  68. totalQty += inventorySingle.qtyTotal;
  69. var tr = "<tr id='item_"+inventorySingle.id+"'>";
  70. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+inventorySingle.locationCode+"</div></th>";
  71. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+inventorySingle.barcode+"</div></th>";
  72. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+inventorySingle.qtyTotal+"</div></th>";
  73. tr += "</tr>";
  74. $("#itemList").append(tr);
  75. }
  76. $("#customerCode").val(customerCode);
  77. $("#sku").val(sku);
  78. $("#totalQty").val(totalQty);
  79. },
  80. error: function() {
  81. playSound('../raw/error.wav');
  82. mui.toast('网络断开或服务器发生异常');
  83. }
  84. });
  85. }
  86. //下一个转移任务
  87. function cleanAll() {
  88. $("#itemList").empty();
  89. $(".allowClear").each(function() {
  90. $(this).val("")
  91. })
  92. $("#locationCode").focus();
  93. }