Commit bf9965fe authored by 满振华's avatar 满振华

修改页面

parent f0a14dfc
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 })
......
......@@ -10,10 +10,10 @@ import './style.less';
* */
const BIPagination = (props: any) => {
const current = props.current || props.pageNum;
return (
<div style={{ textAlign: 'right', paddingTop: '16px' }}>
<Pagination {...props} />
<Pagination {...props} current={current} />
</div>
);
......
......@@ -66,13 +66,20 @@ const DataView = (props: Props, ref: Ref<any>) => {
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)?第二个参数要暴露出什么?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment