var pageCurr; layui.config({ base: baseUrl + "/static/layui/lay/modules/" }).use(['table','laydate', 'form', 'admin'], function(){ var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var layDate = layui.laydate; var form = layui.form; var admin = layui.admin; // 数据渲染 tableIns = table.render({ elem: '#locOutPrintMat', headers: {token: localStorage.getItem('token')}, url: baseUrl+'/locOutPrintMat/list/auth', page: true, limit: 15, limits: [15, 30, 50, 100, 200, 500], toolbar: '#toolbar', cellMinWidth: 50, height: 'full-120', cols: [[ {type: 'checkbox'} ,{field: 'id', align: 'center',title: 'ID',hide : true} ,{field: 'uuid', align: 'center',title: '编号',hide: true} ,{field: 'status$', align: 'center',title: '打印情况', width:100,hide: false} ,{field: 'matnr', align: 'center',title: '物料编码', width:180,hide: false} ,{field: 'batch', align: 'center',title: '批次', width:100,hide: false} ,{field: 'anfme', align: 'center',title: '重量(kg)', width:100,hide: false} ,{field: 'locNo', align: 'center',title: '库位号', width:120,hide: false} ,{field: 'maktx', align: 'center',title: '商品名称',hide: false} ,{field: 'owner$', align: 'center',title: '货主',hide: false} ,{field: 'createTime$', align: 'center',title: '入库时间', width:120,hide: false} ,{field: 'createBy$', align: 'center',title: '入库人员', width:100,hide: false} ,{field: 'updateTime$', align: 'center',title: '打印时间', width:120,hide: false} ,{field: 'updateBy$', align: 'center',title: '打印人员',hide: false} ,{field: 'memo', align: 'center',title: '备注',hide: false} ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} ]], request: { pageName: 'curr', pageSize: 'limit' }, parseData: function (res) { return { 'code': res.code, 'msg': res.msg, 'count': res.data.total, 'data': res.data.records } }, response: { statusCode: 200 }, done: function(res, curr, count) { if (res.code === 403) { top.location.href = baseUrl+"/"; } pageCurr=curr; limit(); } }); // 监听排序事件 table.on('sort(locOutPrintMat)', function (obj) { var searchData = {}; $.each($('#search-box [name]').serializeArray(), function() { searchData[this.name] = this.value; }); searchData['orderByField'] = obj.field; searchData['orderByType'] = obj.type; tableIns.reload({ where: searchData, page: {curr: 1} }); }); // 监听头工具栏事件 table.on('toolbar(locOutPrintMat)', function (obj) { var checkStatus = table.checkStatus(obj.config.id).data; switch(obj.event) { case 'addData': showEditModel(); break; case 'deleteData': if (checkStatus.length === 0) { layer.msg('请选择要删除的数据', {icon: 2}); return; } del(checkStatus.map(function (d) { return d.id; })); break; case 'exportData': admin.confirm('确定导出Excel吗', {shadeClose: true}, function(){ var titles=[]; var fields=[]; obj.config.cols[0].map(function (col) { if (col.type === 'normal' && col.hide === false && col.toolbar == null) { titles.push(col.title); fields.push(col.field); } }); var exportData = {}; $.each($('#search-box [name]').serializeArray(), function() { exportData[this.name] = this.value; }); var param = { 'locOutPrintMat': exportData, 'fields': fields }; $.ajax({ url: baseUrl+"/locOutPrintMat/export/auth", headers: {'token': localStorage.getItem('token')}, data: JSON.stringify(param), dataType:'json', contentType:'application/json;charset=UTF-8', method: 'POST', success: function (res) { layer.closeAll(); if (res.code === 200) { table.exportFile(titles,res.data,'xls'); } else if (res.code === 403) { top.location.href = baseUrl+"/"; } else { layer.msg(res.msg, {icon: 2}) } } }); }); break; // 批量打印 case "btnPrintBatch": printMatCodeNos = []; var data = checkStatus; if (data.length === 0){ layer.msg('请选择打印数据'); } else { layer.open({ type: 1, title: '批量打印 [数量'+ data.length +']', area: ['500px'], shadeClose: true, content: $('#printDataDiv'), success: function(layero, index){ for (var i = 0; i