Index.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. 
  2. var selectedRow;
  3. var refreshGirdData;
  4. var typnum = 1;
  5. var logbegin = '';
  6. var logend = '';
  7. var bootstrap = function ($, learun) {
  8. "use strict";
  9. var page = {
  10. init: function () {
  11. page.initGird();
  12. page.bind();
  13. },
  14. bind: function () {
  15. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  16. // 调用后台查询
  17. // queryJson 查询条件
  18. queryJson["Btime"] = logbegin;
  19. queryJson["Etime"] = logend;
  20. console.log(queryJson);
  21. page.search({ queryJson: JSON.stringify(queryJson) });
  22. }, 250);
  23. // 条码类型
  24. $('#F_barType').DataItemNumSelect({
  25. code: 'EBarCodeType',
  26. parentId: 'EBarCodeType'
  27. });
  28. $('.datetime').each(function () {
  29. $(this).lrdatetime({
  30. dfdata: [
  31. { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  32. { name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  33. { name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  34. { name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  35. ],
  36. // 月
  37. mShow: false,
  38. premShow: false,
  39. // 季度
  40. jShow: false,
  41. prejShow: false,
  42. // 年
  43. ysShow: false,
  44. yxShow: false,
  45. preyShow: false,
  46. yShow: false,
  47. // 默认
  48. dfvalue: 'all',
  49. selectfn: function (begin, end) {
  50. logbegin = begin;
  51. logend = end;
  52. }
  53. });
  54. });
  55. // 查询
  56. $('#btn_Search').on('click', function () {
  57. var keyword = $('#txt_Keyword').val();
  58. page.search({ queryJson: JSON.stringify({ Btime: logbegin, Etime: logend, keyword: $('#txt_Keyword').val() }) });
  59. });
  60. // 刷新
  61. $('#lr_refresh').on('click', function () {
  62. location.reload();
  63. });
  64. $('#lr_import').on('click', function () {
  65. learun.layerForm({
  66. id: 'ImportForm',
  67. title: '导入Excel数据',
  68. url: top.$.rootUrl + '/Utility/ImportForm?ordertype=' + typnum,
  69. width: 600,
  70. height: 300,
  71. maxmin: true,
  72. btn: null
  73. });
  74. });
  75. // 新增
  76. $('#lr_add').on('click', function () {
  77. selectedRow = null;
  78. learun.layerForm({
  79. id: 'form',
  80. title: '新增',
  81. url: top.$.rootUrl + '/BaseManager/BaseBarCode/Form',
  82. width: 500,
  83. height: 280,
  84. callBack: function (id) {
  85. return top[id].acceptClick(refreshGirdData);
  86. }
  87. });
  88. });
  89. $('#btn_Print').on('click', function () {
  90. //$("#printIframe").attr("src", "/DataFiles/test.pdf");
  91. //setTimeout(function () {
  92. // document.getElementById('printIframe').contentWindow.print();
  93. //}, 200);
  94. var postData = $('#gridtable').jfGridGet("rowdata");
  95. if (postData != "") {
  96. if (postData.length == 0) {
  97. learun.alert.error('未选择行项目!');
  98. return false;
  99. }
  100. var options = { format: "CODE128", displayValue: false, fontSize: 12, height: 60 };
  101. var htmls = "";
  102. var i = 0;
  103. $.each(postData, function (index, dbdata) {
  104. //htmls += "<div style='width: 100%;'>";
  105. //htmls += "<div style='text-align: center;font-size: 28px;'>" + warehouseName + " </div>";
  106. htmls += "<div id='DivbarCode" + i + "'style='margin:0 auto;width: 244px;white-space:nowrap ;'>";
  107. htmls += "<svg id='BarCode" + i + "'> </svg>";
  108. htmls += "<div id='showText" + i + "' style='margin-top:0; text-align: center;font-size:12px;'></div>";
  109. htmls += "</div>";
  110. //htmls += "</div>";
  111. htmls += "<div style='page-break-after: always;'></div>";
  112. i = i + 1;
  113. });
  114. $("#pringWarea").html(htmls);
  115. i = 0;
  116. $.each(postData, function (index, dbdata) {
  117. var barcode = document.getElementById('BarCode' + i);
  118. var barval = dbdata["F_barCode"];
  119. JsBarcode(barcode, barval, options);
  120. var widths = $("#BarCode" + i).width();
  121. $("#DivbarCode" + i).width(widths);
  122. $("#showText" + i).text(barval);
  123. i = i + 1;
  124. });
  125. doPrint();
  126. var frist = JSON.stringify(postData);
  127. var datas = {};
  128. datas["postData"] = frist;
  129. $.lrSaveForm(top.$.rootUrl + '/BaseManager/BaseBarCode/PrintBarCode', datas, function (data) {
  130. if (data.IsSucc == false) {
  131. learun.alert.error(data.info);
  132. return
  133. }
  134. // page.printPdf(data.data);
  135. //$("#printIframe").attr("src", data.data);
  136. //setTimeout(function () {
  137. // document.getElementById('printIframe').contentWindow.print();
  138. //}, 200);
  139. });
  140. }
  141. });
  142. },
  143. initGird: function () {
  144. $('#gridtable').jfGrid({
  145. url: top.$.rootUrl + '/BaseManager/BaseBarCode/GetPageList',
  146. headData: [
  147. { label: 'ID', name: 'F_no', width: 50, align: "left" },
  148. { label: '条码值', name: 'F_barCode', width: 120, align: "left" },
  149. {
  150. label: '条码类型', name: 'F_barType', width: 100, align: "left"
  151. , formatterAsync: function (callback, value, row) {
  152. learun.clientdata.getAsync('dataItem', {
  153. Rowkey: value,
  154. GrpCode: 'EBarCodeType',
  155. getType: 'Num',
  156. callback: function (item) {
  157. callback(item.F_NAME);
  158. }
  159. });
  160. }
  161. },
  162. { label: '打印时间', name: 'F_printTime', width: 120, align: "left" },
  163. { label: '打印人', name: 'F_printUserNo', width: 120, align: "left" },
  164. { label: '打印次数', name: 'F_printNumber', width: 120, align: "left" },
  165. { label: '创建人', name: 'F_addUserNo', width: 120, align: "left" },
  166. { label: '创建时间', name: 'F_addTime', width: 120, align: "left" }
  167. ],
  168. mainId: 'F_no',
  169. sidx: 'F_no',
  170. isPage: true,
  171. isMultiselect: true,
  172. });
  173. page.search({ queryJson: JSON.stringify({ Btime: logbegin, Etime: logend, keyword: $('#txt_Keyword').val() }) });
  174. },
  175. search: function (param) {
  176. param = param || {};
  177. $('#gridtable').jfGridSet('reload', param);
  178. },
  179. printPdf: function (pdf) {
  180. var iframe = document.createElement('iframe');
  181. iframe.style.display = "none";
  182. iframe.src = pdf;
  183. document.body.appendChild(iframe);
  184. //iframe.contentWindow.focus();
  185. iframe.contentWindow.print();
  186. }
  187. };
  188. refreshGirdData = function () {
  189. page.search();
  190. };
  191. page.init();
  192. }