Browse Source

fix: BsUi-基础表格修改

hanxiaohui 5 months ago
parent
commit
071880b212
2 changed files with 5 additions and 25 deletions
  1. 3 1
      src/components/BsUi/Table/Table.vue
  2. 2 24
      src/components/BsUi/Table/index.js

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

@@ -78,7 +78,8 @@
   import Pagination from './component/pagination/index.vue';
   import Toolbar from './component/toolbar/index.vue';
   import IndexData from './component/indexData/index.vue';
-  const props = defineProps(['gridOptions', 'searchConfig', 'pagerConfig', 'toolbarConfig', 'getGridRef']);
+  const props = defineProps(['gridOptions', 'searchConfig', 'pagerConfig', 'toolbarConfig', 'getGridRef', 'mounted']);
+
   const gridRef = ref(null);
 
   const isZoom = ref(false);
@@ -94,6 +95,7 @@
   onMounted(() => {
     nextTick(() => {
       props.getGridRef && props.getGridRef(gridRef.value);
+      props.mounted && props.mounted(gridRef.value)
     });
   });
 

+ 2 - 24
src/components/BsUi/Table/index.js

@@ -125,7 +125,7 @@ export const useBsTable = (options, tableRef) => {
         setPagerVisible(false);
         resolve(tableOptions.gridOptions.data);
       } else {
-        // console.log('入参为 =====>', { pageNum, pageSize, ...newSearchParams });
+        console.log('入参为 =====>', { pageNum, pageSize, ...newSearchParams });
         const resData = await getTableDataApi(tableOptions?.url, { pageNum, pageSize, ...newSearchParams });
         // const resData = {
         //   data:  {
@@ -181,34 +181,14 @@ export const useBsTable = (options, tableRef) => {
     });
   };
 
-  const onTableBeforeMount = (callback) => {
-    onBeforeMount(() => {
-      if (typeof callback === 'function') {
-        callback();
-      }
-    });
-  };
-
-  const onTableMounted = (callback) => {
-    onMounted(() => {
-      if (typeof callback === 'function') {
-        const gridRef = getGridRef();
-        callback(gridRef);
-      }
-    });
-  };
-
   onMounted(async () => {
     initTableData();
     initGridOptions();
     initToolbarConfig();
     initPagerConfig();
     initSearchConfig();
-    onTableBeforeMount();
-    options.beforeMount && options.beforeMount();
+    tableOptions.beforeMount && tableOptions.beforeMount();
     await getTableData();
-    onTableMounted();
-    options.mounted && options.mounted();
   });
 
   const setToolBarVisible = (visible) => {
@@ -235,8 +215,6 @@ export const useBsTable = (options, tableRef) => {
 
   return {
     tableOptions,
-    onTableMounted,
-    onTableBeforeMount,
     setTablePropsValue,
     getTablePropsValue,
     setTableOptions,