qcode_bach.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'LodopFuncs'], function ($, undefined, Backend, Table, Form, LodopFuncs) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init();
  6. this.table.first();
  7. this.table.second();
  8. //绑定
  9. // $('#bind').click(function (e) {
  10. // var ids = $('#table1').bootstrapTable('getSelections')[0]['id'];
  11. //
  12. // $.get('qcode_bach/bind',{'ids':ids},function (data) {
  13. // if(data.code==1){
  14. // Toastr.success(data.msg)
  15. // $('#table2').bootstrapTable('refresh');
  16. // }else{
  17. // Toastr.error(data.msg)
  18. // }
  19. // },'json');
  20. // layer.confirm('确定提交选中的 1 项?!', {
  21. // btn: ['确定', '取消'],
  22. // cancel: function(index, layero) {
  23. // }
  24. // },function (index) {
  25. // $.get('qcode_bach/bind',{'ids':ids},function (data) {
  26. // if(data.code==1){
  27. // Toastr.success(data.msg)
  28. // table2.bootstrapTable('refresh');
  29. // }else{
  30. // Toastr.error(data.msg)
  31. // }
  32. // },'json');
  33. // Layer.close(index);
  34. //
  35. // },function (){})
  36. // })
  37. //绑定
  38. // $('#unbind').click(function (e) {
  39. // layer.confirm('确定提交选中的 1 项?!', {
  40. // btn: ['确定', '取消'],
  41. // cancel: function(index, layero) {
  42. // }
  43. // },function (index) {
  44. // var ids = $('#table2').bootstrapTable('getSelections')[0]['id'];
  45. //
  46. // $.get('qcode_bach/unbind',{'ids':ids},function (data) {
  47. // if(data.code==1){
  48. // Toastr.success(data.msg)
  49. // $('#table2').bootstrapTable('refresh');
  50. // }else{
  51. // Toastr.error(data.msg)
  52. // }
  53. // },'json');
  54. // Layer.close(index);
  55. //
  56. // },function (){})
  57. //
  58. // })
  59. },
  60. table: {
  61. first: function () {
  62. // 表格1
  63. var table1 = $("#table1");
  64. table1.bootstrapTable({
  65. url: 'qcode_bach/table1',
  66. extend: {
  67. index_url: 'qcode_bach/table1' + location.search,
  68. add_url: 'qcode_bach/add',
  69. edit_url: 'qcode_bach/edit',
  70. del_url: 'qcode_bach/del',
  71. table: 'qcode_bach',
  72. },
  73. onClickRow:function(row, $element, field)
  74. {
  75. console.log(JSON.stringify(row));
  76. },
  77. toolbar: '#toolbar1',
  78. pk: 'id',
  79. sortName: 'id',
  80. pageSize: 8,
  81. pageList: [8, 20, 50, 'All'],
  82. search: false,
  83. singleSelect: true,
  84. columns: [
  85. [
  86. {checkbox: true},
  87. {field: 'matter_name', title: __('Matter_name'), operate: 'LIKE'},
  88. {field: 'l_flow', title: __('L_flow'), operate: 'LIKE'},
  89. {field: 'large_endnum', title: __('Large_endnum'), operate: 'LIKE'},
  90. {field: 'bach_num', title: __('Bach_num'), operate: 'LIKE'},
  91. {field: 'larger_num', title: __('Larger_num'), operate: 'LIKE'},
  92. {field: 'print_date', title: __('Print_date'), operate: 'LIKE'},
  93. {field: 'company_name', title: __('Company_name'), operate: 'LIKE'},
  94. {field: 'matter_no', title: __('Matter_no'), operate: 'LIKE'},
  95. // {field: 'notes', title: __('Notes')},
  96. {field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  97. ]
  98. ]
  99. });
  100. // 为表格1绑定事件
  101. Table.api.bindevent(table1);
  102. },
  103. second: function () {
  104. // 表格2
  105. var table2 = $("#table2");
  106. table2.bootstrapTable({
  107. url: 'qcode_bach/table2',
  108. extend: {
  109. index_url: '',
  110. add_url: '',
  111. edit_url: '',
  112. del_url: '',
  113. multi_url: '',
  114. table: '',
  115. },
  116. toolbar: '#toolbar2',
  117. pk: 'id',
  118. sortName: 'id',
  119. pageSize: 8,
  120. pageList: [8, 20, 50, 'All'],
  121. search: false,
  122. singleSelect: true,
  123. columns: [
  124. [
  125. {checkbox: true},
  126. {field: 'l_flow', title: __('当前托盘'), operate: 'LIKE'},
  127. {field: 'code', title: __('Code'), operate: 'LIKE'},
  128. {field: 'print_date', title: __('Print_date'), operate: 'LIKE'},
  129. {field: 'p_nums', title: __('P_nums'), operate: 'LIKE'},
  130. {field: 'small_num', title: __('Small_num'), operate: 'LIKE'},
  131. {field: 'l_weight', title: __('L_weight'), operate: 'LIKE'},
  132. {field: 'l_print', title: __('L_print'), operate: 'LIKE'},
  133. {field: 'l_status', title: __('L_status'), operate: 'LIKE'},
  134. // {field: 'notes', title: __('Notes')},
  135. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  136. ]
  137. ]
  138. });
  139. // 为表格2绑定事件
  140. Table.api.bindevent(table2);
  141. }
  142. },
  143. /*recyclebin: function () {
  144. // 初始化表格参数配置
  145. Table.api.init({
  146. extend: {
  147. 'dragsort_url': ''
  148. }
  149. });
  150. var table = $("#table");
  151. // 初始化表格
  152. table.bootstrapTable({
  153. url: 'qcode_bach/recyclebin' + location.search,
  154. pk: 'id',
  155. sortName: 'id',
  156. columns: [
  157. [
  158. {checkbox: true},
  159. {field: 'id', title: __('Id')},
  160. {field: 'name', title: __('Name'), align: 'left'},
  161. {
  162. field: 'deletetime',
  163. title: __('Deletetime'),
  164. operate: 'RANGE',
  165. addclass: 'datetimerange',
  166. formatter: Table.api.formatter.datetime
  167. },
  168. {
  169. field: 'operate',
  170. width: '140px',
  171. title: __('Operate'),
  172. table: table,
  173. events: Table.api.events.operate,
  174. buttons: [
  175. {
  176. name: 'Restore',
  177. text: __('Restore'),
  178. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  179. icon: 'fa fa-rotate-left',
  180. url: 'qcode_bach/restore',
  181. refresh: true
  182. },
  183. {
  184. name: 'Destroy',
  185. text: __('Destroy'),
  186. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  187. icon: 'fa fa-times',
  188. url: 'qcode_bach/destroy',
  189. refresh: true
  190. }
  191. ],
  192. formatter: Table.api.formatter.operate
  193. }
  194. ]
  195. ]
  196. });
  197. // 为表格绑定事件
  198. Table.api.bindevent(table);
  199. },*/
  200. add: function () {
  201. Controller.api.bindevent();
  202. },
  203. edit: function () {
  204. Controller.api.bindevent();
  205. },
  206. reprint: function () {
  207. $("#sel-n").data("params", function (obj) {
  208. //obj为SelectPage对象
  209. return {custom: {name: $("#sel-n").val()}};
  210. });
  211. $("#sel-p").data("params", function (obj) {
  212. //obj为SelectPage对象
  213. return {custom: {name: $("#sel-p").val()}};
  214. });
  215. $("#sel-c").data("params", function (obj) {
  216. //obj为SelectPage对象
  217. return {custom: {name: $("#sel-c").val()}};
  218. });
  219. $("#btn").click(function (e) {
  220. e.preventDefault();
  221. var data = $("form").serialize();
  222. $.post('qcode_bach/reprint',{data},function (res) {
  223. if (res.code==1){
  224. //打印二维码
  225. var html = '<style type="text/css">\n' +
  226. '.tg {border-collapse:collapse;border-spacing:0;font-weight:500;}\n' +
  227. '.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}\n' +
  228. '.tg .tg-s6z2{text-align:center;}\n' +
  229. '</style>\n' +
  230. '<div width="340px">\n' +
  231. '<table class="tg" width="340px">\n' +
  232. '<caption style="width: 300px;">'+res.data.company_name+'</caption>\n' +
  233. '<tr>\n' +
  234. '<td style="width: 70px;">规格:</td>\n' +
  235. '<td colspan="5" style="word-break:break-all;border-color:black;">'+res.data.product_name+'</td>\n' +
  236. '</tr>\n' +
  237. '<tr>\n' +
  238. '<td>配盘数:</td>\n' +
  239. '<td colspan="2">'+res.data.sqrcd+'</td>\n' +
  240. '<td>辅单位:</td>\n' +
  241. '<td colspan="2">'+res.data.sec_unit+'</td>\n' +
  242. '</tr>\n' +
  243. '<tr>\n' +
  244. '<td>数量:</td>\n' +
  245. '<td colspan="2">'+res.data.num+'</td>\n' +
  246. '<td>主单位:</td>\n' +
  247. '<td colspan="2">'+res.data.main_unit+'</td>\n' +
  248. '</tr>\n' +
  249. '<tr>\n' +
  250. '<td>生产日期:</td>\n' +
  251. '<td colspan="5">'+res.data.date+'</td>\n' +
  252. '</tr>\n' +
  253. '<tr>\n' +
  254. '<td>生产批号:</td>\n' +
  255. '<td colspan="5">'+res.data.batch+'</td>\n' +
  256. '</tr>\n' +
  257. '<tr>\n' +
  258. '<td colspan="6" style="word-break:break-all; border-color:black; font-size: 13px;">'+res.data.qrcode+'</td>\n' +
  259. '</tr>\n' +
  260. '</table>\n' +
  261. '<div style="position:absolute;top: 300px;left: 47px">\n' +
  262. '<img src="'+res.data.pCode+'" > </td>\n' +
  263. '</div>\n' +
  264. '<div style="position:absolute;top: 400px;left: 300px;width: 50px;text-align: center;"><span style="font-weight: 500;word-break:normal;font-size: 16px">大件号'+res.data.l_flow+'</span></div>\n' +
  265. '</div>';
  266. var printPdf = (html,qrcode) => {
  267. let LODOP=getLodop();
  268. LODOP.SET_LICENSES("","152A06E8F6CBD6AC1F213ABFCB0D8604","C94CEE276DB2187AE6B65D56B3FC2848","");
  269. LODOP.PRINT_INIT("河南中烟大件二维码打码");
  270. LODOP.SET_PRINT_STYLE("FontSize",16);
  271. LODOP.SET_PRINT_STYLE("Bold",1);
  272. LODOP.SET_PRINT_PAGESIZE(1, 1000, 1500, "CreateCustomPage");
  273. LODOP.ADD_PRINT_HTM(15,20,350,545,html);
  274. // LODOP.SET_PRINT_STYLEA(0,"QRCodeVersion",14);
  275. // LODOP.SET_PRINT_STYLEA(0,"QRCodeErrorLevel","M");
  276. // LODOP.ADD_PRINT_BARCODE(18,715,'27mm','27mm',"QRCode",qrcode);
  277. // LODOP.PRINT() // 直接打印
  278. // LODOP.PRINT_DESIGN() // 设计模式
  279. LODOP.PREVIEW() //打印预览
  280. }
  281. printPdf(html)
  282. }else{
  283. Toastr.error(res.msg);
  284. }
  285. })
  286. })
  287. Controller.api.bindevent();
  288. },
  289. api: {
  290. bindevent: function () {
  291. Form.api.bindevent($("form[role=form]"));
  292. }
  293. }
  294. };
  295. return Controller;
  296. });