diff --git a/components/dataView-V2/DataViewReducer.ts b/components/dataView-V2/DataViewReducer.ts index 308b1e86341301a32b9936eb4225cf9b0c8ab0f9..a77af5c9f5658796976bdbbfa389019b585ff76d 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 b192524d2c42a1a09df46b06331dba5d6e0c70f4..f05fd65ef608ec1adec848f58e965205cb92e246 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 fc0fc23a648ef23d039342416f98eb040a67af25..16820177ed933f5c49706c53bc1dd001bb8832fe 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)?第二个参数要暴露出什么?