|
|
@@ -2,6 +2,8 @@ import BsTable from './Table.vue';
|
|
|
import { reactive, onMounted, onBeforeMount, toRaw, nextTick } from 'vue';
|
|
|
import { set, get, isEmpty, isUndefined, forEach, has } from 'lodash';
|
|
|
import { getTableDataApi } from '/@/api/system/table-api.js';
|
|
|
+import {PAGE_NUM, PAGE_SIZE_OPTIONS} from "/@/components/BsUi/constant.js";
|
|
|
+import {PAGE_SIZE} from "/@/constants/common-const.js";
|
|
|
|
|
|
export const useBsTable = (options, tableRef) => {
|
|
|
let tableOptions = reactive(options.tableOptions);
|
|
|
@@ -50,7 +52,7 @@ export const useBsTable = (options, tableRef) => {
|
|
|
height: '40px',
|
|
|
...tableOptions.gridOptions?.headerCellConfig,
|
|
|
},
|
|
|
- height: 400,
|
|
|
+ height: '100%',
|
|
|
...tableOptions?.gridOptions,
|
|
|
});
|
|
|
|
|
|
@@ -135,6 +137,10 @@ export const useBsTable = (options, tableRef) => {
|
|
|
set(tableOptions, 'pagerConfig.total', value);
|
|
|
};
|
|
|
|
|
|
+ const setPageSizeOptions = (value) => {
|
|
|
+ set(tableOptions, 'pagerConfig.pageSizeOptions', value);
|
|
|
+ }
|
|
|
+
|
|
|
const setTableData = (data) => {
|
|
|
set(tableOptions, 'gridOptions.data', data);
|
|
|
};
|
|
|
@@ -165,8 +171,8 @@ export const useBsTable = (options, tableRef) => {
|
|
|
} else {
|
|
|
if (isEmpty(tableOptions?.url)) {
|
|
|
setLoading(false);
|
|
|
- setPageTotal(tableOptions.gridOptions.data.length);
|
|
|
- setPagerVisible(false);
|
|
|
+ setPageTotal(tableOptions.gridOptions.data.length)
|
|
|
+ setTableData(tableOptions.gridOptions.data);
|
|
|
nextTick(() => {
|
|
|
tableOptions?.tableSearchAfterBiz && tableOptions.tableSearchAfterBiz({ gridRef });
|
|
|
});
|
|
|
@@ -209,10 +215,10 @@ export const useBsTable = (options, tableRef) => {
|
|
|
};
|
|
|
|
|
|
const initPagerConfig = () => {
|
|
|
- setPageNum(tableOptions?.pagerConfig?.pageNum || 1);
|
|
|
- setPageSize(tableOptions?.pagerConfig?.pageSize || 20);
|
|
|
- const visible = get(tableOptions, 'pagerConfig.enable', true);
|
|
|
- setPagerVisible(visible);
|
|
|
+ setPageNum(tableOptions?.pagerConfig?.pageNum || PAGE_NUM);
|
|
|
+ setPageSize(tableOptions?.pagerConfig?.pageSize || PAGE_SIZE);
|
|
|
+ setPageSizeOptions(tableOptions?.pagerConfig?.pageSizeOptions || PAGE_SIZE_OPTIONS);
|
|
|
+ setPagerVisible(tableOptions?.pagerConfig?.enable || true);
|
|
|
initPageEvent();
|
|
|
};
|
|
|
|