Browse Source

fix(SMART-TABLE组件): 修复点击查询分组页数重置的问题

shizhongming 2 years ago
parent
commit
733fff4d49
  1. 7
      src/components/SmartTable/src/SmartTable.tsx
  2. 12
      src/components/SmartTable/src/hooks/usePagination.ts

7
src/components/SmartTable/src/SmartTable.tsx

@ -38,6 +38,7 @@ export default defineComponent({
'proxy-delete', 'proxy-delete',
'add-edit-modal-show', 'add-edit-modal-show',
'cell-click', 'cell-click',
'page-change',
], ],
setup(props, { emit, slots, attrs }) { setup(props, { emit, slots, attrs }) {
const { t } = useI18n(); const { t } = useI18n();
@ -66,7 +67,8 @@ export default defineComponent({
setPagination, setPagination,
getShowPagination, getShowPagination,
setShowPagination, setShowPagination,
} = usePagination(getTableProps); handlePageChange,
} = usePagination(getTableProps, emit);
/** /**
* vxe-table函数 * vxe-table函数
@ -74,7 +76,7 @@ export default defineComponent({
const getTableInstance = () => unref(tableElRef); const getTableInstance = () => unref(tableElRef);
provide('getTableInstance', getTableInstance); provide('getTableInstance', getTableInstance);
const commitVxeProxy = (code, ...args) => getTableInstance()?.commitProxy(code, args); const commitVxeProxy = (code, ...args) => getTableInstance()?.commitProxy(code, args);
const getCheckboxRecords = (isFull: boolean) => const getCheckboxRecords = (isFull?: boolean) =>
getTableInstance()?.getCheckboxRecords(isFull) || []; getTableInstance()?.getCheckboxRecords(isFull) || [];
const getRadioRecord = (isFull: boolean) => getTableInstance()?.getRadioRecord(isFull); const getRadioRecord = (isFull: boolean) => getTableInstance()?.getRadioRecord(isFull);
const setRadioRow = (row: any) => getTableInstance()!.setRadioRow(row); const setRadioRow = (row: any) => getTableInstance()!.setRadioRow(row);
@ -227,6 +229,7 @@ export default defineComponent({
customConfig: unref(getCustomConfig), customConfig: unref(getCustomConfig),
...unref(getTableEvents), ...unref(getTableEvents),
...unref(computedTableClassStyle), ...unref(computedTableClassStyle),
onPageChange: handlePageChange,
}; };
}); });

12
src/components/SmartTable/src/hooks/usePagination.ts

@ -11,7 +11,7 @@ import { VxeGridPropTypes } from 'vxe-table';
* @author zhongming4762 * @author zhongming4762
* @param propsRef * @param propsRef
*/ */
export const usePagination = (propsRef: ComputedRef<SmartTableProps>) => { export const usePagination = (propsRef: ComputedRef<SmartTableProps>, emit: Function) => {
const configRef = ref<VxeGridPropTypes.PagerConfig>({}); const configRef = ref<VxeGridPropTypes.PagerConfig>({});
const show = ref(true); const show = ref(true);
@ -53,6 +53,15 @@ export const usePagination = (propsRef: ComputedRef<SmartTableProps>) => {
}; };
}; };
const handlePageChange = (eventData) => {
const { pageSize, currentPage } = eventData;
setPagination({
pageSize,
currentPage,
});
emit('page-change', eventData);
};
const getPagination = () => unref(getPaginationInfo); const getPagination = () => unref(getPaginationInfo);
function getShowPagination() { function getShowPagination() {
@ -69,5 +78,6 @@ export const usePagination = (propsRef: ComputedRef<SmartTableProps>) => {
getPagination, getPagination,
getShowPagination, getShowPagination,
setShowPagination, setShowPagination,
handlePageChange,
}; };
}; };

Loading…
Cancel
Save