From 99458a90a21032ed17dd7ecf48ddb42051577438 Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期三, 12 十一月 2025 08:26:33 +0800
Subject: [PATCH] API接口日志导出excel列错乱修复

---
 src/main/webapp/static/js/apiLog/apiLog.js |   45 ++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/src/main/webapp/static/js/apiLog/apiLog.js b/src/main/webapp/static/js/apiLog/apiLog.js
index 1d24b5e..dbdd365 100644
--- a/src/main/webapp/static/js/apiLog/apiLog.js
+++ b/src/main/webapp/static/js/apiLog/apiLog.js
@@ -25,20 +25,20 @@
             // ,{field: 'id', align: 'center',title: 'ID'}
             // ,{field: 'uuid', align: 'center',title: '鏃ュ織缂栧彿'}
             ,{field: 'namespace', align: 'center',title: '鍚嶇О绌洪棿'}
-            ,{field: 'url', align: 'center',title: '琛ㄥ崟ID'}
-            ,{field: 'appkey', align: 'center',title: '骞冲彴瀵嗛挜',hide: true}
+            ,{field: 'url', align: 'center',title: '璇锋眰璺緞'}
+            // ,{field: 'appkey', align: 'center',title: '骞冲彴瀵嗛挜',hide: true}
             // ,{field: 'timestamp', align: 'center',title: '鏃堕棿鎴�'}
-            ,{field: 'clientIp', align: 'center',title: 'URL',hide: true}
+            // ,{field: 'clientIp', align: 'center',title: 'URL',hide: true}
             ,{field: 'request', align: 'center',title: '璇锋眰鍐呭'}
-            ,{field: 'response', align: 'center',title: '鎿嶄綔鍐呭'}
+            ,{field: 'response', align: 'center',title: '鍝嶅簲鍐呭'}
             // ,{field: 'err', align: 'center',title: '寮傚父鍐呭'}
             ,{field: 'result$', align: 'center',title: '缁撴灉', templet: '#resTpl', width: 80}
             // ,{field: 'status$', align: 'center',title: '鐘舵��'}
             ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'}
             // ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'}
-            ,{field: 'memo', align: 'center',title: '澶囨敞', hide: true}
+            // ,{field: 'memo', align: 'center',title: '澶囨敞', hide: true}
 
-            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width: 80}
+            // ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width: 80}
         ]],
         request: {
             pageName: 'curr',
@@ -122,7 +122,38 @@
                         success: function (res) {
                             layer.closeAll();
                             if (res.code === 200) {
-                                table.exportFile(titles,res.data,'xls');
+                                var rows = res.data.map(function(arr) {
+                                    return {
+                                        namespace: arr[0],
+                                        url: arr[1],
+                                        request: arr[2],
+                                        response: arr[3],
+                                        result$: arr[4],
+                                        createTime$: arr[5]
+                                    };
+                                });
+                                // 鏍煎紡鍖� JSON 瀛楁锛堝彧澶勭悊 request 鍜� response锛�
+                                var fixedData = rows.map(function(item){
+                                    var newItem = {};
+                                    fields.forEach(function(f){
+                                        var val = item[f];
+                                        if (f === 'request' || f === 'response') {
+                                            if (val) {
+                                                // 灏濊瘯鏍煎紡鍖� JSON 骞惰浆涔夌壒娈婄鍙�
+                                                try {
+                                                    val = JSON.stringify(JSON.parse(val));
+                                                } catch (e) {
+                                                    // 闈炴爣鍑咼SON灏变笉鏍煎紡鍖�
+                                                }
+                                                val = val.replace(/"/g, '鈥�');   // 鏇挎崲鍙屽紩鍙蜂负鍏ㄨ寮曞彿锛岄槻姝� Excel 娣蜂贡
+                                                val = val.replace(/\n/g, '');    // 鍘绘帀鎹㈣
+                                            }
+                                        }
+                                        newItem[f] = val == null ? '' : String(val);
+                                    });
+                                    return newItem;
+                                });
+                                table.exportFile(titles,fixedData,'xls');
                             } else if (res.code === 403) {
                                 top.location.href = baseUrl+"/";
                             } else {

--
Gitblit v1.9.1