1
0
suochencheng 7 лет назад
Родитель
Сommit
078b32f9e3

+ 10 - 0
src/main/java/com/izouma/awesomeadmin/model/CommonQuery.java

@@ -32,6 +32,8 @@ public class CommonQuery {
 
     private String dataSourceCode;
 
+    private String columnNameStr;
+
 
     public String getTableName() {
         return tableName;
@@ -96,5 +98,13 @@ public class CommonQuery {
     public void setDataSourceCode(String dataSourceCode) {
         this.dataSourceCode = dataSourceCode;
     }
+
+    public String getColumnNameStr() {
+        return columnNameStr;
+    }
+
+    public void setColumnNameStr(String columnNameStr) {
+        this.columnNameStr = columnNameStr;
+    }
 }
 

+ 12 - 9
src/main/java/com/izouma/awesomeadmin/web/CommonQueryController.java

@@ -129,18 +129,21 @@ public class CommonQueryController {
         String fileName = record.getTableName();
 
         if (pp.size() > 0) {
-            int columnNumber = pp.get(0).size();
-            int[] columnWidth = new int[pp.get(0).size()];
-            String[] columnName = new String[pp.get(0).size()];
-            for (int i = 0; i < pp.get(0).size(); i++) {
+
+
+            String[] columnName = record.getColumnNameStr().split("_,");
+            int columnNumber = columnName.length;
+
+            int[] columnWidth = new int[columnName.length];
+            for (int i = 0; i < columnNumber; i++) {
                 columnWidth[i] = 20;
 
             }
-            int columnIndex = 0;
-            for (Object key : pp.get(0).keySet()) {
-                columnName[columnIndex] = String.valueOf(key);
-                columnIndex++;
-            }
+//            int columnIndex = 0;
+//            for (Object key : pp.get(0).keySet()) {
+//                columnName[columnIndex] = String.valueOf(key);
+//                columnIndex++;
+//            }
 
             String[][] dataList = new String[pp.size()][columnNumber];
 

+ 20 - 1
src/main/vue/src/pages/CommonQuerys.vue

@@ -578,10 +578,29 @@ export default {
         },
 
         exportExcel() {
+
+            var columnName = '';
+            if (this.tableColumns.length > 0) {
+
+                var templist = [];
+
+                this.tableColumns.forEach(item => {
+                    if (item.show) {
+                        templist.push(item.name);
+                    }
+                })
+
+                if (templist.length > 0) {
+
+                    columnName = templist.join('_,');
+
+                }
+            }
+
             window.location.href = this.$baseUrl + "/commonQuery/exportExcel?advancedQuery="
                 + this.advancedQuerySearchKey + "&tableName=" + this.tableName + "&databasetype=" + this.databasetype
                 + "&searchColumn=" + this.searchColumn + "&searchKey=" + this.filter1 + "&orderByStr=" + this.orderByStr
-                + "&dataSourceCode=" + this.dataSourceCode;
+                + "&dataSourceCode=" + this.dataSourceCode + "&columnNameStr=" + columnName;
         },
         goBackPage() {
             this.$router.go(-1);