printnew.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /* 批量打印提示 */
  2. $(".printing").click(function() {
  3. var a = "";
  4. $(".datatext input[name='check']:checked").each(function() {
  5. a = a + $(this).val()+",";
  6. });
  7. if (a)
  8. {
  9. if($("select[name='printer']").children("option:selected").val() == "")
  10. {
  11. $(".ts p").html("请选择打印机!");
  12. $(".ts").show();
  13. setTimeout('$(".ts").fadeOut()', 1000);
  14. }
  15. else
  16. {
  17. $(".systemwindow div p:eq(0)").text("是否确认批量打印所选内容?");
  18. $(".systemwindow div p:eq(1)").html("<p><font id='printingon'>确 定</font><font class='esc'>取 消</font></p>");
  19. $(".systemwindow").show();
  20. }
  21. }
  22. else
  23. {
  24. $(".ts p").html("请勾选需要打印的内容");
  25. $(".ts").show();
  26. setTimeout('$(".ts").fadeOut()', 1000);
  27. }
  28. });
  29. $(".systemwindow .esc").click(function() {
  30. $(".systemwindow").hide();
  31. });
  32. $(".systemwindow").on('click',".esc",function() {
  33. $(".systemwindow").hide();
  34. });
  35. /* 批量打印开始 */
  36. $(".systemwindow").on('click',"#printingon",function() {
  37. $(".systemwindow").hide();
  38. $(".systemwindow div p:eq(0)").html("<i class='fa fa-2x fa-cog fa-spin'></i> &nbsp; 正在处理打印信息,请稍后...");
  39. $(".systemwindow div p:eq(1)").html("");
  40. $(".systemwindow").show();
  41. var a = "";var i = 0;
  42. $(".datatext input[name='check']:checked").each(function() {
  43. a = a+$(this).val()+',';
  44. i++;
  45. });
  46. ajax(i-1,a);
  47. });
  48. function ajax(num,list){
  49. $.ajax({
  50. url: "/systemprint/printing/",
  51. data: "s=" + list+"&n=" + num,
  52. type: "POST",
  53. dataType: "json",
  54. timeout: 600001,
  55. success: function(c) {
  56. if (c.success) {
  57. if(c.rows['type'] == 1)
  58. {
  59. wprinter.pdffhd(c.rows);
  60. }
  61. else if(c.rows['type'] == 2)
  62. {
  63. wprinter.fhd(c.rows);
  64. }
  65. if(c.rows['n'] > -1)
  66. {
  67. ajax(c.rows['n'],c.rows['data']);
  68. }
  69. else
  70. {
  71. wprinter.sound("打印完成")
  72. $(".systemwindow div p:eq(0)").html("打印完成!");
  73. $(".systemwindow div p:eq(1)").html("<font class='printok'>确 定</font>");
  74. $(".systemwindow").show();
  75. }
  76. }
  77. else
  78. {
  79. $(".systemwindow").hide();
  80. layx.alert('错误',c.msg,function(id,button){
  81. $(".search span").click();
  82. },{dialogIcon:'error'});
  83. }
  84. },
  85. error: function (textStatus) {
  86. wprinter.sound("错误,请求数据超时!请重试")
  87. $(".systemwindow").hide();
  88. layx.alert('错误','请求数据超时!请重试',function(id,button){
  89. $(".search span").click();
  90. },{dialogIcon:'error'});
  91. },
  92. });
  93. }
  94. function outbound(data) {
  95. $(".search .number").val("");
  96. $(".search .waybill").val("");
  97. $.ajax({
  98. url: url+"outbound/",
  99. data: "number="+$("input[name='outbound']").val()+"&id="+LYlink+"&type="+$("select[name='type']").children("option:selected").val()+"&express="+$("select[name='express']").children("option:selected").val(),
  100. type: "POST",
  101. dataType: "json",
  102. success: function(b)
  103. {
  104. searchspan(1);
  105. $(".systemwindow").hide();
  106. if (b && b.success)
  107. {
  108. if(b.music == '1')
  109. {
  110. $("#music_d")[0].play();
  111. }
  112. $(".outbound").html(b.msg);
  113. $("#outbound").val("");
  114. $("#outbound").focus();
  115. }
  116. else
  117. {
  118. $("#outbound").blur();
  119. $("#music_c")[0].play();
  120. $(".systemwindow div p:eq(0)").html(b.msg);
  121. $(".systemwindow div p:eq(1)").html("<font class='wcoutbound'>确 定</font>");
  122. $(".systemwindow").show();
  123. $("#outbound").val("");
  124. }
  125. }
  126. });
  127. }
  128. $(".obdel").click(function() {
  129. var a = "";
  130. $(".datatext input[name='check']:checked").each(function() {
  131. a = a + $(this).val()+",";
  132. });
  133. if (a) {
  134. $(".systemwindow div p:eq(0)").text("是否确认删除所选内容?");
  135. $(".systemwindow div p:eq(1)").html("<p><font id='obdelgo'>确 定</font><font class='esc'>取 消</font></p>");
  136. $(".systemwindow").show();
  137. }
  138. else
  139. {
  140. $(".ts p").html("请勾选需要删除的内容");
  141. $(".ts").show();
  142. setTimeout('$(".ts").fadeOut()', 1000);
  143. }
  144. });
  145. $(".systemwindow").on('click',"#obdelgo",function() {
  146. $(".systemwindow").hide();
  147. $(".systemwindow div p:eq(0)").html("<i class='fa fa-2x fa-cog fa-spin'></i> &nbsp; 删除中,请稍后...");
  148. $(".systemwindow div p:eq(1)").html("");
  149. $(".systemwindow").show();
  150. var a = "";var i = 0;
  151. $(".datatext input[name='check']:checked").each(function() {
  152. a = a+$(this).val()+',';
  153. i++;
  154. });
  155. $.ajax({
  156. url: "/systembound/del",
  157. data: "delarr="+a,
  158. type: "POST",
  159. dataType: "json",
  160. success: function(b)
  161. {
  162. $(".systemwindow").hide();
  163. if (b && b.success)
  164. {
  165. searchspan(1);
  166. $(".outbound").html(b.data);
  167. $("#outbound").blur();
  168. $(".systemwindow div p:eq(0)").html("删除成功!");
  169. $(".systemwindow div p:eq(1)").html("<font class='wcoutbound'>确 定</font>");
  170. $(".systemwindow").show();
  171. }
  172. else
  173. {
  174. $("#outbound").blur();
  175. $(".systemwindow div p:eq(0)").html(b.msg);
  176. $(".systemwindow div p:eq(1)").html("<font class='wcoutbound'>确 定</font>");
  177. $(".systemwindow").show();
  178. }
  179. }
  180. });
  181. });
  182. /* 清空并聚焦出库input */
  183. $(".systemwindow").on('click',".wcsj",function() {
  184. $("#orderinfo").val("");
  185. $("#weight").val("");
  186. $(".systemwindow").find(".gth").remove();
  187. $("#orderinfo").focus();
  188. $(".systemwindow").hide();
  189. });
  190. $(".systemwindow").on('click',".wcoutbound",function() {
  191. $("#outbound").focus();
  192. $(".systemwindow").hide();
  193. });
  194. $(".systemwindow").on('click',".printok",function() {
  195. $(".search span").click();
  196. $(".systemwindow").hide();
  197. });
  198. /* 更改出库信息 */
  199. function win() {
  200. if(typeof editurl != "undefined")
  201. {
  202. $(".datatext tr").each(function() {
  203. $(this).find("td:eq("+editdj+")").html("<h9 class='window' data-h='"+editurl+$(this).attr('id')+"' data-t='"+editt+"'>"+$(this).find("td:eq("+editdj+")").text()+"</h9>");
  204. });
  205. }
  206. }
  207. $(document).keyup(function(event){
  208. if(event.keyCode ==13){
  209. if(typeof systemfout != "undefined")
  210. {
  211. if($("select[name='printer']").children("option:selected").val() == "")
  212. {
  213. $("#music_c")[0].play();
  214. $(".systemwindow div p:eq(0)").html('需要先选择打印机!');
  215. $(".systemwindow div p:eq(1)").html("<font class='wcsj'>确 定</font>");
  216. $(".systemwindow").show();
  217. $("#orderinfo").val("");
  218. $("#orderinfo").focus();
  219. return;
  220. }
  221. $("#orderinfo").blur();
  222. $(".systemwindow div p:eq(0)").html("<i class='fa fa-2x fa-cog fa-spin'></i> &nbsp; 处理中,请稍后...");
  223. $(".systemwindow div p:eq(1)").html("");
  224. $(".systemwindow").show();
  225. $.ajax({
  226. url: "/systemfout/fout/",
  227. data: "order="+$("#orderinfo").val()+"&weight="+$("#weight").val(),
  228. type: "POST",
  229. dataType: "json",
  230. success: function(a) {
  231. $(".systemwindow").hide();
  232. if (a && a.success)
  233. {
  234. if(typeof a.yd != "undefined")
  235. {
  236. $("#orderinfo").blur();
  237. $("#music_c")[0].play();
  238. $("#music_print")[0].play();
  239. $(".tyrows p:eq(0)").html("<i class='fa fa-2x fa-cog fa-spin'></i> &nbsp; 此运单已过期,系统打印处理中,请勿关闭!");
  240. $(".tyrows p:eq(1)").html("");
  241. $(".tyrows").show();
  242. $.ajax({
  243. url: "/systemfout/fedexhz/",
  244. data: "id="+a.id+"&name="+a.name+"&express="+a.express,
  245. type: "POST",
  246. dataType: "json",
  247. success: function(b)
  248. {
  249. $(".systemwindow").hide();
  250. if (b && b.success)
  251. {
  252. wprinter.pdf(b.data)
  253. setTimeout(function(){
  254. $("#music_print_ok")[0].play();
  255. $(".tyrows").hide();
  256. $(".systemwindow").hide();
  257. $("#music_d")[0].play();
  258. $(".systemwindow div p:eq(0)").html('运单打印完成,请更换为新运单后再次操作出库');
  259. $(".systemwindow div p:eq(1)").html("<font class='wcsj'>确 定</font>");
  260. $(".systemwindow").show();
  261. $("#orderinfo").val("");
  262. $("#orderinfo").focus();
  263. },7000);
  264. }
  265. else
  266. {
  267. $(".tyrows").hide();
  268. $("#music_c")[0].play();
  269. wprinter.sound(b.msg);
  270. $(".systemwindow div p:eq(0)").html(b.msg);
  271. $(".systemwindow div p:eq(1)").html("<font class='wcsj'>确 定</font>");
  272. $(".systemwindow").show();
  273. $("#orderinfo").val("");
  274. $("#orderinfo").focus();
  275. }
  276. }
  277. });
  278. }
  279. else
  280. {
  281. $("#music_d")[0].play();
  282. $("#orderinfo").val("");
  283. $("#weight").val("");
  284. $(".search span").click();
  285. $("#orderinfo").focus();
  286. }
  287. }
  288. else
  289. {
  290. $("#music_c")[0].play();
  291. wprinter.sound(a.msg);
  292. $(".systemwindow div p:eq(0)").html(a.msg);
  293. $(".systemwindow div p:eq(1)").html("<font class='wcsj'>确 定</font>");
  294. $(".systemwindow").prepend("<p class='gth' style='font-size: 200px;color: #F00;font-weight: bolder;text-align: center;'>X</p>");
  295. $(".systemwindow").show();
  296. $("#orderinfo").val("");
  297. //$("#orderinfo").focus();
  298. }
  299. }
  300. });
  301. }
  302. if(typeof systembound != "undefined")
  303. {
  304. $(".search .number").val("");
  305. $(".search .waybill").val("");
  306. $.ajax({
  307. url: "/systembound/out",
  308. data: "number="+$("input[name='outbound']").val()+"&type="+$("select[name='type']").children("option:selected").val()+"&express="+$("select[name='express']").children("option:selected").val(),
  309. type: "POST",
  310. dataType: "json",
  311. success: function(b)
  312. {
  313. searchspan(1);
  314. $(".systemwindow").hide();
  315. if (b && b.success)
  316. {
  317. if(b.music == '1')
  318. {
  319. $("#music_d")[0].play();
  320. }
  321. $(".outbound").html(b.msg);
  322. $("#outbound").val("");
  323. $("#outbound").focus();
  324. }
  325. else
  326. {
  327. $("#outbound").blur();
  328. $("#music_c")[0].play();
  329. wprinter.sound(b.msg);
  330. $(".systemwindow div p:eq(0)").html(b.msg);
  331. $(".systemwindow div p:eq(1)").html("<font class='wcoutbound'>确 定</font>");
  332. $(".systemwindow").show();
  333. $("#outbound").val("");
  334. }
  335. }
  336. });
  337. }
  338. if(typeof systemretreat != "undefined")
  339. {
  340. if($("select[name='printer']").children("option:selected").val() == "")
  341. {
  342. $("#music_c")[0].play();
  343. $(".systemwindow div p:eq(0)").html('需要先选择打印机!');
  344. $(".systemwindow div p:eq(1)").html("<font class='wcsj'>确 定</font>");
  345. $(".systemwindow").show();
  346. $("#orderinfo").val("");
  347. $("#orderinfo").focus();
  348. return;
  349. }
  350. $("#orderinfo").blur();
  351. $(".systemwindow div p:eq(0)").html("<i class='fa fa-2x fa-cog fa-spin'></i> &nbsp; 处理中,请稍后...");
  352. $(".systemwindow div p:eq(1)").html("");
  353. $(".systemwindow").show();
  354. $.ajax({
  355. url: "/systemretreat/out/",
  356. data: "order="+$("#orderinfo").val()+"&weight="+$("#weight").val(),
  357. type: "POST",
  358. dataType: "json",
  359. success: function(a) {
  360. $(".systemwindow").hide();
  361. if (a && a.success)
  362. {
  363. $("#music_d")[0].play();
  364. $("#orderinfo").val("");
  365. $("#weight").val("");
  366. $(".search span").click();
  367. $("#orderinfo").focus();
  368. }
  369. else
  370. {
  371. $("#music_c")[0].play();
  372. wprinter.sound(a.msg);
  373. $(".systemwindow div p:eq(0)").html(a.msg);
  374. $(".systemwindow div p:eq(1)").html("<font class='wcsj'>确 定</font>");
  375. $(".systemwindow").prepend("<p class='gth' style='font-size: 200px;color: #F00;font-weight: bolder;text-align: center;'>X</p>");
  376. $(".systemwindow").show();
  377. $("#orderinfo").val("");
  378. //$("#orderinfo").focus();
  379. }
  380. }
  381. });
  382. }
  383. }
  384. });
  385. $(".excel").click(function() {
  386. var f = "";
  387. $(".select").each(function() {
  388. f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
  389. });
  390. $("input:text").each(function() {
  391. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  392. });
  393. $("input:hidden").each(function() {
  394. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  395. });
  396. var t = "";var i = 0;
  397. $(".datatitle td").each(function() {
  398. if(i>0)
  399. {
  400. t = t + "<td>" + $(this).text() + "</td>";
  401. }
  402. i++;
  403. });
  404. var a = "";
  405. $(".datatext input[name='check']:checked").each(function() {
  406. a = a + $(this).val()+",";
  407. });
  408. f = f + "excel=1&a="+a+"&t="+t;
  409. window.location.href = "/systemfout/excel?fexcel="+$("select[name=fexcel]").find("option:selected").val()+"&"+f;
  410. $("select[name=fexcel] option:eq(0)").prop('selected','selected');
  411. });
  412. $(".cpexcel").click(function() {
  413. var f = "";
  414. $(".select").each(function() {
  415. f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
  416. });
  417. $("input:text").each(function() {
  418. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  419. });
  420. $("input:hidden").each(function() {
  421. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  422. });
  423. var t = "";var i = 0;
  424. $(".datatitle td").each(function() {
  425. if(i>0)
  426. {
  427. t = t + "<td>" + $(this).text() + "</td>";
  428. }
  429. i++;
  430. });
  431. var a = "";
  432. $(".datatext input[name='check']:checked").each(function() {
  433. a = a + $(this).val()+",";
  434. });
  435. f = f + "excel=1&a="+a+"&t="+t;
  436. window.location.href = "/systemfout/cpexcel?fexcel="+$("select[name=fexcel]").find("option:selected").val()+"&"+f;
  437. $("select[name=fexcel] option:eq(0)").prop('selected','selected');
  438. });
  439. $(".exceldy").click(function() {
  440. var f = "";
  441. $(".select").each(function() {
  442. f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
  443. });
  444. $("input:text").each(function() {
  445. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  446. });
  447. $("input:hidden").each(function() {
  448. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  449. });
  450. var t = "";var i = 0;
  451. $(".datatitle td").each(function() {
  452. if(i>0)
  453. {
  454. t = t + "<td>" + $(this).text() + "</td>";
  455. }
  456. i++;
  457. });
  458. var a = "";
  459. $(".datatext input[name='check']:checked").each(function() {
  460. a = a + $(this).val()+",";
  461. });
  462. f = f + "excel=1&a="+a+"&t="+t;
  463. window.location.href = "/systemprint//exceldy?fexcel=1&"+f;
  464. $("select[name=fexcel] option:eq(0)").prop('selected','selected');
  465. });
  466. $(".dowot").click(function() {
  467. var f = "";
  468. $(".select").each(function() {
  469. f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
  470. });
  471. $("input:text").each(function() {
  472. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  473. });
  474. $("input:hidden").each(function() {
  475. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  476. });
  477. window.location.href = "/systembound/excel?fexcel=1&"+f;
  478. $("select[name=fexcel] option:eq(0)").prop('selected','selected');
  479. });
  480. /* 时间计算 */
  481. function getBeforeDate(){//n为你要传入的参数,当前为0,前一天为-1,后一天为1
  482. var myDate = new Date;
  483. var year = myDate.getFullYear(); //获取当前年
  484. var mon = myDate.getMonth() + 1; //获取当前月
  485. var date = myDate.getDate(); //获取当前日
  486. var h = myDate.getHours();//获取当前小时数(0-23)
  487. var m = myDate.getMinutes();//获取当前分钟数(0-59)
  488. var s = myDate.getSeconds();//获取当前秒
  489. var week = myDate.getDay();
  490. var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  491. s = year + '-' + mon + '-' + date + ' ' + h + ':' + m;
  492. return s ;
  493. }
  494. $(".obadd").click(function() {
  495. $(".boundtj div p:eq(0)").html('<label>仓库:<select name="type" class="select">'+$("select[name=type]").html()+'</select></label><label>快递:<select name="express" class="select">'+$("select[name=express]").html()+'</select></label><label>编号:<input value="" name="number" type="text"></label><label>运单:<input value="" name="waybill" type="text"></label><label>时间:<input id="time" value="" name="time" type="text" onclick="laydate({istime: true,format:\'YYYY-MM-DD hh:mm\'})" readonly></label>');
  496. $(".boundtj div p:eq(1)").html("<font class='obaddgo'>确 定</font><font class='esc'>取 消</font>");
  497. $(".boundtj label #time").val(getBeforeDate());
  498. $(".boundtj").show();
  499. });
  500. $(".boundtj").on('click',".obaddgo",function() {
  501. var f = "";
  502. $(".boundtj .select").each(function() {
  503. f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
  504. });
  505. $(".boundtj input:text").each(function() {
  506. f = f + $(this).attr("name") + "=" + $(this).val() + "&";
  507. });
  508. $.ajax({
  509. url: "/systembound/add",
  510. data: f,
  511. type: "POST",
  512. dataType: "json",
  513. success: function(c) {
  514. if (c && c.success)
  515. {
  516. searchspan(1);
  517. $(".boundtj p").html("");
  518. $(".boundtj").hide();
  519. $(".boundtj div p:eq(0)").html(c.msg);
  520. $(".boundtj div p:eq(1)").html("<font class='esc'>确 定</font>");
  521. $(".boundtj").show();
  522. }
  523. else {
  524. $(".ts p").html(c.msg);
  525. $(".ts").show();
  526. setTimeout('$(".ts").fadeOut()', 1000);
  527. }
  528. }
  529. });
  530. });
  531. $(".boundtj").on('click',".esc",function() {
  532. $(".boundtj p").html("");
  533. $(".boundtj").hide();
  534. });