deliver.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $('#lager').click(function () {
  5. $('#iframe1').contentWindow.location.reload('lager.html');
  6. });
  7. Controller.api.bindevent();
  8. },
  9. // lager: function () {
  10. // // 初始化表格参数配置
  11. // Table.api.init({
  12. // extend: {
  13. // index_url: 'deliver/lager', // 替换为你的后端接口地址
  14. // }
  15. // });
  16. //
  17. // var table = $("#table");
  18. //
  19. // // 初始化表格
  20. // table.bootstrapTable({
  21. // url: $.fn.bootstrapTable.defaults.extend.index_url,
  22. // toolbar: '#toolbar', // 工具栏选择器(如果有)
  23. // pk: 'id', // 主键字段
  24. // sortName: 'id', // 默认排序字段
  25. //
  26. // pagination: true, // 启用分页
  27. // sidePagination: 'server', // 服务器端分页
  28. // pageSize: 10, // 每页数量
  29. // pageList: [10, 25, 50, 100], // 可选页数
  30. // search: false, // 是否启用搜索
  31. // commonSearch: true, // 是否启用 FastAdmin 搜索栏
  32. // queryParams: function (params) {
  33. // return {
  34. // offset: params.offset,
  35. // limit: params.limit,
  36. // filter: JSON.stringify(params.filter), // 搜索条件
  37. // op: JSON.stringify(params.op) // 搜索操作符
  38. // };
  39. // },
  40. //
  41. // columns: [
  42. // {field: 'bach', title: '工单号'},
  43. // {field: 'tray_num', title: '托盘号'},
  44. // {field: 'matter_name', title: '物料名称'},
  45. // {field: 'bach', title: '批次号'},
  46. // {field: 'total_boxes', title: '每托箱数'},
  47. // {field: 'tray_num', title: '每层箱数'},
  48. // {field: 'box_num', title: '每托层数'},
  49. // {field: 'pallet_height', title: '每托高度'},
  50. // {field: 'larger_num', title: '总箱数'},
  51. // {field: 'manufacture_date', title: '生产日期'},
  52. // {field: 'code', title: '大件编码'},
  53. // // 添加更多字段...
  54. // ]
  55. // });
  56. //
  57. // // 绑定事件
  58. // Table.api.bindevent(table);
  59. // },
  60. lager: function () {
  61. // 初始化表格参数配置
  62. Table.api.init();
  63. this.table.first();
  64. this.table.second();
  65. Controller.api.bindevent();
  66. },
  67. table:{
  68. first:function (){
  69. var table = $("#table");
  70. // 初始化表格
  71. table.bootstrapTable({
  72. url: 'deliver/lager', // 请求的 URL
  73. pk: 'id', // 主键字段
  74. height: 700, // 表格的高度
  75. sortName: 'id', // 默认排序字段
  76. sortOrder: 'desc', // 默认排序顺序
  77. pageSize: 50, // 每页显示 10 条数据
  78. pageList: [10, 25, 50, 100,'ALL'], // 分页条数选择器
  79. searchFormVisible: true, // 是否显示搜索框
  80. onClickRow:function(row, $element, field)
  81. {
  82. // 点击行事件
  83. $("#myTabContent1 .form-commonsearch input[name='large_id']").val(row.id);
  84. $("#myTabContent1 .btn-refresh").trigger("click");
  85. },
  86. search: false, // 禁用默认搜索框
  87. showToggle: false, // 隐藏切换按钮
  88. showColumns: false, // 隐藏列选择按钮
  89. showExport: false, // 隐藏导出按钮
  90. columns: [
  91. [
  92. {checkbox: true},
  93. {field: 'id', title: 'ID', visible:false,operate: false},
  94. {field: 'bach', title: __('批次号'),operate: "LIKE"},
  95. {field: 'l_flow', title: __('托盘号'), operate: false},
  96. {field: 'matter_name', title: __('产品名称'), operate: 'LIKE',searchList: $.getJSON("deliver/matterName")},
  97. {field: 'total_boxes', title: "每托箱数", operate: false},
  98. {field: 'tray_num', title: "每层箱数", operate: false},
  99. {field: 'box_num', title: "每托层数", operate: false},
  100. {field: 'pallet_height', title: "每托高度", operate: false},
  101. {
  102. field: 'pallet_size',
  103. title: '托盘规格',
  104. operate: false,
  105. width: 120,
  106. formatter: function (value, row, index) {
  107. return row.pallet_length + ' * ' + row.pallet_width;
  108. }
  109. },
  110. // {field: 'small_num', title: "托盘数", operate: false},
  111. {field: 'larger_num', title: "总箱数", operate: false},
  112. {field: 'manufacture_date', title: '生产日期', operate: 'RANGE', addclass: 'datetimerange',datetimeFormat:'YYYY-MM-DD', formatter: Table.api.formatter.datetime},
  113. {field: 'code', title: __('大件编码'), operate: false},
  114. // {field: 'small_num', title: __('小件数'),operate: false},
  115. ]
  116. ]
  117. });
  118. // 监听复选框点击事件
  119. $('#table').on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function(e, rows) {
  120. var selectedData = table.bootstrapTable('getSelections'); // 获取选中的数据
  121. // 计算选中的大件数量和小件数量
  122. // 大件数量(选中的行数)
  123. var largeItemCount = selectedData.length;
  124. var smallItemCount = selectedData.reduce(function(total, row) {
  125. // 累加每个选中项的 small_num
  126. return total + (row.small_num || 0);
  127. }, 0);
  128. // 更新页面上的提示信息
  129. $('p span').eq(1).text(largeItemCount); // 更新大件数量
  130. $('p span').eq(3).text(smallItemCount); // 更新小件数量
  131. });
  132. //导出发货按钮
  133. $('.btn-print').on('click',function () {
  134. var ids = Table.api.selectedids(table);
  135. if (ids.length === 0){
  136. alert('至少选择一个大件');
  137. }
  138. var lager = ids.toString();
  139. // window.location.href = 'print?lager_id='+lager;
  140. Fast.api.ajax({
  141. url:'deliver/print',
  142. data:{lager_id:lager},
  143. },function (data,res) {
  144. if (res.code == 1){
  145. window.location.href = '/'+res.data;
  146. table.bootstrapTable('refresh');
  147. }
  148. return false;
  149. },function (data,res) {
  150. if (res.code == 0){
  151. layer.confirm(res.msg);
  152. }
  153. return false;
  154. })
  155. })
  156. // 为表格绑定事件
  157. Table.api.bindevent(table);
  158. //去掉时间区间记忆
  159. table.on('post-body.bs.table',function (e,settings,json,xhr) {
  160. $('.datetimerange').each(function () {
  161. $(this).attr('autocomplete','off');
  162. })
  163. });
  164. }, second:function(){
  165. //小件列表
  166. var smallTable = $('#small_table');
  167. smallTable.bootstrapTable({
  168. url:'deliver/smallList',
  169. height: 600,
  170. toolbar: '#toolbar1',
  171. search:false,
  172. // commonSearch:false,
  173. showToggle:false,
  174. showColumns:false,
  175. showExport:false,
  176. columns: [
  177. [
  178. {field: 'large_id',title: __('大件id'),operate: 'LIKE',visible:false},
  179. {field: 'code', title: __('小件标签代码'),operate: false},
  180. {field: 'l_flow', title: __('当前序号'),operate: false},
  181. {field: 'print_num', title: __('打印次数'),operate: false},
  182. {field: 'status', title: __('状态'),searchList: {"0":'正常',"1":'已删除'},operate: false,formatter: Table.api.formatter.status},
  183. ]
  184. ]
  185. });
  186. // 为表格绑定事件
  187. Table.api.bindevent(smallTable);
  188. }
  189. },
  190. apply: function () {
  191. // 初始化表格参数配置
  192. Table.api.init({
  193. extend: {
  194. index_url: 'deliver/apply' + location.search,
  195. goods_url: 'deliver/goods',
  196. del_url:'deliver/apply_del',
  197. table:'deliver'
  198. }
  199. });
  200. var table = $("#table2");
  201. // 初始化表格
  202. table.bootstrapTable({
  203. url: $.fn.bootstrapTable.defaults.extend.index_url,
  204. pk: 'id',
  205. height:400,
  206. sortName: 'id',
  207. searchFormVisible:true,
  208. search:false,
  209. showToggle:false,
  210. showColumns:false,
  211. showExport:false,
  212. fixedColumns: true,
  213. fixedRightNumber: 1,
  214. columns: [
  215. [
  216. {checkbox: true},
  217. {field: 'id', title: __('Id'),visible:false,operate: false},
  218. {field: 'large_num', title: '托盘数量', operate: false},
  219. {field: 'matter_name', title: '产品名称', operate: 'LIKE',searchList: $.getJSON("deliver/matterName")},
  220. {field: 'total_boxes', title: '每箱托数', operate: false},
  221. {field: 'tray_num', title: '每层箱数', operate: false},
  222. {field: 'box_num', title: '每托层数', operate: false},
  223. {field: 'pallet_height', title: '托盘高度', operate: false},
  224. {
  225. field: 'pallet_size',
  226. title: '托盘规格',
  227. operate: false,
  228. width: 120,
  229. formatter: function (value, row, index) {
  230. return row.pallet_length + ' * ' + row.pallet_width;
  231. }
  232. },
  233. // {field: 'small_num', title: '总箱数', operate: false},
  234. {field: 'larger_num', title: '总箱数', operate: false},
  235. // {field: 'matter_no', title: '产品编码', operate: false},
  236. {field: 'username', title: '所属用户', operate: 'LIKE'},
  237. // {field: 'large_num', title: '大件数量', operate: false},
  238. // {field: 'small_num', title: '小件数量', operate: false},
  239. {field: 'create_time', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  240. {field: 'file_dir', title: '下载路径', operate: false,formatter: function (value,row,index) {
  241. if (row.status == 0){
  242. return "<a href=/"+value+">点击下载</a>";
  243. }else {
  244. return "不支持下载";
  245. }
  246. }},
  247. {field: 'status', title: '状态', operate: 'LIKE',searchList: {"0":'待发货',"1":'已删除'}, formatter: Table.api.formatter.status},
  248. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  249. ]
  250. ],
  251. });
  252. // 为表格绑定事件
  253. Table.api.bindevent(table);
  254. //发货按钮
  255. $('.btn-goods').on('click',function () {
  256. var ids = Table.api.selectedids(table);
  257. if (ids.length === 0){
  258. alert('至少选择一个订单');
  259. }
  260. var id_str = ids.toString();
  261. Fast.api.open('deliver/goods?ids='+id_str,'发货信息',{area:["60%","60%"]})
  262. });
  263. //去掉时间区间输入记忆
  264. table.on('post-body.bs.table',function (e,settings,json,xhr) {
  265. $('.datetimerange').each(function () {
  266. $(this).attr('autocomplete','off');
  267. })
  268. });
  269. Controller.api.bindevent();
  270. },
  271. goods: function () {
  272. $('#apply_btn').click(function () {
  273. var ids = $('#goods_id').val();
  274. var order_number = $('#c-order_number').val();
  275. if (order_number == null || order_number === ''){
  276. layer.confirm('订单号不能为空');
  277. }
  278. var deliveryman = $('#c-deliveryman').val();
  279. if (deliveryman == null || deliveryman === ''){
  280. layer.confirm('司机名称不能为空');
  281. }
  282. var shr_phone = $('#c-shr_phone').val();
  283. if (shr_phone == null || shr_phone === ''){
  284. layer.confirm('手机号不能为空');
  285. }
  286. var plate_number = $('#c-plate_number').val();
  287. if (plate_number == null || plate_number === ''){
  288. layer.confirm('车牌号不能为空');
  289. }
  290. var note = $('#c-note').val();
  291. Fast.api.ajax({
  292. url:'deliver/apply_add',
  293. data:{
  294. ids:ids,
  295. order_number:order_number,
  296. deliveryman:deliveryman,
  297. shr_phone:shr_phone,
  298. plate_number:plate_number,
  299. note:note,
  300. }
  301. },function (data,res) {
  302. parent.Toastr.success("成功");
  303. Fast.api.close();
  304. window.parent.location.reload();
  305. return false;
  306. },function (data) {
  307. parent.Toastr.error('失败');
  308. Fast.api.close();
  309. window.parent.location.reload();
  310. return false;
  311. })
  312. });
  313. Controller.api.bindevent();
  314. },
  315. dispatch: function () {
  316. // 初始化表格参数配置
  317. Table.api.init({
  318. extend: {
  319. index_url: 'deliver/dispatch' + location.search,
  320. del_url:'deliver/dispatch_del',
  321. table:'deliver'
  322. }
  323. });
  324. var table = $("#table3");
  325. // 初始化表格
  326. table.bootstrapTable({
  327. url: $.fn.bootstrapTable.defaults.extend.index_url,
  328. pk: 'id',
  329. height:400,
  330. sortName: 'id',
  331. searchFormVisible:true,
  332. showToggle:false,
  333. showColumns:false,
  334. showExport:false,
  335. fixedColumns: true,
  336. fixedRightNumber: 1,
  337. columns: [
  338. [
  339. {checkbox: true},
  340. {field: 'id', title: __('Id'),visible:false,operate: false},
  341. {field: 'shdh', title: '收货单号', operate: false},
  342. {field: 'order_number', title: '订单号', operate: 'LIKE'},
  343. {field: 'deliveryman', title: '司机', operate: false},
  344. {field: 'plate_number', title: '车牌号', operate: false},
  345. {field: 'supplier_name', title: '供应商名称', operate: 'LIKE'},
  346. {field: 'create_time', title: '发货时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  347. {field: 'buttons',
  348. width: "120px",
  349. title: __('发货单打印'),
  350. operate: false,
  351. table: table,
  352. events: Table.api.events.operate,
  353. buttons: [
  354. {
  355. name: 'ajax',
  356. text: __('点击打印'),
  357. title: __('点击打印'),
  358. classname: 'btn btn-xs btn-success btn-magic btn-ajax',
  359. icon: 'fa fa-magic',
  360. url: 'deliver/printqrcode/id/{ids}',
  361. success: function (data, res) {
  362. if (res.code === 1) {
  363. const arr = res.data.data;
  364. let totalTray = 0;
  365. let totalBox = 0;
  366. const productNames = [];
  367. const productQuantities = [];
  368. // 遍历数据,统计数量
  369. for (let i = 0; i < arr.length; i++) {
  370. totalTray += parseInt(arr[i].large_num || 0);
  371. totalBox += parseInt(arr[i].larger_num || 0);
  372. productNames.push(arr[i].matter_name);
  373. productQuantities.push(arr[i].total_boxes * arr[i].larger_num);
  374. }
  375. // 根据出货数量计算手工盒子数量
  376. const manualBoxes = productQuantities.reduce((total, qty) => total + qty, 0);
  377. // 纸质卡片数量可按业务设定(例:每托2张)
  378. const paperCards = totalTray * totalBox;
  379. let html = `
  380. <div style="width: 1100px; height: 100px; position: relative;">
  381. <div style="float: left">
  382. <div style="width: 1000px; font-size: 28px; font-weight: bold; text-align: center; line-height: 50px;">${res.data.supplier_name}</div>
  383. <div style="width: 1000px; font-size: 24px; text-align: center; line-height: 50px;">送货单</div>
  384. </div>
  385. <div id="qrcode" style="position: absolute; right: 100px; top: -5px; width: 105px; height: 105px;">
  386. <img src="${res.data.qrcode_add}" style="width: 105px; height: 105px;" id="qrcode_image"/>
  387. </div>
  388. </div>
  389. <table style="margin-bottom: 10px; width: 1186px; font-weight: 500; border-collapse: collapse;">
  390. <tr>
  391. <td colspan="6" style="border: none;">客户名称:河南中烟工业有限责任公司黄金叶生产制造中心</td>
  392. <td colspan="4" style="border: none;">送货单号:<span id="shdh">${res.data.shdh}</span></td>
  393. </tr>
  394. <tr>
  395. <td colspan="6" style="border: none;">送货地址:河南省郑州市经开区第三大街9号</td>
  396. <td colspan="4" style="border: none;">送货日期:<span id="shrq_date">${res.data.shrq_date}</span></td>
  397. </tr>
  398. </table>
  399. <div style="width: 1070px; font-size: 20px; text-align: center; border: 1px solid black; border-bottom: none;">
  400. ${res.data.order_ddbh || ''}${res.data.note || ''}
  401. </div>
  402. <table style="width: 1070px; border-collapse: collapse; table-layout: fixed; font-size: 16px; text-align: center; margin-top: 0;">
  403. <tr style="font-weight: bold;">
  404. <th style="border: 1px solid black;text-align: center;">托盘序号</th>
  405. <th style="border: 1px solid black;text-align: center; width: 360px;">产品名称</th>
  406. <th style="border: 1px solid black;text-align: center;">每托箱数</th>
  407. <th style="border: 1px solid black;text-align: center;">每层箱数</th>
  408. <th style="border: 1px solid black;text-align: center;">每托层数</th>
  409. <th style="border: 1px solid black;text-align: center;">每托高度</th>
  410. <th style="border: 1px solid black;text-align: center;">托盘规格</th>
  411. <th style="border: 1px solid black;text-align: center;">托盘数</th>
  412. <th style="border: 1px solid black;text-align: center;">总箱数</th>
  413. </tr>
  414. `;
  415. for (let i = 0; i < arr.length; i++) {
  416. html += `
  417. <tr>
  418. <td style="border: 1px solid black;">第${arr[i].large_ber}托</td>
  419. <td style="border: 1px solid black;">${arr[i].matter_name}</td>
  420. <td style="border: 1px solid black;">${arr[i].total_boxes}</td>
  421. <td style="border: 1px solid black;">${arr[i].tray_num}</td>
  422. <td style="border: 1px solid black;">${arr[i].box_num}</td>
  423. <td style="border: 1px solid black;">${arr[i].pallet_height}</td>
  424. <td style="border: 1px solid black;">${arr[i].pallet_length} * ${arr[i].pallet_width}</td>
  425. <td style="border: 1px solid black;">${arr[i].large_num}</td>
  426. <td style="border: 1px solid black;">${arr[i].larger_num}</td>
  427. </tr>
  428. `;
  429. }
  430. const fillCount = 15 - arr.length;
  431. for (let i = 0; i < fillCount; i++) {
  432. html += `
  433. <tr>
  434. <td style="border: 1px solid black;">&nbsp;</td>
  435. <td style="border: 1px solid black;"></td>
  436. <td style="border: 1px solid black;"></td>
  437. <td style="border: 1px solid black;"></td>
  438. <td style="border: 1px solid black;"></td>
  439. <td style="border: 1px solid black;"></td>
  440. <td style="border: 1px solid black;"></td>
  441. <td style="border: 1px solid black;"></td>
  442. <td style="border: 1px solid black;"></td>
  443. </tr>
  444. `;
  445. }
  446. html += `
  447. <tr style="font-weight: bold;">
  448. <td style="border: 1px solid black;">合计:</td>
  449. <td style="border: 1px solid black;"></td>
  450. <td style="border: 1px solid black;"></td>
  451. <td style="border: 1px solid black;"></td>
  452. <td style="border: 1px solid black;"></td>
  453. <td style="border: 1px solid black;"></td>
  454. <td style="border: 1px solid black;"></td>
  455. <td style="border: 1px solid black;">${totalTray}</td>
  456. <td style="border: 1px solid black;">${totalBox}</td>
  457. </tr>
  458. </table>
  459. <table style="margin-top: 20px; width: 1070px; border-collapse: collapse; font-size: 18px;">
  460. <tr>
  461. <td colspan="${productNames.length + 2}" style="border: 1px solid black; text-align: left;">
  462. 总共出货:${totalBox} 箱 = ${totalTray} 托(手工盒子:${manualBoxes} 套,纸质卡片:${paperCards} 张)
  463. </td>
  464. </tr>
  465. <tr>
  466. <td style="border: 1px solid black; text-align: center;">产品名称</td>
  467. ${productNames.map(name => `<td style="border: 1px solid black; text-align: center;">${name}</td>`).join('')}
  468. <td style="border: 1px solid black; text-align: center;">合计</td>
  469. </tr>
  470. <tr>
  471. <td style="border: 1px solid black; text-align: center;">出货数量</td>
  472. ${productQuantities.map(qty => `<td style="border: 1px solid black; text-align: center;">${qty}</td>`).join('')}
  473. <td style="border: 1px solid black; text-align: center;">${manualBoxes}</td>
  474. </tr>
  475. </table>
  476. <div style="margin-top: 20px; font-size: 14px; font-weight: bold; border: 1px solid black; padding: 10px; text-align: left; width: 1070px;">
  477. 共 ${totalTray} 托
  478. <br/>
  479. 备注:
  480. <br/>(1) 用唛头笔写上托盘序号,托盘唛头打印贴在每托盘上面,打托的时候混托注意摆放和高度,另外不要漏掉了。
  481. <br/>(2) 每托烟盒中间放瓦楞,最上面盖个木板,缠绕膜缠结实,护角护好,打打包带,井子形打包
  482. <br/>(3) 配托后,请提供具体托盘高度及托盘重量。
  483. </div>
  484. `;
  485. $("#printcode").html(html);
  486. var ee = $('#qrcode_image').attr('src',res.data.qrcode_add);
  487. // 将打印的区域赋值,进行打印
  488. ee.on('load',function () {
  489. var printHTML = document.querySelector('#printcode').innerHTML;
  490. window.document.body.innerHTML = printHTML;
  491. window.print();
  492. window.location.reload(); // 打印完成后重新加载页面
  493. })
  494. // const printHTML = document.querySelector('#printcode').innerHTML;
  495. // document.body.innerHTML = printHTML;
  496. // window.print();
  497. // window.location.reload();
  498. }
  499. return false;
  500. },
  501. error: function (data, ret) {
  502. return false;
  503. }
  504. },
  505. ],
  506. formatter: Table.api.formatter.buttons
  507. },
  508. {field: 'status', title: '状态', operate: 'LIKE',searchList: {"0":'已发货',"1":'已删除'}, formatter: Table.api.formatter.status},
  509. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  510. ]
  511. ],
  512. });
  513. // 为表格绑定事件
  514. Table.api.bindevent(table);
  515. //去掉时间区间输入记忆
  516. table.on('post-body.bs.table',function (e,settings,json,xhr) {
  517. $('.datetimerange').each(function () {
  518. $(this).attr('autocomplete','off');
  519. })
  520. });
  521. Controller.api.bindevent();
  522. },
  523. receive: function () {
  524. // 初始化表格参数配置
  525. Table.api.init({
  526. extend: {
  527. index_url: 'deliver/receive' + location.search,
  528. del_url:'deliver/receive_del',
  529. table:'deliver'
  530. }
  531. });
  532. var table = $("#table");
  533. // 初始化表格
  534. table.bootstrapTable({
  535. url: $.fn.bootstrapTable.defaults.extend.index_url,
  536. pk: 'id',
  537. height:500,
  538. sortName: 'id',
  539. searchFormVisible:true,
  540. showToggle:false,
  541. showColumns:false,
  542. showExport:false,
  543. fixedColumns: true,
  544. fixedRightNumber: 1,
  545. columns: [
  546. [
  547. {checkbox: true},
  548. {field: 'id', title: __('Id'),visible:false,operate: false},
  549. {field: 'shdh', title: '送货单号', operate: false},
  550. {field: 'order_number', title: '订单号', operate: 'LIKE'},
  551. {field: 'deliveryman', title: '司机', operate: false},
  552. {field: 'plate_number', title: '车牌号', operate: false},
  553. {field: 'supplier_name', title: '供应商名称', operate: 'LIKE'},
  554. {field: 'create_time', title: '发货时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  555. {field: 'buttons', operate: false,
  556. width: "120px",
  557. title: __('发货单打印'),
  558. table: table,
  559. events: Table.api.events.operate,
  560. buttons: [
  561. {
  562. name: 'ajax',
  563. text: __('点击打印'),
  564. title: __('点击打印'),
  565. classname: 'btn btn-xs btn-success btn-magic btn-ajax',
  566. icon: 'fa fa-magic',
  567. url: 'deliver/printqrcode/id/{ids}',
  568. // confirm: '确认发送',
  569. success: function (data,res) {
  570. if (res.code === 1){
  571. var arr = res.data.data;
  572. var note='';
  573. var html = '<div style="width: 1100px;height: 100px;position: relative;">\n' +
  574. ' <div style="float: left">\n' +
  575. ' <div style="width: 1000px;font-weight: 400;font-size: 28px;text-align: center;line-height: 50px;" class="company">'+res.data.supplier_name+'</div>\n' +
  576. ' <div style="width: 1000px;font-weight: 400;font-size: 24px;text-align: center;line-height: 50px;">送货单</div>\n' +
  577. ' </div>\n' +
  578. ' <div id="qrcode" style="display:inline-block;width: 105px;height: 105px;position: absolute;right: 100px;top: -5px;">\n' +
  579. ' <img src="" style="width: 105px;height: 105px;" id="qrcode_image"/>\n' +
  580. ' </div>\n' +
  581. ' </div>\n' +
  582. ' <table class="tg1" style="margin-top: 3px;border-collapse:collapse;border-spacing:0;font-weight:500;width:1186px">\n' +
  583. ' <tr class="info">\n' +
  584. ' <td colspan="6" style="border:none">客户名称:河南中烟工业有限责任公司黄金叶生产制造中心</td>\n' +
  585. ' <td colspan="4" style="border:none">送货单号:<span style="font-size: 16px;" id="shdh">'+res.data.shdh+'</span></td>\n' +
  586. ' </tr>\n' +
  587. ' <tr class="info">\n' +
  588. ' <td colspan="6" style="border:none">送货地址:河南省郑州市经开区第三大街9号</td>\n' +
  589. ' <td colspan="4" style="border:none">送货日期:<span style="font-size: 16px;" id="shrq_date">'+res.data.shrq_date+'</span></td>\n' +
  590. ' </tr>\n' +
  591. ' </table>\n' +
  592. ' <br>\n' +
  593. ' <table class="tg1" style="table-layout:fixed;width: 1186px;border-collapse:collapse;border-spacing:0;font-weight:500; position: relative;" id="table">'+
  594. ' <tr><th class="tg-s6z2" style="font-family:Arial, sans-serif;font-size:20px;text-align:center;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;">物料名称</th>' +
  595. ' <th class="tg-s6z2" style="font-family:Arial, sans-serif;font-size:20px;text-align:center;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;">生产批号</th>' +
  596. ' <th class="tg-s6z2" style="font-family:Arial, sans-serif;font-size:20px;text-align:center;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;">大件</th>' +
  597. ' <th class="tg-s6z2" style="font-family:Arial, sans-serif;font-size:20px;text-align:center;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;">小件</th>' +
  598. ' <th class="tg-s6z2" style="font-family:Arial, sans-serif;font-size:20px;text-align:center;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;">单位</th>' +
  599. ' <th class="tg-s6z2" style="font-family:Arial, sans-serif;font-size:20px;text-align:center;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;">实发数量</th>' +
  600. ' <th class="tg-s6z2" style="font-family:Arial, sans-serif;font-size:20px;text-align:center;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;">备注</th>' +
  601. ' <th id="explain" rowspan="'+(res.data.count+1)+'" width="7%" style="border: none"><span style="writing-mode: tb-rl;height: 300px;font-size:16px;text-align: center;">' +
  602. ' 蓝联(回):业务 黄联(回):运输 '+'<br>'+'白联:存根 红联:财务 绿联:客户</span></th></tr>';
  603. for (var i=0;i < arr.length;i++){
  604. html+= '<tr><td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].matter_name+'</td>';
  605. html+= '<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+(arr[i].bach_num?arr[i].bach_num:'')+'</td>';
  606. html+= '<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].large_num+'</td>';
  607. html+= '<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].small_num+'</td>';
  608. if(arr[i].mater_type==1){
  609. html+= '<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">万张</td>';
  610. html+='<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].l_num+'</td>';
  611. html+='<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].small_num+'件*'+parseInt(arr[i].num)+'张'+'</td>';
  612. }else if (arr[i].mater_type==2){
  613. html+= '<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">kg</td>';
  614. html+='<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].l_weight +'</td>';
  615. html+='<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].small_num+'件*'+parseFloat(arr[i].num)/1000+'kg'+'</td>';
  616. }else if (arr[i].mater_type==3){
  617. html+= '<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">万支</td>';
  618. html+='<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+parseFloat(arr[i].num)*parseFloat(arr[i].small_num)/10000+'</td>';
  619. html+='<td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+arr[i].small_num+'件*'+parseInt(arr[i].num)+'支'+'</td>';
  620. }
  621. }
  622. html+= '<tr><td class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">送货单备注</td>' +
  623. ' <td colspan="6" class="tg-031e" style="font-family:Arial, sans-serif;font-size:18px;text-align:center;border-style:solid;border-width:1px;overflow:hidden;word-break:break-all;border-color:black;">'+res.data.note+'</td></tr>'+
  624. ' </table>\n' +
  625. ' <table class="tg2" style="margin-top: 3px;border-collapse:collapse;border-spacing:0;font-weight:500;width:1086px;font-size: 16px;">\n' +
  626. ' <tr class="footer">\n' +
  627. ' <td colspan="3">发货单位:<span class="company">'+res.data.supplier_name+'</span></td>\n' +
  628. ' <td colspan="3">司机/司机电话:<span id="deliveryman">'+res.data.deliveryman+'&nbsp;&nbsp;'+res.data.shr_phone+'</span></td>\n' +
  629. ' <td colspan="3">车牌号:<span id="carid">'+res.data.plate_number+'</span></td>\n' +
  630. ' </tr>\n' +
  631. ' <tr class="footer">\n' +
  632. ' <td colspan="7">发货单位地址:<span id="address">'+res.data.address+'</span></td>\n' +
  633. ' <td colspan="3">收货单位(签名、盖章)</td>\n' +
  634. ' </tr>\n' +
  635. ' </table>'
  636. $("#printcode").html(html)
  637. var ee = $('#qrcode_image').attr('src',res.data.qrcode_add);
  638. // 将打印的区域赋值,进行打印
  639. ee.on('load',function () {
  640. var printHTML = document.querySelector('#printcode').innerHTML;
  641. window.document.body.innerHTML = printHTML;
  642. window.print();
  643. window.location.reload(); // 打印完成后重新加载页面
  644. })
  645. }
  646. return false;
  647. },
  648. error: function (data, ret) {
  649. return false;
  650. }
  651. },
  652. ],
  653. formatter: Table.api.formatter.buttons
  654. },
  655. {field: 'status', title: '状态', operate: 'LIKE',searchList: {"0":'未收货',"2":'已收货'},defaultValue:'1', formatter: Table.api.formatter.status},
  656. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  657. ]
  658. ],
  659. });
  660. $('#receive').click(function (){
  661. var shdh = $('#shdh').val();
  662. if (shdh!=''){
  663. $.get('deliver/receive_add',{'shdh':shdh},function (res){
  664. if (res.code==1){
  665. //修改成功
  666. //1. 提示
  667. Toastr.success(res.msg)
  668. //2. 刷新页面
  669. table.bootstrapTable('refresh');
  670. }else{
  671. Toastr.error(res.msg)
  672. }
  673. })
  674. }
  675. })
  676. // 为表格绑定事件
  677. Table.api.bindevent(table);
  678. Controller.api.bindevent();
  679. },
  680. api: {
  681. bindevent: function () {
  682. Form.api.bindevent($("form[role=form]"));
  683. }
  684. }
  685. };
  686. return Controller;
  687. });