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:300, sortName: 'id', toolbar:'#toolbar', searchFormVisible:true, 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: '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}, ] ] }); //导出发货按钮 $('.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) { return false; },function (data) { return false; }) }) // 为表格绑定事件 Table.api.bindevent(table); //去掉时间区间记忆 table.on('post-body.bs.table',function (e,settings,json,xhr) { $('.datetimerange').each(function () { $(this).attr('autocomplete','off'); }) }); //复选框全选事件 table.on('check-all.bs.table',function (e,rows){ var lagerlist = ''; for (i=0;i\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":'已发货',"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:'2', 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; });