| | |
| | | where: where, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | toolbar: '#toolbar', |
| | | cols: [[ |
| | | {type: 'checkbox', width: 70}, |
| | | {type: 'numbers'}, |
| | | {field: 'orderNo', title: '单据编号', templet: '#orderNoTpl',sort:true}, |
| | | {field: 'docType$', align: 'center', title: '类型', minWidth: 160, width: 160,sort:true}, |
| | |
| | | $("#orderAddBtn").click(function () { |
| | | showEditModel(); |
| | | }); |
| | | // Excel导出 |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(order)', function (obj) { |
| | | var data = table.checkStatus(obj.config.id).data; |
| | | switch (obj.event) { |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | |
| | | titles.push("订单编号"); |
| | | titles.push("品号"); |
| | | titles.push("品名"); |
| | | titles.push("订单数量"); |
| | | titles.push("完成数量"); |
| | | titles.push("作业中数量"); |
| | | titles.push("创建时间"); |
| | | |
| | | fields.push("orderNo"); |
| | | fields.push("matnr"); |
| | | fields.push("maktx"); |
| | | fields.push("anfme"); |
| | | fields.push("qty"); |
| | | fields.push("workQty"); |
| | | fields.push("createTime$"); |
| | | |
| | | |
| | | var orderNos = []; |
| | | data.forEach(function(elem) { |
| | | console.log("elem="+elem.settle); |
| | | if(elem.payType >0) { |
| | | co = 1; |
| | | } |
| | | orderNos.push(elem.orderNo); |
| | | }); |
| | | var param = { |
| | | 'orderNo': orderNos, |
| | | 'fields' : fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/order/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) |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | $("#orderExcel").click(function () { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | var data = checkStatus.data; |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | if (data.length === 0){ |
| | | layer.msg('请选择数据'); |
| | | } else { |
| | | var titles=[]; |
| | | var fields=[]; |
| | | data.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 = { |
| | | 'wrkMast': exportData, |
| | | 'fields': fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/order/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) |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | |
| | | }); |
| | | |
| | | // 工具条点击事件 |
| | | table.on('tool(order)', function (obj) { |