Bläddra i källkod

fix: CustomerModal检索条件

lanjianrong 5 år sedan
förälder
incheckning
1b4f97ae83
1 ändrade filer med 6 tillägg och 4 borttagningar
  1. 6 4
      src/pages/Customer/Contact/components/CustomerModal/index.jsx

+ 6 - 4
src/pages/Customer/Contact/components/CustomerModal/index.jsx

@@ -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)