Prechádzať zdrojové kódy

fix:处理table表数据驼峰字段名

韩帛霖 1 rok pred
rodič
commit
cd6126aac7

+ 13 - 1
ruoyi-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -190,6 +190,7 @@ import {
 } from "@/api/tablelist/commonTable";
 import {getToken} from "@/utils/auth";
 import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
+import {camelCase} from "@/utils";
 
 export default {
   name: "listInfo",
@@ -278,6 +279,9 @@ export default {
     this.sqlkey = this.$route.query.sqlkey;
   },
   methods: {
+    isUpperCase(char) {
+      return char === char.toUpperCase();
+    },
     // 下划线命名转驼峰命名
     toUnderScoreCase(str) {
       if (str === null) {
@@ -320,7 +324,7 @@ export default {
       columns.forEach((item) => {
         for (const key in item) {
           let tempObj = {};
-          tempObj.key = this.toUnderScoreCase(key);
+          tempObj.key = camelCase(key);
           tempObj.value = item[key];
           resArr.push(tempObj);
         }
@@ -366,6 +370,14 @@ export default {
             res.rows.forEach((item) => {
               this.tableList.push(item.resultMap);
             });
+            this.tableList = this.tableList.map(item => {
+              let kv = {}
+              for (let itemKey in item) {
+                console.log(itemKey);
+                kv[camelCase(itemKey)] = item[itemKey]
+              }
+              return kv
+            })
             this.total = res.total;
             this.loading = false;
           });