|
|
@@ -1,5 +1,5 @@
|
|
|
import BsTable from './Table.vue';
|
|
|
-import { reactive, onMounted, onBeforeMount, toRaw } from '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';
|
|
|
|
|
|
@@ -9,19 +9,21 @@ export const useBsTable = (options, tableRef) => {
|
|
|
let gridRef = null;
|
|
|
|
|
|
const initGridOptions = () => {
|
|
|
- const seqCol = tableOptions?.gridOptions.columns.find((v) => ['seq', 'check', 'radio'].includes(v.type));
|
|
|
const optCol = tableOptions?.gridOptions.columns.find((v) => v?.cellRender && v.cellRender.name === 'CellOption');
|
|
|
// 操作初始化
|
|
|
if (!isEmpty(optCol)) {
|
|
|
optCol.fixed = 'right';
|
|
|
}
|
|
|
- // 序号初始化
|
|
|
- if (!isEmpty(seqCol)) {
|
|
|
- seqCol.align = 'center';
|
|
|
- seqCol.headerAlign = 'center';
|
|
|
- seqCol.width = '60px';
|
|
|
- seqCol.fixed = 'left';
|
|
|
- }
|
|
|
+ ['seq', 'checkbox', 'radio'].forEach((v) => {
|
|
|
+ const itemCol = tableOptions?.gridOptions.columns.find((vv) => vv.type === v);
|
|
|
+ // 序号初始化
|
|
|
+ if (!isEmpty(itemCol)) {
|
|
|
+ itemCol.align = 'center';
|
|
|
+ itemCol.headerAlign = 'center';
|
|
|
+ itemCol.width = '60px';
|
|
|
+ itemCol.fixed = 'left';
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
// 初始化列
|
|
|
tableOptions?.gridOptions.columns.forEach((col) => {
|
|
|
@@ -48,6 +50,7 @@ export const useBsTable = (options, tableRef) => {
|
|
|
height: '40px',
|
|
|
...tableOptions.gridOptions?.headerCellConfig,
|
|
|
},
|
|
|
+ height: 400,
|
|
|
...tableOptions?.gridOptions,
|
|
|
});
|
|
|
|
|
|
@@ -155,12 +158,18 @@ export const useBsTable = (options, tableRef) => {
|
|
|
setLoading(false);
|
|
|
setTableData(list);
|
|
|
setPageTotal(total);
|
|
|
+ nextTick(() => {
|
|
|
+ tableOptions?.tableSearchAfterBiz && tableOptions.tableSearchAfterBiz({ gridRef });
|
|
|
+ });
|
|
|
resolve(list);
|
|
|
} else {
|
|
|
if (isEmpty(tableOptions?.url)) {
|
|
|
setLoading(false);
|
|
|
setPageTotal(tableOptions.gridOptions.data.length);
|
|
|
setPagerVisible(false);
|
|
|
+ nextTick(() => {
|
|
|
+ tableOptions?.tableSearchAfterBiz && tableOptions.tableSearchAfterBiz({ gridRef });
|
|
|
+ });
|
|
|
resolve(tableOptions.gridOptions.data);
|
|
|
} else {
|
|
|
const resData = await getTableDataApi(tableOptions?.url, { pageNum, pageSize, ...newSearchParams });
|
|
|
@@ -168,6 +177,9 @@ export const useBsTable = (options, tableRef) => {
|
|
|
setLoading(false);
|
|
|
setTableData(data.list);
|
|
|
setPageTotal(data.total);
|
|
|
+ nextTick(() => {
|
|
|
+ tableOptions?.tableSearchAfterBiz && tableOptions.tableSearchAfterBiz({ gridRef });
|
|
|
+ });
|
|
|
resolve(data);
|
|
|
}
|
|
|
}
|
|
|
@@ -183,9 +195,6 @@ export const useBsTable = (options, tableRef) => {
|
|
|
};
|
|
|
|
|
|
const initPageEvent = () => {
|
|
|
- const visible = get(tableOptions, 'pagerConfig.enable', true);
|
|
|
- setPagerVisible(visible);
|
|
|
-
|
|
|
set(tableOptions, 'pagerConfig.onChange', async () => {
|
|
|
await getTableData();
|
|
|
});
|
|
|
@@ -200,6 +209,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);
|
|
|
initPageEvent();
|
|
|
};
|
|
|
|