common_wigsout.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /**
  2. * window onload
  3. * by lijg
  4. * 2018.11.07
  5. */
  6. window.onload = function(){
  7. // var yesterday = myGetDate(-1);
  8. var today = myGetDate(0);
  9. var monthAgo = myGetDate(-30);
  10. $(".start_date").val(monthAgo);
  11. $(".end_date").val(today);
  12. $(".top_start").html(monthAgo);
  13. $(".top_end").html(today);
  14. getOrdersInit();
  15. $(".code_input_in").focus();
  16. };
  17. function searchOrder(){
  18. var code = $('.search_code').val();
  19. if(code.length == 0){
  20. alert('请输入所查找编号!');
  21. return false;
  22. }
  23. var key = getUrlParam();
  24. $.ajax({
  25. type: 'get',
  26. url: 'application/main.php',
  27. data: 'c=wigsOut&m=searchOrders&code=' + code + '&key=' + key,
  28. success: function(rs){
  29. if(rs == '-1'){
  30. alert('查无此编号!');
  31. }else{
  32. $("#list").html(rs);
  33. }
  34. $('.search_code').val("");
  35. $('.search_code').focus();
  36. },
  37. });
  38. return false;
  39. }
  40. /**
  41. * get any date
  42. * by lijg
  43. * 20181108
  44. */
  45. function myGetDate(whichDay){
  46. var myDate = new Date();
  47. myDate.setDate(myDate.getDate()+whichDay);
  48. var year = myDate.getFullYear();
  49. var month = (myDate.getMonth()+1<10)?'0'+(myDate.getMonth()+1):(myDate.getMonth()+1);
  50. var day = (myDate.getDate()<10)?('0'+myDate.getDate()):myDate.getDate();
  51. var today = year + '-' + month + '-' + day;
  52. return today;
  53. }
  54. /**
  55. * by lijg
  56. * 2018.11.07
  57. */
  58. $(document).ready(function(){
  59. var key = getUrlParam();
  60. // if(!key){
  61. // $('.options').hide();
  62. // }
  63. $(document).on("click", ".gtlt", function(){
  64. var shop = $(".shop").val();
  65. var status = $(".orders_status").val();
  66. var type = $(".type").val();
  67. var time_type = $(".time_type").val();
  68. var start = $(".start_date").val();
  69. var end = $(".end_date").val();
  70. var total_page = $(".total_page").data('ttpg');
  71. var wh = $(this).data('wh');
  72. var dir = wh.substr(0, 1);
  73. var now = wh.substr(1);
  74. let pnsn = localStorage.getItem('pnsn');
  75. if(dir == 'h'){
  76. now = (now-1)*10 + 1;
  77. }else if(dir == 't'){
  78. now = now*10 + 1;
  79. }
  80. if(now > 0 && now <= total_page){
  81. var params1 = now + '_' + shop + '_' + status + '_' + start + '_' + end + '_' + key + '_' + pnsn + '_' + type+ '_'+time_type;
  82. var params2 = shop + '_'+ status + '_' + start + '_' + end + '_' + wh + '_' + pnsn + '_' + type + '_'+time_type;
  83. myAjax('wigsOut_getOrders', params1);
  84. myAjax('wigsOut_pagination', params2);
  85. }else{
  86. return false;
  87. }
  88. });
  89. $(document).on("click", ".cancel_order", function(){
  90. var barcode = $(this).data('barcode');
  91. updateOrdersStatus(barcode, '4');
  92. });
  93. $(".status_btn").click(function(){
  94. getOrdersInit();
  95. var start = $(".start_date").val();
  96. var end = $(".end_date").val();
  97. $('.top_start').html(start);
  98. $('.top_end').html(end);
  99. });
  100. $(".code_input_in").change(function(){
  101. var code = $(this).val();
  102. updateOrdersStatus(code, '2');
  103. });
  104. $(".code_input_out").change(function(){
  105. var code = $(this).val();
  106. updateOrdersStatus(code, '3');
  107. });
  108. $(".code_input_dist").change(function(){
  109. var code = $(this).val();
  110. updateOrdersStatus(code, '6');
  111. });
  112. $('.search_code_btn').click(function(){
  113. var code = $('.search_code').val();
  114. if(code.length == 0){
  115. alert('请输入所查找编号!');
  116. return false;
  117. }
  118. var key = getUrlParam();
  119. $.ajax({
  120. type: 'get',
  121. url: 'application/main.php',
  122. data: 'c=wigsOut&m=searchOrders&code=' + code + '&key=' + key,
  123. success: function(rs){
  124. if(rs == '-1'){
  125. alert('查无此编号!');
  126. }else{
  127. $("#list").html(rs);
  128. }
  129. },
  130. });
  131. });
  132. $('.export_btn').click(function(){
  133. var shop = $("#shop").val();
  134. var status = $("#orders_status").val();
  135. var type = $('#type').val();
  136. var start_date = $(".start_date").val();
  137. var end_date = $(".end_date").val();
  138. var time_type= $(".time_type").val();
  139. if(!start_date || !end_date){
  140. alert("请选择查询日期");
  141. return false;
  142. }else if(start_date > end_date){
  143. alert("结束日期不得小于起始日期");
  144. return false;
  145. }
  146. window.location.href = 'application/main.php?c=wigsOut&m=exportExcel&shop='+shop+'&status='+status+'&startDate='+start_date+'&endDate='+end_date+'&type='+type+'&time_type='+time_type;
  147. });
  148. $('.export_yesterday_btn').click(function(){
  149. eyb();
  150. setTimeout(eyb, 2000);
  151. });
  152. function eyb(){
  153. window.location.href = 'application/main.php?c=wigsOut&m=exportExcel&shop='+0+'&status='+3+'&startDate='+myGetDate(-1)+'&endDate='+myGetDate(-1)+'&type='+0;
  154. }
  155. /**
  156. * change per page amount
  157. * by lijg 20190214
  158. */
  159. $('.pagination').on('change', '.pnsn', function(){
  160. let pnsn = $(this).val();
  161. localStorage.setItem('pnsn', pnsn);
  162. getOrdersInit();
  163. });
  164. $(document).on('click', '.update_memo', function(){
  165. var oid = $(this).data('id');
  166. var omemo = $(this).parent('.options').siblings('.memo').html();
  167. var memo = prompt("请填写备注:", omemo);
  168. if(memo != null && memo != ''){
  169. $.ajax({
  170. type: 'post',
  171. url: 'application/main.php',
  172. data: 'c=wigsOut&m=updateMemo&oid=' + oid + '&memo=' + memo,
  173. success: function(rs){
  174. if(rs == -1){
  175. alert('添加备注失败,请联系开发人员!');
  176. }else{
  177. window.location.reload();
  178. }
  179. },
  180. });
  181. }
  182. });
  183. $('.sync_data').click(function(){
  184. $('.sync_icon').show();
  185. $.ajax({
  186. type: 'get',
  187. url: 'application/main.php',
  188. data: 'c=wigsOut&m=syncData',
  189. dataType: 'json',
  190. success: function(rs){
  191. $('.sync_icon').hide();
  192. if(rs.code == 0){
  193. alert('无新数据!');
  194. }else if(rs.code != 1){
  195. alert('同步失败,请联系开发人员!');
  196. }else{
  197. alert('同步成功!');
  198. window.location.reload();
  199. }
  200. },
  201. });
  202. });
  203. $('#list').on('click', '.print_bc', function(){
  204. var order_barcode = $(this).parent().parent('.list_block').find('.order_barcode').html();
  205. var goods_info = $(this).parent().parent('.list_block').find('.goods_info').html();
  206. var print_time = $(this).parent().parent('.list_block').find('.order_id').data('printtime');
  207. var transport = $(this).parent().parent('.list_block').find('.order_id').data('transport');
  208. var oid = $(this).parent().parent('.list_block').find('.order_id').html();
  209. var LODOP;
  210. LODOP=getLodop();
  211. LODOP.PRINT_INIT("");
  212. if (LODOP.CVERSION) CLODOP.On_Return = function(TaskID, Value) {
  213. if(Value==1){
  214. $.ajax({
  215. type: 'post',
  216. url: 'application/main.php',
  217. data: 'c=wigsOut&m=updatePrint&oid=' + oid,
  218. success: function(rs){
  219. if(rs == -1){
  220. alert('系统错误,请联系开发人员!');
  221. }else{
  222. $('.barcode>.box').html('');
  223. $('.yp').html('').hide();
  224. $('.np').show();
  225. reloadNow();
  226. }
  227. },
  228. });
  229. }else{
  230. alert('系统错误,请联系开发人员!');
  231. }
  232. }
  233. LODOP.ADD_PRINT_BARCODE(3, 2, 400, 35, "128Auto", order_barcode);
  234. LODOP.SET_PRINT_STYLEA(0, "showBarText", 0)
  235. var str=order_barcode+'*'+goods_info + '*' + transport + '*' + print_time;
  236. if(str.length>=130){
  237. str1=str.slice(0,130);
  238. str2=str.slice(130);
  239. LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str1);
  240. LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
  241. LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
  242. LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
  243. LODOP.NewPageA();
  244. LODOP.ADD_PRINT_TEXT(3, "0mm",400,"45mm", str2);
  245. LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
  246. LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
  247. LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
  248. }else{
  249. LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str);
  250. LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
  251. LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
  252. LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
  253. }
  254. // LODOP.ADD_PRINT_BARCODE(3, 10, 32, 400, "128Auto", order_barcode);
  255. // LODOP.SET_PRINT_STYLEA(0, "showBarText", 0)
  256. // LODOP.SET_PRINT_STYLEA(0, "Angle", 90)
  257. // var str=order_barcode+'*'+goods_info + '*' + transport + '*' + print_time;
  258. // LODOP.ADD_PRINT_TEXT(450, 4, 500, 45, str);
  259. // LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
  260. // LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
  261. // LODOP.SET_PRINT_STYLEA(0, "Angle", 90)
  262. // LODOP.SET_PRINT_PAGESIZE(3,450,70,"")//设置默认纸张
  263. LODOP.PRINT();
  264. });
  265. $('.print_all').click(function(){
  266. $.ajax({
  267. type: 'post',
  268. url: 'application/main.php',
  269. data: 'c=wigsOut&m=printAll',
  270. success: function(rs){
  271. if(rs == -1){
  272. alert('暂无可打印数据!');
  273. }else{
  274. var arr = JSON.parse(rs);
  275. var LODOP;
  276. LODOP=getLodop();
  277. LODOP.PRINT_INIT("");
  278. for(x in arr){
  279. setTimeout(function() {
  280. LODOP.ADD_PRINT_BARCODE(3, 2, 400, 35, "128Auto", arr[x].barcode);
  281. LODOP.SET_PRINT_STYLEA(0, "showBarText", 0)
  282. str=arr[x].str;
  283. if(str.length>=130){
  284. str1=str.slice(0,130);
  285. str2=str.slice(130);
  286. LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str1);
  287. LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
  288. LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
  289. LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
  290. LODOP.NewPageA();
  291. LODOP.ADD_PRINT_TEXT(3, "0mm",400,"45mm", str2);
  292. LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
  293. LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
  294. LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
  295. }else{
  296. LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str);
  297. LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
  298. LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
  299. LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
  300. }
  301. // LODOP.SET_PRINT_PAGESIZE(3,450,70,"")//设置默认纸张
  302. // LODOP.PRINTA();
  303. LODOP.PRINT();
  304. }, 2000);
  305. }
  306. $('.barcode>.box').html('');
  307. $('.yp').html('').hide();
  308. $('.np').show();
  309. reloadNow();
  310. }
  311. },
  312. });
  313. });
  314. });
  315. /**
  316. * reload current page
  317. * by lijg
  318. * 2019.10.15
  319. */
  320. function reloadNow(){
  321. var shop = $("#shop").val();
  322. var status = $("#orders_status").val();
  323. var start_date = $(".start_date").val();
  324. var end_date = $(".end_date").val();
  325. var type= $("#type").val();
  326. let pnsn = localStorage.getItem('pnsn');
  327. if(pnsn == null){
  328. pnsn = 15;
  329. localStorage.setItem('pnsn', 15);
  330. }
  331. var now = $('#pagination').data('now');
  332. if(!start_date || !end_date){
  333. alert("请选择查询日期");
  334. return false;
  335. }else if(start_date > end_date){
  336. alert("结束日期不得小于起始日期");
  337. return false;
  338. }
  339. var key = getUrlParam();
  340. var param1 = now + '_' + shop + '_' + status + '_' + start_date + '_' + end_date + '_' + key + '_' + pnsn + '_' + type + '_' + time_type;
  341. var param3 = start_date + '_' + end_date + '_' + time_type;
  342. myAjax('wigsOut_getOrders', param1);
  343. myAjax('wigsOut_getStatistics', param3);
  344. }
  345. /**
  346. * get orders
  347. * by lijg
  348. * 2018.11.07
  349. */
  350. function getOrdersInit(){
  351. var shop = $("#shop").val();
  352. var status = $("#orders_status").val();
  353. var start_date = $(".start_date").val();
  354. var end_date = $(".end_date").val();
  355. var type= $("#type").val();
  356. var time_type=$('.time_type').val();
  357. let pnsn = localStorage.getItem('pnsn');
  358. if(pnsn == null){
  359. pnsn = 15;
  360. localStorage.setItem('pnsn', 15);
  361. }
  362. if(!start_date || !end_date){
  363. alert("请选择查询日期");
  364. return false;
  365. }else if(start_date > end_date){
  366. alert("结束日期不得小于起始日期");
  367. return false;
  368. }
  369. var key = getUrlParam();
  370. var param1 = '1' + '_' + shop + '_' + status + '_' + start_date + '_' + end_date + '_' + key + '_' + pnsn + '_' + type+ '_' + time_type;
  371. var param2 = shop + '_' + status + '_' + start_date + '_' + end_date + '_h0' + '_' + pnsn + '_' + type + '_' + time_type;
  372. var param3 = start_date + '_' + end_date + '_' + time_type;
  373. myAjax('wigsOut_getOrders', param1);
  374. myAjax('wigsOut_pagination', param2);
  375. myAjax('wigsOut_getStatistics', param3);
  376. }
  377. /**
  378. * get orders from pagination
  379. * by lijg
  380. * 2018.11.07
  381. */
  382. function getOFP(param){
  383. var key = getUrlParam();
  384. let pnsn = localStorage.getItem('pnsn');
  385. param += '_' + key + '_' + pnsn;
  386. myAjax('wigsOut_getOrders', param);
  387. }
  388. /**
  389. * ajax upload excel for wigsOut
  390. * by lijg
  391. * 2018.11.07
  392. */
  393. function uploadWigsout(aim){
  394. var xmlHttp = getXmlHttpObjecf(xmlHttp == null);
  395. if(xmlHttp == null){
  396. alert("Please update your browser!");
  397. return false;
  398. }
  399. var excel = document.getElementById('excel').files['0'];
  400. if(excel == undefined){
  401. alert("请选择导入文件");
  402. return false;
  403. }else{
  404. var ext = excel.name.substr(excel.name.lastIndexOf('.')+1);
  405. if(ext != 'xlsx'){
  406. alert('请选择 *.xlsx 格式文件!');
  407. return false;
  408. }else{
  409. $(".btn").attr("disabled", true);
  410. $(".upload_icon").show();
  411. }
  412. }
  413. var cm = aim.split('_');
  414. var url = 'application/main.php';
  415. var form = new FormData();
  416. form.append('c', cm[0]);
  417. form.append('m', cm[1]);
  418. form.append('excel', excel);
  419. xmlHttp.onreadystatechange = function(){
  420. stateChanged(xmlHttp, aim);
  421. };
  422. xmlHttp.open('POST', url, true);
  423. xmlHttp.send(form);
  424. }
  425. /**
  426. * update orders
  427. * by lijg 20181108
  428. */
  429. function updateOrdersStatus(code, status){
  430. params = code + '_' + status;
  431. myAjax("wigsOut_updateOrder", params);
  432. }
  433. /**
  434. * get url param
  435. * by lijg 20181120
  436. */
  437. function getUrlParam(){
  438. var url = window.location.href;
  439. var p = url.split('?');
  440. if(p.length == 2){
  441. return p[1];
  442. }else{
  443. return null;
  444. }
  445. }