2024-03-13 16:11:28 +08:00
|
|
|
import './list-proj.css'
|
|
|
|
import CardProj from "../card/CardProj.tsx";
|
2024-04-29 17:22:26 +08:00
|
|
|
import { useRef, MutableRefObject, useState, useEffect, useContext } from "react";
|
2024-05-23 18:21:31 +08:00
|
|
|
import { Pagination, message, Spin, Empty } from 'antd';
|
2024-04-29 17:22:26 +08:00
|
|
|
import { get } from "../../util/AjaxUtils.ts";
|
|
|
|
import { IndexListContext } from "../../context/IndexListContext.ts";
|
|
|
|
import { IListPage } from "../../interfaces/listpage/IListPage.ts";
|
|
|
|
import { IProj } from "../../interfaces/proj/IProj.ts";
|
2024-05-23 18:21:31 +08:00
|
|
|
// import NoData from "../../assets/no-data.png";
|
2024-05-07 17:00:32 +08:00
|
|
|
import { useLocation } from 'react-router-dom';
|
2024-05-23 14:57:22 +08:00
|
|
|
import syminga from '../../static/homeimg/homeimga.png'
|
|
|
|
import symingb from '../../static/homeimg/homeimgb.png'
|
|
|
|
import symingc from '../../static/homeimg/homeimgc.png'
|
|
|
|
import symingd from '../../static/homeimg/homeimgd.png'
|
2024-05-28 18:00:42 +08:00
|
|
|
import { getMenuActive } from '../../util/cache.ts';
|
|
|
|
|
2024-05-07 17:00:32 +08:00
|
|
|
// import gpsImg from '../../static/right/gps.png'
|
|
|
|
// import { Link } from "react-router-dom";
|
|
|
|
// import { Breadcrumb } from 'antd';
|
|
|
|
// import backImg from '../../static/right/back.png'
|
|
|
|
// const { Search } = Input;
|
2024-03-13 16:11:28 +08:00
|
|
|
|
|
|
|
export default function ListProj() {
|
2024-03-27 18:56:48 +08:00
|
|
|
const indexListContext = useContext(IndexListContext);
|
2024-05-12 07:45:51 +08:00
|
|
|
const { state } = useLocation()
|
2024-05-07 17:00:32 +08:00
|
|
|
// console.log('传递过来的参数',state.keyword);
|
|
|
|
// if(state){
|
|
|
|
// console.log('传递过来的参数',state.keyword);
|
|
|
|
// // setKeywords(state.keyword)
|
|
|
|
// }
|
2024-05-12 07:45:51 +08:00
|
|
|
const keywords = state ? state.keyword : ''
|
2024-05-07 17:00:32 +08:00
|
|
|
// console.log(keywords);
|
2024-05-23 14:57:22 +08:00
|
|
|
const images = [syminga,symingb,symingc,symingd]
|
2024-03-13 16:11:28 +08:00
|
|
|
const listProjRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
|
|
|
const listRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
|
|
|
|
2024-03-20 18:30:39 +08:00
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
const [page, setPage] = useState(1);
|
2024-05-28 18:00:42 +08:00
|
|
|
const [showPage, setShowPage] = useState(true);
|
|
|
|
|
2024-03-20 18:30:39 +08:00
|
|
|
const [total, setTotal] = useState(0);
|
2024-03-27 18:56:48 +08:00
|
|
|
const [projs, setProjs] = useState<IProj[]>([]);
|
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
2024-05-07 17:00:32 +08:00
|
|
|
// const [keywords, setKeywords] = useState('');
|
2024-05-16 18:00:57 +08:00
|
|
|
const domHeight = window.innerHeight - 250;
|
2024-05-12 07:45:51 +08:00
|
|
|
// const navigate = useNavigate()
|
2024-03-20 18:30:39 +08:00
|
|
|
const reqData = (currentPage: number) => {
|
2024-05-28 18:00:42 +08:00
|
|
|
setProjs([])
|
|
|
|
|
2024-03-27 18:56:48 +08:00
|
|
|
get<IListPage<IProj>>({
|
2024-03-20 18:30:39 +08:00
|
|
|
messageApi: messageApi,
|
|
|
|
url: '/api/proj/listpage/self',
|
|
|
|
config: {
|
|
|
|
params: {
|
|
|
|
page: currentPage,
|
2024-05-22 16:18:38 +08:00
|
|
|
rows: 10,
|
2024-05-12 07:45:51 +08:00
|
|
|
keywords: keywords,
|
2024-04-01 20:39:22 +08:00
|
|
|
projCategoryId: indexListContext.category,
|
2024-05-28 18:00:42 +08:00
|
|
|
status: indexListContext.status ? indexListContext.status : getMenuActive()
|
2024-03-20 18:30:39 +08:00
|
|
|
}
|
|
|
|
},
|
2024-03-27 18:56:48 +08:00
|
|
|
onBefore() {
|
|
|
|
setIsLoading(true);
|
|
|
|
},
|
2024-04-29 17:22:26 +08:00
|
|
|
onSuccess({ data }) {
|
2024-05-22 18:08:16 +08:00
|
|
|
console.log('看看结果', data);
|
2024-03-27 18:56:48 +08:00
|
|
|
setPage(data.page);
|
2024-03-20 18:30:39 +08:00
|
|
|
setTotal(data.total);
|
2024-05-23 14:57:22 +08:00
|
|
|
// setProjs(data.rows);
|
|
|
|
const updatedArr = (data.rows).map((item, index) => ({
|
|
|
|
...item,
|
|
|
|
img: images[index % images.length] // 利用取余来循环填充图片
|
|
|
|
}));
|
|
|
|
console.log('循环数组',updatedArr);
|
|
|
|
setProjs(updatedArr);
|
|
|
|
|
2024-03-27 18:56:48 +08:00
|
|
|
},
|
|
|
|
onFinally() {
|
|
|
|
setIsLoading(false);
|
2024-03-19 19:19:07 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const renderList = () => {
|
2024-04-01 20:39:22 +08:00
|
|
|
if (projs.length == 0) {
|
2024-03-28 19:35:54 +08:00
|
|
|
return (
|
2024-04-01 20:39:22 +08:00
|
|
|
<div className="no-data" style={{
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
backgroundColor: 'var(--color-light)',
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center'
|
|
|
|
}}>
|
2024-05-23 14:57:22 +08:00
|
|
|
<Empty description='暂无内容' />
|
2024-03-28 19:35:54 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2024-04-02 18:45:46 +08:00
|
|
|
return projs.map((item) => {
|
2024-05-12 07:45:51 +08:00
|
|
|
return (
|
|
|
|
<div className='projListBox' key={new Date().getTime() + ':' + item.projId}>
|
|
|
|
<CardProj item={item} />
|
|
|
|
</div>
|
|
|
|
)
|
2024-04-01 20:39:22 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const renderCategory = () => {
|
2024-03-19 19:19:07 +08:00
|
|
|
}
|
2024-05-23 14:57:22 +08:00
|
|
|
|
2024-05-28 18:00:42 +08:00
|
|
|
useEffect(() => {
|
|
|
|
setShowPage(false)
|
|
|
|
setPage(1)
|
|
|
|
if (indexListContext.categorys) {
|
|
|
|
reqData(1);
|
|
|
|
renderCategory();
|
|
|
|
}
|
|
|
|
console.log(page);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setShowPage(true)
|
|
|
|
}, 0);
|
|
|
|
}, [indexListContext.status,keywords])
|
|
|
|
|
2024-03-19 19:19:07 +08:00
|
|
|
useEffect(() => {
|
2024-04-02 18:45:46 +08:00
|
|
|
if (indexListContext.categorys) {
|
2024-05-28 18:00:42 +08:00
|
|
|
|
2024-04-02 18:45:46 +08:00
|
|
|
reqData(page);
|
|
|
|
renderCategory();
|
|
|
|
}
|
2024-05-28 18:00:42 +08:00
|
|
|
}, [indexListContext.categoryChangeCount, indexListContext.category])
|
2024-05-22 18:08:16 +08:00
|
|
|
|
2024-04-29 17:22:26 +08:00
|
|
|
// const renderStatus = () => {
|
|
|
|
// if (indexListContext.status == 'ALL') {
|
|
|
|
// return <Tag color="blue">项目:全部项目</Tag>
|
|
|
|
// } else if (indexListContext.status == 'PROCESSING') {
|
|
|
|
// return <Tag color="blue">项目:进行中的</Tag>
|
|
|
|
// } else if (indexListContext.status == 'COMPLETE') {
|
|
|
|
// return <Tag color="blue">项目:已完成的</Tag>
|
|
|
|
// }
|
|
|
|
// return <></>
|
|
|
|
// }
|
2024-03-28 19:35:54 +08:00
|
|
|
|
2024-03-13 16:11:28 +08:00
|
|
|
return (
|
2024-03-20 18:30:39 +08:00
|
|
|
<>
|
|
|
|
{contextHolder}
|
|
|
|
<div className="list-proj" ref={listProjRef}>
|
2024-05-07 17:00:32 +08:00
|
|
|
|
2024-03-20 18:30:39 +08:00
|
|
|
<div className="body">
|
2024-03-27 18:56:48 +08:00
|
|
|
<Spin tip="加载中..." spinning={isLoading}>
|
2024-05-12 07:45:51 +08:00
|
|
|
<div className="list" ref={listRef} style={{ height: `${domHeight}px` }}>
|
2024-03-27 18:56:48 +08:00
|
|
|
{renderList()}
|
|
|
|
</div>
|
2024-05-07 17:00:32 +08:00
|
|
|
<div className="page" >
|
2024-05-22 18:08:16 +08:00
|
|
|
{/* defaultCurrent: 默认当前页数 total:数据总数 */}
|
2024-05-28 18:00:42 +08:00
|
|
|
{showPage?<Pagination defaultCurrent={page} total={total} defaultPageSize={10} onChange={(page) => {
|
2024-05-12 07:45:51 +08:00
|
|
|
reqData(page);
|
2024-05-28 18:00:42 +08:00
|
|
|
}} /> : null}
|
2024-03-27 18:56:48 +08:00
|
|
|
</div>
|
|
|
|
</Spin>
|
2024-03-13 16:11:28 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-20 18:30:39 +08:00
|
|
|
</>
|
2024-03-13 16:11:28 +08:00
|
|
|
)
|
|
|
|
}
|