|
|
@@ -25,14 +25,16 @@ const SearchModal = ({ clientId, onSelect }) => {
|
|
|
const { data: { customer, total } = { customer: [], total: 0 }, code = -1 } =
|
|
|
await queryCustomers(params)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- if (params?.page === 1 || params?.search) {
|
|
|
+ if (params?.current === 1) {
|
|
|
+ scrollRef.current?.scrollTo({ top: 0 })
|
|
|
// 请求的是第一页或者搜索框
|
|
|
- setState({ ...state, customer, total, laoding: false })
|
|
|
+ setState({ ...state, customer, total, laoding: false, searchVal: params?.search })
|
|
|
} else {
|
|
|
setState({
|
|
|
...state,
|
|
|
customer: state.customer.concat(customer),
|
|
|
total,
|
|
|
+ searchVal: params?.search,
|
|
|
laoding: false,
|
|
|
current: params?.current || 1
|
|
|
})
|
|
|
@@ -45,7 +47,7 @@ const SearchModal = ({ clientId, onSelect }) => {
|
|
|
}, [])
|
|
|
const onChange = e => {
|
|
|
const { value = '' } = e.target || e.currentTarget
|
|
|
- initData({ search: value, current: state.current, pageSize: state.pageSize })
|
|
|
+ initData({ search: value, current: 1, pageSize: state.pageSize })
|
|
|
}
|
|
|
|
|
|
const { run: handleInputChange } = useDebounceFn(onChange)
|
|
|
@@ -88,7 +90,7 @@ const SearchModal = ({ clientId, onSelect }) => {
|
|
|
// 已到底部
|
|
|
|
|
|
state.current * state.pageSize < state.total &&
|
|
|
- initData({ current: state.current + 1, pageSize: state.pageSize })
|
|
|
+ initData({ current: state.current + 1, pageSize: state.pageSize, search: state.searchVal })
|
|
|
}
|
|
|
}
|
|
|
// const { run: listScroller } = useThrottleFn(handleListScroll)
|