浏览代码

计算属性

yusheng 10 月之前
父节点
当前提交
0f4b4be5c1
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      src/mixins/tableColumnsMixin.js

+ 10 - 2
src/mixins/tableColumnsMixin.js

@@ -55,6 +55,13 @@ export default {
         }
         }
       }
       }
     },
     },
+    getColumns() {
+      if (typeof this.columns == 'function') {
+        return this.columns();
+      } else {
+        return this.columns;
+      }
+    },
     //服务器和本地配置columns对比
     //服务器和本地配置columns对比
     columnsContrast(list) {
     columnsContrast(list) {
       const key = 'label';
       const key = 'label';
@@ -62,8 +69,9 @@ export default {
       let sList = list.filter((d, i, r) => {
       let sList = list.filter((d, i, r) => {
         return d[key];
         return d[key];
       });
       });
-      let devColumns =
-        this.newColumns?.length > 0 ? this.newColumns : this.columns;
+      let devColumns = this.newColumns?.length
+        ? this.newColumns
+        : this.getColumns();
       let dList = devColumns.filter((d, i, r) => {
       let dList = devColumns.filter((d, i, r) => {
         return d[key] && d[key] !== '序号';
         return d[key] && d[key] !== '序号';
       });
       });