ajax.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. function getXmlHttpObject() {
  2. var a = null;
  3. try {
  4. a = new XMLHttpRequest()
  5. } catch (e) {
  6. try {
  7. a = new ActiveXObject("Msxml2.XMLHTTP")
  8. } catch (e) {
  9. a = new ActiveXObject("Microsoft.XMLHTTP")
  10. }
  11. }
  12. return a
  13. }
  14. function createUrl(a, b) {
  15. var c = 'application/main.php?';
  16. var d = a.split('_');
  17. c += 'c=' + d[0] + '&m=' + d[1];
  18. if (b.length > 0 || b > 0) {
  19. if (d[0] == 'barcode' && d[1] == 'showProduct') {
  20. var p = b.split('_');
  21. c += '&now=' + p[0] + '&type=' + p[1]
  22. } else if (d[0] == 'barcode' && d[1] == 'pagination') {
  23. var p = b.split('_');
  24. c += '&type=' + p[0] + '&wh=' + p[1]
  25. } else if (d[0] == 'barcode' && d[1] == 'updatePrintStatus') {
  26. var p = b.split('_');
  27. c += '&bid=' + p[0] + '&type=' + p[1]
  28. } else if (d[0] == 'ocr' && d[1] == 'getWaybill') {
  29. var p = b.split('_');
  30. c += '&now=' + p[0] + '&shop=' + p[1] + '&startDate=' + p[2] + '&endDate=' + p[3]
  31. } else if (d[0] == 'ocr' && d[1] == 'pagination') {
  32. var p = b.split('_');
  33. c += '&shop=' + p[0] + '&startDate=' + p[1] + '&endDate=' + p[2] + '&wh=' + p[3]
  34. } else if (d[0] == 'scanner' && d[1] == 'getOrders') {
  35. var p = b.split('_');
  36. c += '&now=' + p[0] + '&shop=' + p[1] + '&status=' + p[2] + '&startDate=' + p[3] + '&endDate=' + p[4] + '&key=' + p[5] + '&pnsn=' + p[6]
  37. } else if (d[0] == 'scanner' && d[1] == 'pagination') {
  38. var p = b.split('_');
  39. c += '&shop=' + p[0] + '&status=' + p[1] + '&startDate=' + p[2] + '&endDate=' + p[3] + '&wh=' + p[4] + '&pnsn=' + p[5]
  40. } else if (d[0] == 'scanner' && d[1] == 'updateOrder') {
  41. var p = b.split('_');
  42. c += '&order_sn=' + p[0] + '&status=' + p[1]
  43. } else if (d[0] == 'scanner' && d[1] == 'getStatistics') {
  44. var p = b.split('_');
  45. c += '&startDate=' + p[0] + '&endDate=' + p[1]
  46. } else if (d[0] == 'wigsOut' && d[1] == 'getOrders') {
  47. var p = b.split('_');
  48. c += '&now=' + p[0] + '&shop=' + p[1] + '&status=' + p[2] + '&startDate=' + p[3] + '&endDate=' + p[4] + '&key=' + p[5] + '&pnsn=' + p[6];
  49. c += '&type=' + p[7];
  50. c += '&time_type='+p[8]
  51. } else if (d[0] == 'wigsOut' && d[1] == 'pagination') {
  52. var p = b.split('_');
  53. c += '&shop=' + p[0] + '&status=' + p[1] + '&startDate=' + p[2] + '&endDate=' + p[3] + '&wh=' + p[4] + '&pnsn=' + p[5];
  54. c += '&type=' + p[6];
  55. c += '&time_type='+p[7]
  56. } else if (d[0] == 'wigsOut' && d[1] == 'updateOrder') {
  57. var p = b.split('_');
  58. c += '&code=' + p[0] + '&status=' + p[1]
  59. } else if (d[0] == 'wigsOut' && d[1] == 'getStatistics') {
  60. var p = b.split('_');
  61. c += '&startDate=' + p[0] + '&endDate=' + p[1];
  62. c += '&time_type='+p[2]
  63. }
  64. }
  65. c = encodeURI(c + '&mr=' + Math.random());
  66. return c
  67. }
  68. function stateChanged(a, b, c) {
  69. var d = b.split('_');
  70. if (a.readyState == 4 && a.status == 200) {
  71. if (d[0] == 'barcode' && d[1] == 'showProduct') {
  72. $("#list").html(a.responseText);
  73. $("#pagination").data("now", c)
  74. } else if (d[0] == 'barcode' && d[1] == 'pagination') {
  75. $("#pagination").html(a.responseText)
  76. } else if (d[0] == 'barcode' && d[1] == 'uploadExcel') {
  77. $(".btn").attr("disabled", false);
  78. $(".upload_icon").hide();
  79. if (a.response !== '1') {
  80. alert("导入失败")
  81. } else {
  82. alert("导入成功");
  83. window.location.reload()
  84. }
  85. } else if (d[0] == 'ocr' && d[1] == 'uploadImage') {
  86. $(".btn").attr("disabled", false);
  87. $(".upload_icon").hide();
  88. if (a.response != '1') {
  89. var e = a.response;
  90. switch (e) {
  91. case '-6':
  92. alert("请勿重复上传");
  93. break;
  94. default:
  95. alert("上传失败")
  96. }
  97. } else {
  98. alert("上传成功");
  99. window.location.reload()
  100. }
  101. } else if (d[0] == 'ocr' && d[1] == 'getWaybill') {
  102. $("#list").html(a.responseText);
  103. $("#pagination").data("now", c)
  104. } else if (d[0] == 'ocr' && d[1] == 'pagination') {
  105. $("#pagination").html(a.responseText)
  106. } else if (d[0] == 'scanner' && d[1] == 'getOrders') {
  107. $("#list").html(a.responseText);
  108. $("#pagination").data("now", c)
  109. } else if (d[0] == 'scanner' && d[1] == 'pagination') {
  110. $("#pagination").html(a.responseText)
  111. } else if (d[0] == 'scanner' && d[1] == 'uploadExcel') {
  112. $(".btn").attr("disabled", false);
  113. $(".upload_icon").hide();
  114. if (a.response !== '1') {
  115. alert("导入失败,数据格式错误或内容重复!")
  116. } else {
  117. alert("导入成功");
  118. window.location.reload()
  119. }
  120. } else if (d[0] == 'scanner' && d[1] == 'updateOrder') {
  121. var f = document.getElementById('success_tip');
  122. var g = document.getElementById('warning_tip');
  123. var h = JSON.parse(a.response);
  124. switch (h.no) {
  125. case '1':
  126. f.play();
  127. alert("出库成功");
  128. break;
  129. case '2':
  130. f.play();
  131. alert("取消成功");
  132. window.location.reload();
  133. break;
  134. case '-1':
  135. g.play();
  136. alert("出库失败,请联系开发人员!");
  137. break;
  138. case '-2':
  139. g.play();
  140. alert("取消失败,请联系开发人员!");
  141. break;
  142. case '-3':
  143. g.play();
  144. alert("出库失败,此运单已出库!\n出库时间:" + h.out_time);
  145. break;
  146. case '-4':
  147. g.play();
  148. alert("取消失败,此运单已出库!\n出库时间:" + h.out_time);
  149. break;
  150. case '-5':
  151. g.play();
  152. alert("出库失败,此运单已取消!\n取消时间:" + h.out_time);
  153. break;
  154. case '-6':
  155. g.play();
  156. alert("取消失败,此运单已取消!\n取消时间:" + h.out_time);
  157. break;
  158. case '-10':
  159. g.play();
  160. alert("操作失败,查无此运单号!");
  161. break;
  162. default:
  163. g.play();
  164. alert("操作失败,请联系开发人员!")
  165. }
  166. $(".barcode_input").val('');
  167. $(".barcode_input").focus()
  168. } else if (d[0] == 'scanner' && d[1] == 'getStatistics') {
  169. var h = JSON.parse(a.responseText);
  170. $(".top_yesterday").html(h.yesterday);
  171. $(".top_total").html(h.total);
  172. $(".top_in").html(h. in );
  173. $(".top_out").html(h.out);
  174. $(".top_cancel").html(h.cancel)
  175. } else if (d[0] == 'wigsOut' && d[1] == 'getOrders') {
  176. $("#list").html(a.responseText);
  177. $("#pagination").data("now", c)
  178. } else if (d[0] == 'wigsOut' && d[1] == 'pagination') {
  179. $("#pagination").html(a.responseText)
  180. } else if (d[0] == 'wigsOut' && d[1] == 'uploadExcel') {
  181. $(".btn").attr("disabled", false);
  182. $(".upload_icon").hide();
  183. if (a.response !== '1') {
  184. alert("导入失败,数据格式错误或内容重复!")
  185. } else {
  186. alert("导入成功");
  187. window.location.reload()
  188. }
  189. } else if (d[0] == 'wigsOut' && d[1] == 'updateOrder') {
  190. var f = document.getElementById('success_tip');
  191. var g = document.getElementById('warning_tip');
  192. var h = JSON.parse(a.response);
  193. switch (h.no) {
  194. case '1':
  195. f.play();
  196. alert("入库成功");
  197. window.location.reload();
  198. break;
  199. case '2':
  200. f.play();
  201. alert("出库成功");
  202. window.location.reload();
  203. break;
  204. case '3':
  205. f.play();
  206. alert("取消成功");
  207. window.location.reload();
  208. break;
  209. case '4':
  210. f.play();
  211. alert("待分配执行成功");
  212. window.location.reload();
  213. break;
  214. case '-1':
  215. g.play();
  216. alert("入库失败,请联系开发人员!");
  217. break;
  218. case '-2':
  219. g.play();
  220. alert("出库失败,请联系开发人员!");
  221. break;
  222. case '-3':
  223. g.play();
  224. alert("取消失败,请联系开发人员!");
  225. break;
  226. case '-4':
  227. g.play();
  228. alert("出库失败,此订单未入库!");
  229. break;
  230. case '-5':
  231. g.play();
  232. alert("入库失败,此运单已入库!\n入库时间:" + h.time);
  233. break;
  234. case '-6':
  235. g.play();
  236. alert("入库失败,此运单已出库!\n出库时间:" + h.time);
  237. break;
  238. case '-7':
  239. g.play();
  240. alert("出库失败,此运单已出库!\n出库时间:" + h.time);
  241. break;
  242. case '-8':
  243. g.play();
  244. alert("入库失败,此运单已取消!\n取消时间:" + h.time);
  245. break;
  246. case '-9':
  247. g.play();
  248. alert("出库失败,此运单已取消!\n取消时间:" + h.time);
  249. break;
  250. case '-10':
  251. g.play();
  252. alert("操作失败,查无此单号!");
  253. break;
  254. case '-12':
  255. g.play();
  256. alert("未分配失败,请联系开发人员!");
  257. break;
  258. default:
  259. g.play();
  260. alert("操作失败,请联系开发人员!")
  261. }
  262. $(".code_input_in").val('');
  263. $(".code_input_out").val('');
  264. $(".code_input_in").focus()
  265. } else if (d[0] == 'wigsOut' && d[1] == 'getStatistics') {
  266. var h = JSON.parse(a.responseText);
  267. $(".top_yesterday").html(h.yesterday);
  268. $(".top_total").html(h.total);
  269. $(".top_in").html(h. in );
  270. $(".top_out").html(h.out);
  271. $(".top_cancel").html(h.cancel);
  272. $(".top_not_in").html(h.not_in)
  273. }
  274. } else if (a.readyState == 4 && a.status == 404) {
  275. alert("系统错误,请联系开发人员!")
  276. }
  277. }
  278. function myAjax(a, b) {
  279. var c = getXmlHttpObject();
  280. if (c == null) {
  281. alert("Please update your browser!");
  282. return false
  283. }
  284. var d = createUrl(a, b);
  285. c.onreadystatechange = function() {
  286. stateChanged(c, a, b)
  287. };
  288. c.open("GET", d, true);
  289. c.send(null)
  290. }