|
@@ -18,8 +18,9 @@ import TopFilter from '@/pages/TaskManage/components/TopFilter';
|
|
|
import { IMandateType } from '@/pages/TaskManage/index.types';
|
|
|
import { useNavigate } from '@@/exports';
|
|
|
import { DownOutlined } from '@ant-design/icons';
|
|
|
-import { Col, Collapse, CollapseProps, Divider, List, Row, Spin } from 'antd';
|
|
|
+import { Col, Collapse, CollapseProps, Divider, List, Row } from 'antd';
|
|
|
|
|
|
+import ScrollLoading from '@/components/ScrollLoading';
|
|
|
import { getMandateList } from '@/services/TaskManage';
|
|
|
import dayjs from 'dayjs';
|
|
|
import { useEffect, useRef, useState } from 'react';
|
|
@@ -45,6 +46,7 @@ const TaskList: React.FC<IPropsType> = (props) => {
|
|
|
currentPage: 1,
|
|
|
});
|
|
|
const [isLoadAll, setIsLoadAll] = useState(false);
|
|
|
+ const [pagination, setPagination] = useState({ current: 1, total: 0 });
|
|
|
|
|
|
const bottomAreaOfList = useRef<HTMLDivElement>(null);
|
|
|
|
|
@@ -63,34 +65,10 @@ const TaskList: React.FC<IPropsType> = (props) => {
|
|
|
setMandateList([...mandateList, ...result.data.list]);
|
|
|
}
|
|
|
}
|
|
|
- if (pageInfo.current * pageInfo.pageSize >= pageInfo.total) {
|
|
|
- setIsLoadAll(true);
|
|
|
- }
|
|
|
- pageInfo.current += 1;
|
|
|
- setCurrentParams({
|
|
|
- ...currentParams,
|
|
|
- currentPage: pageInfo.current,
|
|
|
- });
|
|
|
+ setPagination(pageInfo);
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- const handleScroll = () => {
|
|
|
- if (bottomAreaOfList.current === null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- const rect = bottomAreaOfList.current.getBoundingClientRect();
|
|
|
- const isVisible =
|
|
|
- rect.top >= 0 &&
|
|
|
- rect.left >= 0 &&
|
|
|
- rect.bottom <=
|
|
|
- (window.innerHeight || document.documentElement.clientHeight) &&
|
|
|
- rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
|
-
|
|
|
- if (isVisible) {
|
|
|
- getList(currentParams);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
// 获取用户
|
|
|
useEffect(() => {
|
|
|
if (userList.length === 0) {
|
|
@@ -101,16 +79,6 @@ const TaskList: React.FC<IPropsType> = (props) => {
|
|
|
}
|
|
|
}, []);
|
|
|
|
|
|
- // 监听滚动事件
|
|
|
- useEffect(() => {
|
|
|
- // 组件挂载时添加滚动事件监听
|
|
|
- window.addEventListener('scroll', handleScroll);
|
|
|
- // 组件卸载时移除滚动事件监听
|
|
|
- return () => {
|
|
|
- window.removeEventListener('scroll', handleScroll);
|
|
|
- };
|
|
|
- }, [loadData, currentParams]);
|
|
|
-
|
|
|
// 配置顶部下拉过滤器
|
|
|
useEffect(() => {
|
|
|
const filters: ITopFilter[] = [];
|
|
@@ -166,16 +134,6 @@ const TaskList: React.FC<IPropsType> = (props) => {
|
|
|
getList(params);
|
|
|
};
|
|
|
|
|
|
- const loadMoreMandate =
|
|
|
- !isLoadAll && !loadData ? (
|
|
|
- <div
|
|
|
- ref={bottomAreaOfList}
|
|
|
- style={{
|
|
|
- height: '1px',
|
|
|
- }}
|
|
|
- />
|
|
|
- ) : null;
|
|
|
-
|
|
|
const goTaskDetail = (mandate: IMandateType) => {
|
|
|
navigate(
|
|
|
`/task-manage/list/detail?project_id=${project_id}&mandate_id=${mandate.Id}`,
|
|
@@ -332,22 +290,26 @@ const TaskList: React.FC<IPropsType> = (props) => {
|
|
|
|
|
|
return (
|
|
|
<PageContent closeable={false}>
|
|
|
- <div className={styles.topContainer}>
|
|
|
- <div className={styles.fixedTop}>
|
|
|
- <PageTitle returnable>
|
|
|
- {MandateType.find((item) => item.value === mandateType)?.label}
|
|
|
- </PageTitle>
|
|
|
- <TopFilter filters={topFiltersConfig} onChange={onTopFilterChange} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <Spin spinning={loading || loadData}>
|
|
|
+ <PageTitle returnable>
|
|
|
+ {MandateType.find((item) => item.value === mandateType)?.label}
|
|
|
+ </PageTitle>
|
|
|
+ <TopFilter filters={topFiltersConfig} onChange={onTopFilterChange} />
|
|
|
+
|
|
|
+ <ScrollLoading
|
|
|
+ height={180}
|
|
|
+ loading={loading || loadData}
|
|
|
+ totalLength={mandateList?.length}
|
|
|
+ pagination={pagination}
|
|
|
+ handleLoadData={(current: number) =>
|
|
|
+ getList({ ...currentParams, currentPage: current })
|
|
|
+ }
|
|
|
+ >
|
|
|
<List
|
|
|
itemLayout="horizontal"
|
|
|
dataSource={mandateList}
|
|
|
renderItem={buildTaskList}
|
|
|
- loadMore={loadMoreMandate}
|
|
|
/>
|
|
|
- </Spin>
|
|
|
+ </ScrollLoading>
|
|
|
</PageContent>
|
|
|
);
|
|
|
};
|