From 51889b97a85b070cbb80a5bb2893149c80448d5d Mon Sep 17 00:00:00 2001
From: 1 <1>
Date: 星期二, 30 十二月 2025 16:31:15 +0800
Subject: [PATCH] #导出优化

---
 src/main/webapp/static/js/locDetlStatis/locDetlStatis.js |   60 ++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/src/main/webapp/static/js/locDetlStatis/locDetlStatis.js b/src/main/webapp/static/js/locDetlStatis/locDetlStatis.js
index fd1da33..a1adf70 100644
--- a/src/main/webapp/static/js/locDetlStatis/locDetlStatis.js
+++ b/src/main/webapp/static/js/locDetlStatis/locDetlStatis.js
@@ -5,6 +5,8 @@
     ];
     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'}
     // )
@@ -103,45 +105,55 @@
         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('缃戠粶閿欒锛屽鍑哄け璐�');
                         }
                     });
                 });

--
Gitblit v1.9.1