Browse Source

fix:增加加载全部数据的标识来停止继续触发请求

ZhaoJun 1 year ago
parent
commit
c5ce27fb7d
1 changed files with 8 additions and 5 deletions
  1. 8 5
      src/pages/TaskManage/Detail/TaskList/TaskList.tsx

+ 8 - 5
src/pages/TaskManage/Detail/TaskList/TaskList.tsx

@@ -44,6 +44,7 @@ const TaskList: React.FC<IPropsType> = (props) => {
     pageSize: 20,
     pageSize: 20,
     currentPage: 1,
     currentPage: 1,
   });
   });
+  const [isLoadAll, setIsLoadAll] = useState(false);
 
 
   const bottomAreaOfList = useRef<HTMLDivElement>(null);
   const bottomAreaOfList = useRef<HTMLDivElement>(null);
 
 
@@ -58,11 +59,13 @@ const TaskList: React.FC<IPropsType> = (props) => {
       if (result.data.pagination.current === 1) {
       if (result.data.pagination.current === 1) {
         setMandateList(result.data.list);
         setMandateList(result.data.list);
       } else {
       } else {
-        // 如果还有数据没加载
         if (mandateList.length < pageInfo.total) {
         if (mandateList.length < pageInfo.total) {
           setMandateList([...mandateList, ...result.data.list]);
           setMandateList([...mandateList, ...result.data.list]);
         }
         }
       }
       }
+      if (pageInfo.current * pageInfo.pageSize >= pageInfo.total) {
+        setIsLoadAll(true);
+      }
       pageInfo.current += 1;
       pageInfo.current += 1;
       setCurrentParams({
       setCurrentParams({
         ...currentParams,
         ...currentParams,
@@ -72,7 +75,7 @@ const TaskList: React.FC<IPropsType> = (props) => {
   });
   });
 
 
   const handleScroll = () => {
   const handleScroll = () => {
-    if (bottomAreaOfList.current === null || loadData) {
+    if (bottomAreaOfList.current === null) {
       return;
       return;
     }
     }
     const rect = bottomAreaOfList.current.getBoundingClientRect();
     const rect = bottomAreaOfList.current.getBoundingClientRect();
@@ -163,11 +166,11 @@ const TaskList: React.FC<IPropsType> = (props) => {
     getList(params);
     getList(params);
   };
   };
 
 
-  const loadMoreMandate = !loadData ? (
+  const loadMoreMandate = !isLoadAll && !loadData ? (
     <div
     <div
       ref={bottomAreaOfList}
       ref={bottomAreaOfList}
       style={{
       style={{
-        height: '10px',
+        height: '1px',
       }}
       }}
     />
     />
   ) : null;
   ) : null;
@@ -259,7 +262,7 @@ const TaskList: React.FC<IPropsType> = (props) => {
     ];
     ];
 
 
     return (
     return (
-      <List.Item>
+      <List.Item style={{ borderBottom: '0' }}>
         <div className={`${styles.cardContainer} card-box`}>
         <div className={`${styles.cardContainer} card-box`}>
           <Row justify="space-between" style={{ marginBottom: '20px' }}>
           <Row justify="space-between" style={{ marginBottom: '20px' }}>
             <Col className={styles.fontS24}>时间:{formatItem.CreateTime}</Col>
             <Col className={styles.fontS24}>时间:{formatItem.CreateTime}</Col>