From bf9965fe002df0ccd399209f23cb78dcabf90c89 Mon Sep 17 00:00:00 2001 From: manzhenhua Date: Wed, 27 May 2020 15:22:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dataView-V2/DataViewReducer.ts | 4 ++-- .../_components/table/pagination/index.tsx | 4 ++-- components/dataView-V2/index.tsx | 11 +++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/components/dataView-V2/DataViewReducer.ts b/components/dataView-V2/DataViewReducer.ts index 308b1e8..a77af5c 100644 --- a/components/dataView-V2/DataViewReducer.ts +++ b/components/dataView-V2/DataViewReducer.ts @@ -1,7 +1,7 @@ export interface Pagination { // 分页数据 pageSize?: number, pageNum?: number, - total?: number + total?: number, } interface State { loading: boolean, @@ -69,7 +69,7 @@ export const effect = (reduceArr: any, registerFun: { fetch: Function }) => { newParams = await registerFun.fetch({ pagination: { ...state.pagination, pageNum: payload.pageNum } }) break case 'onSearch': - newParams = await registerFun.fetch({ searchForm: { ...state.searchForm, ...(payload.searchForm || {}) } }) + newParams = await registerFun.fetch({ searchForm: { ...state.searchForm, ...(payload.searchForm || {}) }, pagination: initState.pagination }) break case 'onResert': newParams = await registerFun.fetch({ searchForm: null, pagination: initState.pagination }) diff --git a/components/dataView-V2/_components/table/pagination/index.tsx b/components/dataView-V2/_components/table/pagination/index.tsx index b192524..f05fd65 100644 --- a/components/dataView-V2/_components/table/pagination/index.tsx +++ b/components/dataView-V2/_components/table/pagination/index.tsx @@ -10,10 +10,10 @@ import './style.less'; * */ const BIPagination = (props: any) => { - + const current = props.current || props.pageNum; return (
- +
); diff --git a/components/dataView-V2/index.tsx b/components/dataView-V2/index.tsx index fc0fc23..1682017 100644 --- a/components/dataView-V2/index.tsx +++ b/components/dataView-V2/index.tsx @@ -66,13 +66,20 @@ const DataView = (props: Props, ref: Ref) => { dataSource: Array.isArray(dataSource) ? dataSource.slice() : [], } } - async function _fetch(params: any) { + async function _fetch(params = {}) { const { beforeFetch, fetch, afterFetch } = props; const onBeforeFetch: Function = beforeFetch && typeof beforeFetch === 'function' ? beforeFetch : _beforeFetch; const onAfterFetch: Function = afterFetch && typeof afterFetch === 'function' ? afterFetch : _afterFetch; if (typeof fetch === 'function') { const res = await fetch(onBeforeFetch.bind(null, params), dispatch); - return await onAfterFetch(res) + const { dataSource = [], pagination = {}, searchForm = {} } = res || {}; + return await onAfterFetch({ + dataSource, + pagination: { + ...(params.pagination || {}), ...pagination, + searchForm: { ...(params.searchForm || {}), ...searchForm } + } + }) } } useImperativeHandle(ref, () => {//第一个参数,要暴露给哪个(ref)?第二个参数要暴露出什么? -- 2.21.0