From 733fff4d49fb528dfe0ab2fda51dd3bc6c2eb314 Mon Sep 17 00:00:00 2001 From: shizhongming Date: Fri, 23 Feb 2024 10:22:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(SMART-TABLE=E7=BB=84=E4=BB=B6):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=82=B9=E5=87=BB=E6=9F=A5=E8=AF=A2=E5=88=86=E7=BB=84?= =?UTF-8?q?=E9=A1=B5=E6=95=B0=E9=87=8D=E7=BD=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SmartTable/src/SmartTable.tsx | 7 +++++-- src/components/SmartTable/src/hooks/usePagination.ts | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/SmartTable/src/SmartTable.tsx b/src/components/SmartTable/src/SmartTable.tsx index 58097b741..829de8e60 100644 --- a/src/components/SmartTable/src/SmartTable.tsx +++ b/src/components/SmartTable/src/SmartTable.tsx @@ -38,6 +38,7 @@ export default defineComponent({ 'proxy-delete', 'add-edit-modal-show', 'cell-click', + 'page-change', ], setup(props, { emit, slots, attrs }) { const { t } = useI18n(); @@ -66,7 +67,8 @@ export default defineComponent({ setPagination, getShowPagination, setShowPagination, - } = usePagination(getTableProps); + handlePageChange, + } = usePagination(getTableProps, emit); /** * vxe-table函数 @@ -74,7 +76,7 @@ export default defineComponent({ const getTableInstance = () => unref(tableElRef); provide('getTableInstance', getTableInstance); const commitVxeProxy = (code, ...args) => getTableInstance()?.commitProxy(code, args); - const getCheckboxRecords = (isFull: boolean) => + const getCheckboxRecords = (isFull?: boolean) => getTableInstance()?.getCheckboxRecords(isFull) || []; const getRadioRecord = (isFull: boolean) => getTableInstance()?.getRadioRecord(isFull); const setRadioRow = (row: any) => getTableInstance()!.setRadioRow(row); @@ -227,6 +229,7 @@ export default defineComponent({ customConfig: unref(getCustomConfig), ...unref(getTableEvents), ...unref(computedTableClassStyle), + onPageChange: handlePageChange, }; }); diff --git a/src/components/SmartTable/src/hooks/usePagination.ts b/src/components/SmartTable/src/hooks/usePagination.ts index 62c484577..a9973f70e 100644 --- a/src/components/SmartTable/src/hooks/usePagination.ts +++ b/src/components/SmartTable/src/hooks/usePagination.ts @@ -11,7 +11,7 @@ import { VxeGridPropTypes } from 'vxe-table'; * @author zhongming4762 * @param propsRef */ -export const usePagination = (propsRef: ComputedRef) => { +export const usePagination = (propsRef: ComputedRef, emit: Function) => { const configRef = ref({}); const show = ref(true); @@ -53,6 +53,15 @@ export const usePagination = (propsRef: ComputedRef) => { }; }; + const handlePageChange = (eventData) => { + const { pageSize, currentPage } = eventData; + setPagination({ + pageSize, + currentPage, + }); + emit('page-change', eventData); + }; + const getPagination = () => unref(getPaginationInfo); function getShowPagination() { @@ -69,5 +78,6 @@ export const usePagination = (propsRef: ComputedRef) => { getPagination, getShowPagination, setShowPagination, + handlePageChange, }; };