define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { $('#lager').click(function () { $('#iframe1').contentWindow.location.reload('lager.html'); }); Controller.api.bindevent(); }, // lager: function () { // // 初始化表格参数配置 // Table.api.init({ // extend: { // index_url: 'deliver/lager', // 替换为你的后端接口地址 // } // }); // // var table = $("#table"); // // // 初始化表格 // table.bootstrapTable({ // url: $.fn.bootstrapTable.defaults.extend.index_url, // toolbar: '#toolbar', // 工具栏选择器(如果有) // pk: 'id', // 主键字段 // sortName: 'id', // 默认排序字段 // // pagination: true, // 启用分页 // sidePagination: 'server', // 服务器端分页 // pageSize: 10, // 每页数量 // pageList: [10, 25, 50, 100], // 可选页数 // search: false, // 是否启用搜索 // commonSearch: true, // 是否启用 FastAdmin 搜索栏 // queryParams: function (params) { // return { // offset: params.offset, // limit: params.limit, // filter: JSON.stringify(params.filter), // 搜索条件 // op: JSON.stringify(params.op) // 搜索操作符 // }; // }, // // columns: [ // {field: 'bach', title: '工单号'}, // {field: 'tray_num', title: '托盘号'}, // {field: 'matter_name', title: '物料名称'}, // {field: 'bach', title: '批次号'}, // {field: 'total_boxes', title: '每托箱数'}, // {field: 'tray_num', title: '每层箱数'}, // {field: 'box_num', title: '每托层数'}, // {field: 'pallet_height', title: '每托高度'}, // {field: 'larger_num', title: '总箱数'}, // {field: 'manufacture_date', title: '生产日期'}, // {field: 'code', title: '大件编码'}, // // 添加更多字段... // ] // }); // // // 绑定事件 // Table.api.bindevent(table); // }, lager: function () { // 初始化表格参数配置 Table.api.init(); this.table.first(); this.table.second(); Controller.api.bindevent(); }, table:{ first:function (){ var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: 'deliver/lager', // 请求的 URL pk: 'id', // 主键字段 height: 700, // 表格的高度 sortName: 'id', // 默认排序字段 sortOrder: 'desc', // 默认排序顺序 pageSize: 50, // 每页显示 10 条数据 pageList: [10, 25, 50, 100,'ALL'], // 分页条数选择器 searchFormVisible: true, // 是否显示搜索框 onClickRow:function(row, $element, field) { // 点击行事件 $("#myTabContent1 .form-commonsearch input[name='large_id']").val(row.id); $("#myTabContent1 .btn-refresh").trigger("click"); }, search: false, // 禁用默认搜索框 showToggle: false, // 隐藏切换按钮 showColumns: false, // 隐藏列选择按钮 showExport: false, // 隐藏导出按钮 columns: [ [ {checkbox: true}, {field: 'id', title: 'ID', visible:false,operate: false}, {field: 'bach', title: __('批次号'),operate: "LIKE"}, {field: 'l_flow', title: __('托盘号'), operate: false}, {field: 'matter_name', title: __('产品名称'), operate: 'LIKE',searchList: $.getJSON("deliver/matterName")}, {field: 'total_boxes', title: "每托箱数", operate: false}, {field: 'tray_num', title: "每层箱数", operate: false}, {field: 'box_num', title: "每托层数", operate: false}, {field: 'pallet_height', title: "每托高度", operate: false}, { field: 'pallet_size', title: '托盘规格', operate: false, width: 120, formatter: function (value, row, index) { return row.pallet_length + ' * ' + row.pallet_width; } }, // {field: 'small_num', title: "托盘数", operate: false}, {field: 'larger_num', title: "总箱数", operate: false}, {field: 'manufacture_date', title: '生产日期', operate: 'RANGE', addclass: 'datetimerange',datetimeFormat:'YYYY-MM-DD', formatter: Table.api.formatter.datetime}, {field: 'code', title: __('大件编码'), operate: false}, // {field: 'small_num', title: __('小件数'),operate: false}, ] ] }); // 监听复选框点击事件 $('#table').on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function(e, rows) { var selectedData = table.bootstrapTable('getSelections'); // 获取选中的数据 // 计算选中的大件数量和小件数量 // 大件数量(选中的行数) var largeItemCount = selectedData.length; var smallItemCount = selectedData.reduce(function(total, row) { // 累加每个选中项的 small_num return total + (row.small_num || 0); }, 0); // 更新页面上的提示信息 $('p span').eq(1).text(largeItemCount); // 更新大件数量 $('p span').eq(3).text(smallItemCount); // 更新小件数量 }); //导出发货按钮 $('.btn-print').on('click',function () { var ids = Table.api.selectedids(table); if (ids.length === 0){ alert('至少选择一个大件'); } var lager = ids.toString(); // window.location.href = 'print?lager_id='+lager; Fast.api.ajax({ url:'deliver/print', data:{lager_id:lager}, },function (data,res) { if (res.code == 1){ window.location.href = '/'+res.data; table.bootstrapTable('refresh'); } return false; },function (data,res) { if (res.code == 0){ layer.confirm(res.msg); } return false; }) }) // 为表格绑定事件 Table.api.bindevent(table); //去掉时间区间记忆 table.on('post-body.bs.table',function (e,settings,json,xhr) { $('.datetimerange').each(function () { $(this).attr('autocomplete','off'); }) }); }, second:function(){ //小件列表 var smallTable = $('#small_table'); smallTable.bootstrapTable({ url:'deliver/smallList', height: 600, toolbar: '#toolbar1', search:false, // commonSearch:false, showToggle:false, showColumns:false, showExport:false, columns: [ [ {field: 'large_id',title: __('大件id'),operate: 'LIKE',visible:false}, {field: 'code', title: __('小件标签代码'),operate: false}, {field: 'l_flow', title: __('当前序号'),operate: false}, {field: 'print_num', title: __('打印次数'),operate: false}, {field: 'status', title: __('状态'),searchList: {"0":'正常',"1":'已删除'},operate: false,formatter: Table.api.formatter.status}, ] ] }); // 为表格绑定事件 Table.api.bindevent(smallTable); } }, apply: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'deliver/apply' + location.search, goods_url: 'deliver/goods', del_url:'deliver/apply_del', table:'deliver' } }); var table = $("#table2"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', height:400, sortName: 'id', searchFormVisible:true, search:false, showToggle:false, showColumns:false, showExport:false, fixedColumns: true, fixedRightNumber: 1, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id'),visible:false,operate: false}, {field: 'large_num', title: '托盘数量', operate: false}, {field: 'matter_name', title: '产品名称', operate: 'LIKE',searchList: $.getJSON("deliver/matterName")}, {field: 'total_boxes', title: '每箱托数', operate: false}, {field: 'tray_num', title: '每层箱数', operate: false}, {field: 'box_num', title: '每托层数', operate: false}, {field: 'pallet_height', title: '托盘高度', operate: false}, { field: 'pallet_size', title: '托盘规格', operate: false, width: 120, formatter: function (value, row, index) { return row.pallet_length + ' * ' + row.pallet_width; } }, // {field: 'small_num', title: '总箱数', operate: false}, {field: 'larger_num', title: '总箱数', operate: false}, // {field: 'matter_no', title: '产品编码', operate: false}, {field: 'username', title: '所属用户', operate: 'LIKE'}, // {field: 'large_num', title: '大件数量', operate: false}, // {field: 'small_num', title: '小件数量', operate: false}, {field: 'create_time', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime}, {field: 'file_dir', title: '下载路径', operate: false,formatter: function (value,row,index) { if (row.status == 0){ return "点击下载"; }else { return "不支持下载"; } }}, {field: 'status', title: '状态', operate: 'LIKE',searchList: {"0":'待发货',"1":'已删除'}, formatter: Table.api.formatter.status}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], }); // 为表格绑定事件 Table.api.bindevent(table); //发货按钮 $('.btn-goods').on('click',function () { var ids = Table.api.selectedids(table); if (ids.length === 0){ alert('至少选择一个订单'); } var id_str = ids.toString(); Fast.api.open('deliver/goods?ids='+id_str,'发货信息',{area:["60%","60%"]}) }); //去掉时间区间输入记忆 table.on('post-body.bs.table',function (e,settings,json,xhr) { $('.datetimerange').each(function () { $(this).attr('autocomplete','off'); }) }); Controller.api.bindevent(); }, goods: function () { $('#apply_btn').click(function () { var ids = $('#goods_id').val(); var order_number = $('#c-order_number').val(); if (order_number == null || order_number === ''){ layer.confirm('订单号不能为空'); } var deliveryman = $('#c-deliveryman').val(); if (deliveryman == null || deliveryman === ''){ layer.confirm('司机名称不能为空'); } var shr_phone = $('#c-shr_phone').val(); if (shr_phone == null || shr_phone === ''){ layer.confirm('手机号不能为空'); } var plate_number = $('#c-plate_number').val(); if (plate_number == null || plate_number === ''){ layer.confirm('车牌号不能为空'); } var note = $('#c-note').val(); Fast.api.ajax({ url:'deliver/apply_add', data:{ ids:ids, order_number:order_number, deliveryman:deliveryman, shr_phone:shr_phone, plate_number:plate_number, note:note, } },function (data,res) { parent.Toastr.success("成功"); Fast.api.close(); window.parent.location.reload(); return false; },function (data) { parent.Toastr.error('失败'); Fast.api.close(); window.parent.location.reload(); return false; }) }); Controller.api.bindevent(); }, dispatch: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'deliver/dispatch' + location.search, del_url:'deliver/dispatch_del', table:'deliver' } }); var table = $("#table3"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', height:400, sortName: 'id', searchFormVisible:true, showToggle:false, showColumns:false, showExport:false, fixedColumns: true, fixedRightNumber: 1, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id'),visible:false,operate: false}, {field: 'shdh', title: '收货单号', operate: false}, {field: 'order_number', title: '订单号', operate: 'LIKE'}, {field: 'deliveryman', title: '司机', operate: false}, {field: 'plate_number', title: '车牌号', operate: false}, {field: 'supplier_name', title: '供应商名称', operate: 'LIKE'}, {field: 'create_time', title: '发货时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime}, {field: 'buttons', width: "120px", title: __('发货单打印'), operate: false, table: table, events: Table.api.events.operate, buttons: [ { name: 'ajax', text: __('点击打印'), title: __('点击打印'), classname: 'btn btn-xs btn-success btn-magic btn-ajax', icon: 'fa fa-magic', url: 'deliver/printqrcode/id/{ids}', success: function (data, res) { if (res.code === 1) { const arr = res.data.data; let totalTray = 0; let totalBox = 0; const productNames = []; const productQuantities = []; // 遍历数据,统计数量 for (let i = 0; i < arr.length; i++) { totalTray += parseInt(arr[i].large_num || 0); totalBox += parseInt(arr[i].larger_num || 0); productNames.push(arr[i].matter_name); productQuantities.push(arr[i].total_boxes * arr[i].larger_num); } // 根据出货数量计算手工盒子数量 const manualBoxes = productQuantities.reduce((total, qty) => total + qty, 0); // 纸质卡片数量可按业务设定(例:每托2张) const paperCards = totalTray * totalBox; let html = `
${res.data.supplier_name}
送货单
客户名称:河南中烟工业有限责任公司黄金叶生产制造中心 送货单号:${res.data.shdh}
送货地址:河南省郑州市经开区第三大街9号 送货日期:${res.data.shrq_date}
${res.data.order_ddbh || ''}${res.data.note || ''}
`; for (let i = 0; i < arr.length; i++) { html += ` `; } const fillCount = 15 - arr.length; for (let i = 0; i < fillCount; i++) { html += ` `; } html += `
托盘序号 产品名称 每托箱数 每层箱数 每托层数 每托高度 托盘规格 托盘数 总箱数
第${arr[i].large_ber}托 ${arr[i].matter_name} ${arr[i].total_boxes} ${arr[i].tray_num} ${arr[i].box_num} ${arr[i].pallet_height} ${arr[i].pallet_length} * ${arr[i].pallet_width} ${arr[i].large_num} ${arr[i].larger_num}
 
合计: ${totalTray} ${totalBox}
${productNames.map(name => ``).join('')} ${productQuantities.map(qty => ``).join('')}
总共出货:${totalBox} 箱 = ${totalTray} 托(手工盒子:${manualBoxes} 套,纸质卡片:${paperCards} 张)
产品名称${name}合计
出货数量${qty}${manualBoxes}
共 ${totalTray} 托
备注:
(1) 用唛头笔写上托盘序号,托盘唛头打印贴在每托盘上面,打托的时候混托注意摆放和高度,另外不要漏掉了。
(2) 每托烟盒中间放瓦楞,最上面盖个木板,缠绕膜缠结实,护角护好,打打包带,井子形打包
(3) 配托后,请提供具体托盘高度及托盘重量。
`; $("#printcode").html(html); var ee = $('#qrcode_image').attr('src',res.data.qrcode_add); // 将打印的区域赋值,进行打印 ee.on('load',function () { var printHTML = document.querySelector('#printcode').innerHTML; window.document.body.innerHTML = printHTML; window.print(); window.location.reload(); // 打印完成后重新加载页面 }) // const printHTML = document.querySelector('#printcode').innerHTML; // document.body.innerHTML = printHTML; // window.print(); // window.location.reload(); } return false; }, error: function (data, ret) { return false; } }, ], formatter: Table.api.formatter.buttons }, {field: 'status', title: '状态', operate: 'LIKE',searchList: {"0":'已发货',"1":'已删除'}, formatter: Table.api.formatter.status}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], }); // 为表格绑定事件 Table.api.bindevent(table); //去掉时间区间输入记忆 table.on('post-body.bs.table',function (e,settings,json,xhr) { $('.datetimerange').each(function () { $(this).attr('autocomplete','off'); }) }); Controller.api.bindevent(); }, receive: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'deliver/receive' + location.search, del_url:'deliver/receive_del', table:'deliver' } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', height:500, sortName: 'id', searchFormVisible:true, showToggle:false, showColumns:false, showExport:false, fixedColumns: true, fixedRightNumber: 1, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id'),visible:false,operate: false}, {field: 'shdh', title: '送货单号', operate: false}, {field: 'order_number', title: '订单号', operate: 'LIKE'}, {field: 'deliveryman', title: '司机', operate: false}, {field: 'plate_number', title: '车牌号', operate: false}, {field: 'supplier_name', title: '供应商名称', operate: 'LIKE'}, {field: 'create_time', title: '发货时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime}, {field: 'buttons', operate: false, width: "120px", title: __('发货单打印'), table: table, events: Table.api.events.operate, buttons: [ { name: 'ajax', text: __('点击打印'), title: __('点击打印'), classname: 'btn btn-xs btn-success btn-magic btn-ajax', icon: 'fa fa-magic', url: 'deliver/printqrcode/id/{ids}', // confirm: '确认发送', success: function (data,res) { if (res.code === 1){ var arr = res.data.data; var note=''; var html = '
\n' + '
\n' + '
'+res.data.supplier_name+'
\n' + '
送货单
\n' + '
\n' + '
\n' + ' \n' + '
\n' + '
\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + '
客户名称:河南中烟工业有限责任公司黄金叶生产制造中心送货单号:'+res.data.shdh+'
送货地址:河南省郑州市经开区第三大街9号送货日期:'+res.data.shrq_date+'
\n' + '
\n' + ' '+ ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' '; for (var i=0;i < arr.length;i++){ html+= ''; html+= ''; html+= ''; html+= ''; if(arr[i].mater_type==1){ html+= ''; html+=''; html+=''; }else if (arr[i].mater_type==2){ html+= ''; html+=''; html+=''; }else if (arr[i].mater_type==3){ html+= ''; html+=''; html+=''; } } html+= '' + ' '+ '
物料名称生产批号大件小件单位实发数量备注' + ' 蓝联(回):业务 黄联(回):运输 '+'
'+'白联:存根 红联:财务 绿联:客户
'+arr[i].matter_name+''+(arr[i].bach_num?arr[i].bach_num:'')+''+arr[i].large_num+''+arr[i].small_num+'万张'+arr[i].l_num+''+arr[i].small_num+'件*'+parseInt(arr[i].num)+'张'+'kg'+arr[i].l_weight +''+arr[i].small_num+'件*'+parseFloat(arr[i].num)/1000+'kg'+'万支'+parseFloat(arr[i].num)*parseFloat(arr[i].small_num)/10000+''+arr[i].small_num+'件*'+parseInt(arr[i].num)+'支'+'
送货单备注'+res.data.note+'
\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + '
' $("#printcode").html(html) var ee = $('#qrcode_image').attr('src',res.data.qrcode_add); // 将打印的区域赋值,进行打印 ee.on('load',function () { var printHTML = document.querySelector('#printcode').innerHTML; window.document.body.innerHTML = printHTML; window.print(); window.location.reload(); // 打印完成后重新加载页面 }) } return false; }, error: function (data, ret) { return false; } }, ], formatter: Table.api.formatter.buttons }, {field: 'status', title: '状态', operate: 'LIKE',searchList: {"0":'未收货',"2":'已收货'},defaultValue:'1', formatter: Table.api.formatter.status}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ], }); $('#receive').click(function (){ var shdh = $('#shdh').val(); if (shdh!=''){ $.get('deliver/receive_add',{'shdh':shdh},function (res){ if (res.code==1){ //修改成功 //1. 提示 Toastr.success(res.msg) //2. 刷新页面 table.bootstrapTable('refresh'); }else{ Toastr.error(res.msg) } }) } }) // 为表格绑定事件 Table.api.bindevent(table); Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });