Browse Source

fix: BsUi-表格组件修改

hanxiaohui 4 months ago
parent
commit
999169f490
2 changed files with 12 additions and 4 deletions
  1. 4 3
      src/components/BsUi/Table/Table.vue
  2. 8 1
      src/components/BsUi/Table/index.js

+ 4 - 3
src/components/BsUi/Table/Table.vue

@@ -1,5 +1,5 @@
 <template>
-  <vxe-grid class="wrapper" v-bind="gridOptions" ref="gridRef" v-fullscreen :style="{ height: isShowPager && isFixed ? `calc(100vh - 101px)` : '100%' }">
+  <vxe-grid class="wrapper" v-bind="gridOptions" ref="gridRef" v-fullscreen :style="{ height: isEnablePager && isFixed ? `calc(100vh - 101px)` : '100%' }">
     <template #form>
       <Search
         v-if="searchConfig && searchConfig.enable && searchConfig?.fields && searchConfig?.data"
@@ -87,7 +87,7 @@
     </template>
 
     <template #pager>
-      <div :class="`pager ${!has(pagerConfig, 'isFixed') || pagerConfig.isFixed ? 'page_fixed' : ''}`" v-if="pagerConfig && pagerConfig.enable">
+      <div :class="`pager ${!has(pagerConfig, 'isFixed') || pagerConfig.isFixed ? 'page_fixed' : ''}`" v-if="pagerConfig && isEnablePager">
         <Pagination :pagerConfig="pagerConfig" />
       </div>
     </template>
@@ -120,7 +120,7 @@
   const props = defineProps(['gridOptions', 'searchConfig', 'pagerConfig', 'toolbarConfig', 'getGridRef', 'mounted', 'toolbarTopConfig', 'url']);
 
   const isFixed = get(props.pagerConfig, 'isFixed', true);
-  const isShowPager = get(props.pagerConfig, 'enable', false);
+  const isEnablePager = get(props.pagerConfig, 'enable', false) || get(props.pagerConfig, 'enabled', false);
 
   const $slots = useSlots();
 
@@ -130,6 +130,7 @@
 
   const slotCols = ref([]);
 
+
   const handleSetting = () => {
     gridRef.value.openCustom();
   };

+ 8 - 1
src/components/BsUi/Table/index.js

@@ -1,6 +1,6 @@
 import BsTable from './Table.vue';
 import { reactive, onMounted, onBeforeMount, toRaw } from 'vue';
-import { set, get, isEmpty, isUndefined, forEach } from 'lodash';
+import {set, get, isEmpty, isUndefined, forEach, has} from 'lodash';
 import { getTableDataApi } from '/@/api/system/table-api.js';
 
 export const useBsTable = (options, tableRef) => {
@@ -24,6 +24,13 @@ export const useBsTable = (options, tableRef) => {
       seqCol.fixed = 'left'
     }
 
+    // 初始化列
+    tableOptions?.gridOptions.columns.forEach((col) => {
+      if(!has(col, 'headerAlign')) {
+        col.headerAlign = 'center'
+      }
+    })
+
     set(tableOptions, 'gridOptions', {
       border: 'full',
       showHeaderOverflow: true,