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(); this.table.first(); this.table.second(); Controller.api.bindevent(); }, table:{ first:function (){ var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: 'deliver/lager', pk: 'id', height:600, sortName: 'id', pagination: false, // 关闭分页功能 toolbar:'#toolbar', 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: '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}', // 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+= ''; // html+= ''; // // if(arr[i].mater_type==1){ // html+=''; // 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].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].small_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; // }, success: function (data, res) { console.log(data); console.log(res); if (res.code === 1) { var arr = res.data.data; let html = `
`; for (let i = 0; i < arr.length; 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].small_num}
// // // //
发货单位:${res.data.supplier_name}司机/司机电话:${res.data.deliveryman}   ${res.data.shr_phone}车牌号:${res.data.plate_number}
发货单位地址:${res.data.address}收货单位(签名、盖章)
// `; $("#printcode").html(html); // 正确绑定 load 事件并打印 // let image = document.getElementById('qrcode_image'); // image.onload = function () { 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; });