|
@@ -17,8 +17,8 @@ const SearchModal = ({ clientId, onSelect }) => {
|
|
|
laoding: true,
|
|
laoding: true,
|
|
|
customer: [],
|
|
customer: [],
|
|
|
searchVal: '',
|
|
searchVal: '',
|
|
|
- page: 1,
|
|
|
|
|
- size: 10,
|
|
|
|
|
|
|
+ current: 1,
|
|
|
|
|
+ pageSize: 10,
|
|
|
total: 0
|
|
total: 0
|
|
|
})
|
|
})
|
|
|
const initData = async params => {
|
|
const initData = async params => {
|
|
@@ -29,17 +29,23 @@ const SearchModal = ({ clientId, onSelect }) => {
|
|
|
// 请求的是第一页
|
|
// 请求的是第一页
|
|
|
setState({ ...state, customer, total, laoding: false })
|
|
setState({ ...state, customer, total, laoding: false })
|
|
|
} else {
|
|
} else {
|
|
|
- setState({ ...state, customer: state.customer.concat(customer), total, laoding: false })
|
|
|
|
|
|
|
+ setState({
|
|
|
|
|
+ ...state,
|
|
|
|
|
+ customer: state.customer.concat(customer),
|
|
|
|
|
+ total,
|
|
|
|
|
+ laoding: false,
|
|
|
|
|
+ pageSize: params?.pageSize || 1
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- initData({ page: 1, size: 10 })
|
|
|
|
|
|
|
+ initData({ current: 1, pageSize: 10 })
|
|
|
}, [])
|
|
}, [])
|
|
|
const onChange = e => {
|
|
const onChange = e => {
|
|
|
const { value = '' } = e.target || e.currentTarget
|
|
const { value = '' } = e.target || e.currentTarget
|
|
|
- initData({ search: value, page: state.page, size: state.size })
|
|
|
|
|
|
|
+ initData({ search: value, current: state.current, pageSize: state.pageSize })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const { run: handleInputChange } = useDebounceFn(onChange)
|
|
const { run: handleInputChange } = useDebounceFn(onChange)
|
|
@@ -80,7 +86,7 @@ const SearchModal = ({ clientId, onSelect }) => {
|
|
|
scrollRef.current.scrollTop
|
|
scrollRef.current.scrollTop
|
|
|
) {
|
|
) {
|
|
|
// 已到底部
|
|
// 已到底部
|
|
|
- initData({ page: state.page + 1, size: state.size })
|
|
|
|
|
|
|
+ initData({ current: state.current + 1, pageSize: state.pageSize })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// const { run: listScroller } = useThrottleFn(handleListScroll)
|
|
// const { run: listScroller } = useThrottleFn(handleListScroll)
|