import './list-proj.css' import CardProj from "../card/CardProj.tsx"; import { useRef, MutableRefObject, useState, useEffect, useContext } from "react"; import { Pagination, message, Spin, Image } from 'antd'; 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"; import NoData from "../../assets/no-data.png"; import { useLocation } from 'react-router-dom'; // 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; export default function ListProj() { const indexListContext = useContext(IndexListContext); const { state } = useLocation() // console.log('传递过来的参数',state.keyword); // if(state){ // console.log('传递过来的参数',state.keyword); // // setKeywords(state.keyword) // } const keywords = state ? state.keyword : '' // console.log(keywords); const listProjRef: MutableRefObject = useRef(null); const listRef: MutableRefObject = useRef(null); const [messageApi, contextHolder] = message.useMessage(); const [page, setPage] = useState(1); const [total, setTotal] = useState(0); const [projs, setProjs] = useState([]); const [isLoading, setIsLoading] = useState(false); // const [keywords, setKeywords] = useState(''); const domHeight = window.innerHeight - 250; // const navigate = useNavigate() const reqData = (currentPage: number) => { get>({ messageApi: messageApi, url: '/api/proj/listpage/self', config: { params: { page: currentPage, rows: 10, keywords: keywords, projCategoryId: indexListContext.category, status: indexListContext.status ? indexListContext.status : '' } }, onBefore() { setIsLoading(true); }, onSuccess({ data }) { // console.log('看看结果', data); setPage(data.page); setTotal(data.total); setProjs(data.rows); }, onFinally() { setIsLoading(false); } }) } const renderList = () => { if (projs.length == 0) { return (
暂无数据
) } return projs.map((item) => { return (
) }); } const renderCategory = () => { } useEffect(() => { if (indexListContext.categorys) { reqData(page); renderCategory(); } }, [indexListContext.status, indexListContext.categoryChangeCount, indexListContext.category, keywords, page]) useEffect(() => { }, [indexListContext.status]) // const renderStatus = () => { // if (indexListContext.status == 'ALL') { // return 项目:全部项目 // } else if (indexListContext.status == 'PROCESSING') { // return 项目:进行中的 // } else if (indexListContext.status == 'COMPLETE') { // return 项目:已完成的 // } // return <> // } return ( <> {contextHolder}
{renderList()}
{ reqData(page); // setPage(page); }} />
) }