waveOutShelf.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. //波次单号回车
  2. $('#waveNo').keyup(function(event) {
  3. if(event.keyCode != "13") {
  4. return false;
  5. }
  6. $("#waveNo").val(trimStr($("#waveNo").val()));
  7. //播放扫描声音
  8. playSound('../raw/scan.wav');
  9. submitWaveNo()
  10. });
  11. $("#waveNo").blur(function() {
  12. var waveNo = trimStr($("#waveNo").val());
  13. if(waveNo == '') {
  14. $('#waveNo').focus();
  15. }
  16. });
  17. setTimeout(function() {
  18. $('#waveNo').focus();
  19. }, 1000);
  20. // 库位号回车
  21. // $('#locationCode').keyup(function(event) {
  22. // if(event.keyCode != "13") {
  23. // return false;
  24. // }
  25. // $("#locationCode").val(trimStr($("#locationCode").val()));
  26. // //播放扫描声音
  27. // playSound('../raw/scan.wav');
  28. // $('#barcode').focus();
  29. // });
  30. // 条码回车
  31. $('#barcode').keyup(function(event) {
  32. if(event.keyCode != "13") {
  33. return false;
  34. }
  35. $("#barcode").val(trimStr($("#barcode").val()));
  36. //播放扫描声音
  37. playSound('../raw/scan.wav');
  38. $("#productQty").focus();
  39. });
  40. // 提交
  41. $('#productQty').keyup(function(event) {
  42. if(event.keyCode != "13") {
  43. return false;
  44. }
  45. $("#productQty").val(trimStr($("#productQty").val()));
  46. //播放扫描声音
  47. playSound('../raw/scan.wav');
  48. submitOutShelf();
  49. });
  50. function submitWaveNo() {
  51. if($("#waveNo").val() == '') {
  52. mui.alert('波次号或运单号不能为空!', '注意');
  53. return;
  54. }
  55. var appRequest = $appRequest; //复制请求封装对象
  56. appRequest.opType = OP_TYPE_MENU.BATCH_OUT_SHELF_1;
  57. appRequest.msg = $("#waveNo").val(); //msg是消息内容主体
  58. // 提交
  59. $.ajax({
  60. type: 'POST',
  61. url: $appRequestUrl,
  62. data: JSON.stringify(appRequest),
  63. contentType: "application/json",
  64. success: function(result) {
  65. if(!result.success) {
  66. playSound('../raw/error.wav');
  67. $("#waveNo").val("");
  68. mui.alert(result.msg, '警告', function() { setFocus('waveNo'); });
  69. return;
  70. }
  71. var wave = result.extend;
  72. //刷新待下架列表
  73. showUnOutShelfDetails();
  74. $("#warehouseCode").val(wave.warehouseCode);
  75. $("#customerCode").val(wave.customerCode);
  76. $("#statusName").val(wave.statusName);
  77. $('#barcode').focus();
  78. },
  79. error: function() {
  80. mui.alert('网络断开或服务器发生异常', '注意');
  81. }
  82. });
  83. }
  84. //提交下架
  85. var isSubmintIng = false; // 是否正在提交
  86. function submitOutShelf() {
  87. if(isSubmintIng) {
  88. return;
  89. }
  90. if($("#waveNo").val() == '') {
  91. mui.alert('波次号不能为空!', '注意');
  92. return;
  93. }
  94. // if($("#locationCode").val() == '') {
  95. // mui.alert('货位号不能为空!', '注意');
  96. // return;
  97. // }
  98. if($("#barcode").val() == '') {
  99. mui.alert('商品条码不能为空!', '注意');
  100. return;
  101. }
  102. if($("#productQty").val() == '') {
  103. mui.alert('商品数量不能为空!', '注意');
  104. return;
  105. }
  106. isSubmintIng = true;
  107. var waveNo = $("#waveNo").val();
  108. // var locationCode = $('#locationCode').val();
  109. var barcode = $('#barcode').val();
  110. var quantity = $("#productQty").val();
  111. var jsonData = {};
  112. jsonData.waveNo = waveNo;
  113. jsonData.quantity = quantity;
  114. // jsonData.locationCode = locationCode;
  115. jsonData.barcode = barcode;
  116. var appRequest = $appRequest; //复制请求封装对象
  117. appRequest.opType = OP_TYPE_MENU.BATCH_OUT_SHELF_2;
  118. appRequest.msg = JSON.stringify(jsonData); //msg是消息内容主体
  119. mui(document.getElementById("subButton")).button('loading'); //切换为loading状态
  120. // 提交
  121. $.ajax({
  122. type: 'POST',
  123. url: $appRequestUrl,
  124. data: JSON.stringify(appRequest),
  125. contentType: "application/json",
  126. success: function(result) {
  127. console.log(JSON.stringify(result))
  128. isSubmintIng = false;
  129. mui(document.getElementById("subButton")).button('reset'); //重置button
  130. if(!result.success) {
  131. playSound('../raw/error.wav');
  132. mui.alert(result.msg, '警告', function() { setFocus('barcode'); });
  133. return;
  134. }
  135. mui.toast(result.msg);
  136. //播放成功声音
  137. playSound('../raw/ok.wav');
  138. //刷新下架列表
  139. refreshUnOutShelfItems();
  140. refreshAlreadyOutShelfItems();
  141. nextBarcode(); // 下一个库位
  142. if(result.extend.flag == '3') { // 波次完成下架
  143. cleanAll();
  144. }
  145. },
  146. error: function() {
  147. isSubmintIng = false;
  148. mui(document.getElementById("subButton")).button('reset'); //重置button
  149. mui.alert('网络断开或服务器发生异常', '注意');
  150. }
  151. });
  152. }
  153. function nextBarcode() {
  154. // 下架完之后清空
  155. $(".allowClear").each(function() {
  156. $(this).val("")
  157. })
  158. $('#barcode').focus();
  159. }
  160. function cleanAll() {
  161. $("input").each(function() {
  162. $(this).val("")
  163. })
  164. $('#waveNo').focus();
  165. }
  166. //下架列表
  167. var isShowUnOutShelfDetails = false;
  168. function showUnOutShelfDetails(){
  169. if(!isShowUnOutShelfDetails){
  170. $("#showUnOutShelfDetails").show();
  171. isShowUnOutShelfDetails = true;
  172. $("#showUnOutShelfIco").attr("class", "fa fa-angle-double-up");
  173. //刷新明细
  174. refreshUnOutShelfItems();
  175. }else{
  176. $("#showUnOutShelfDetails").hide();
  177. isShowUnOutShelfDetails = false;
  178. $("#showUnOutShelfIco").attr("class", "fa fa-angle-double-down");
  179. }
  180. //回到上次焦点地方
  181. // if(focusId!=null && focusId != ''){
  182. // $("#"+focusId).focus();
  183. // }
  184. }
  185. //显示待下架明细
  186. function refreshUnOutShelfItems(){
  187. var waveNo = $('#waveNo').val();
  188. var appRequest = $appRequest;//复制请求封装对象
  189. appRequest.opType = OP_TYPE_MENU.BATCH_OUT_SHELF_3;
  190. appRequest.msg = waveNo;//msg是消息内容主体
  191. $("#unOutShelfItemList").empty();
  192. $.ajax({
  193. type: 'POST',
  194. url: $appRequestUrl,
  195. contentType: "application/json; charset=utf-8",
  196. data: JSON.stringify(appRequest),
  197. success: function (appResponse) {
  198. if(!appResponse.success){
  199. return;
  200. }
  201. var waitQtyTotal = 0;
  202. var itemList = appResponse.extend;
  203. // console.log(JSON.stringify(itemList));
  204. var unOutShelfList = itemList.unOutShelfList;
  205. for(var index = 0; index < unOutShelfList.length; index ++){
  206. var unOutShelf = unOutShelfList[index];
  207. var tr = "<tr id='item_"+unOutShelf.id+"'>";
  208. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+unOutShelf.barcode+"</div></th>";
  209. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+unOutShelf.productName+"</div></th>";
  210. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+unOutShelf.locationCode+"</div></th>";
  211. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+unOutShelf.quantity+"</div></th>";
  212. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+unOutShelf.extend4+"</div></th>";
  213. tr += "</tr>";
  214. $("#unOutShelfItemList").append(tr);
  215. }
  216. },
  217. error: function () {
  218. playSound('../raw/error.wav');
  219. mui.toast('网络断开或服务器发生异常');
  220. }
  221. });
  222. }
  223. //已下架列表
  224. var isAlreadyOutShelfDetails = false;
  225. function alreadyOutShelfDetails(){
  226. if(!isAlreadyOutShelfDetails){
  227. $("#alreadyOutShelfDetails").show();
  228. isAlreadyOutShelfDetails = true;
  229. $("#showAlreadyOutShelfIco").attr("class", "fa fa-angle-double-up");
  230. //刷新明细
  231. refreshAlreadyOutShelfItems();
  232. }else{
  233. $("#alreadyOutShelfDetails").hide();
  234. isAlreadyOutShelfDetails = false;
  235. $("#showAlreadyOutShelfIco").attr("class", "fa fa-angle-double-down");
  236. }
  237. //回到上次焦点地方
  238. /* if(focusId!=null && focusId != ''){
  239. $("#"+focusId).focus();
  240. } */
  241. }
  242. //显示已下架明细
  243. function refreshAlreadyOutShelfItems(){
  244. var waveNo = $('#waveNo').val();
  245. var appRequest = $appRequest;//复制请求封装对象
  246. appRequest.opType = OP_TYPE_MENU.BATCH_OUT_SHELF_3;
  247. appRequest.msg = waveNo;//msg是消息内容主体
  248. $("#alreadyOutShelfItemList").empty();
  249. $.ajax({
  250. type: 'POST',
  251. url: $appRequestUrl,
  252. contentType: "application/json; charset=utf-8",
  253. data: JSON.stringify(appRequest),
  254. success: function (appResponse) {
  255. if(!appResponse.success){
  256. return;
  257. }
  258. var waitQtyTotal = 0;
  259. var itemList = appResponse.extend;
  260. // console.log(JSON.stringify(itemList));
  261. var alreadyOutShelfList = itemList.alreadyOutShelfList;
  262. for(var index = 0; index < alreadyOutShelfList.length; index ++){
  263. var alreadyOutShelf = alreadyOutShelfList[index];
  264. var tr = "<tr id='item_"+alreadyOutShelf.id+"'>";
  265. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+alreadyOutShelf.barcode+"</div></th>";
  266. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+alreadyOutShelf.productName+"</div></th>";
  267. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+alreadyOutShelf.locationCode+"</div></th>";
  268. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+alreadyOutShelf.quantity+"</div></th>";
  269. tr += "<th><div style='width:100%;overflow: hidden;font-size: 9pt;text-align: left;'>"+alreadyOutShelf.extend4+"</div></th>";
  270. tr += "</tr>";
  271. $("#alreadyOutShelfItemList").append(tr);
  272. }
  273. },
  274. error: function () {
  275. playSound('../raw/error.wav');
  276. mui.toast('网络断开或服务器发生异常');
  277. }
  278. });
  279. }