| | |
| | | ]; |
| | | arrRemove(detlCols, "field", "anfme") |
| | | arrRemove(detlCols, "field", "zpallet") |
| | | arrRemove(detlCols, "field", "orderNo") |
| | | arrRemove(detlCols, "field", "memo") |
| | | cols.push.apply(cols, detlCols); |
| | | // cols.push({field: 'anfme', align: 'center',title: '数量', style: 'font-weight: bold'} |
| | | // ) |
| | |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | switch(obj.event) { |
| | | case 'exportAll': |
| | | layer.closeAll(); |
| | | layer.load(1, {shade: [0.1,'#fff']}); |
| | | location.href = baseUrl + "/locDetl/statis/export"; |
| | | layer.closeAll('loading'); |
| | | break; |
| | | case 'exportData': |
| | | layer.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); |
| | | } |
| | | }); |
| | | layer.confirm('确定导出Excel吗?', {shadeClose: true}, function(){ |
| | | // 收集搜索条件 |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | |
| | | var param = { |
| | | 'locDetl': exportData, |
| | | 'fields': fields |
| | | locDetl: exportData |
| | | }; |
| | | |
| | | $.ajax({ |
| | | url: baseUrl+"/locDetl/export/auth", |
| | | url: baseUrl + "/locDetl/statis/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | 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'); |
| | | if (res.code === 200 && res.data && res.data.length > 0) { |
| | | var titles = ['库存数量', '商品编号', '商品名称', '采购单号', '条码UPC', '单箱净重(kg)', '客户PO']; |
| | | var fieldKeys = ['anfme', 'matnr', 'maktx', 'boxType3', 'standby2', 'weight', 'standby1']; |
| | | |
| | | var exportData = res.data.map(function(item) { |
| | | return [ |
| | | item.anfme || '', |
| | | item.matnr || '', |
| | | item.maktx || '', // 如果 maktx 为空可默认 |
| | | item.boxType3 || '', |
| | | item.standby2 || '', |
| | | item.weight || '', |
| | | item.standby1 || '' // 如字段是 order_no 改成 item.order_no |
| | | ]; |
| | | }); |
| | | |
| | | table.exportFile(titles, exportData, 'xls'); |
| | | layer.msg('导出成功,共 ' + res.data.length + ' 条数据', {icon: 1}); |
| | | } else if (res.code === 200) { |
| | | layer.msg('没有符合条件的数据可导出', {icon: 2}); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | layer.msg(res.msg || '导出失败'); |
| | | } |
| | | }, |
| | | error: function() { |
| | | layer.closeAll(); |
| | | layer.msg('网络错误,导出失败'); |
| | | } |
| | | }); |
| | | }); |