diff --git a/src/military/expert/competionList/index.jsx b/src/military/expert/competionList/index.jsx index 8c9db432..c9ff51b5 100644 --- a/src/military/expert/competionList/index.jsx +++ b/src/military/expert/competionList/index.jsx @@ -17,10 +17,11 @@ for (const item of competitionStatus) { // 竞赛任务状态 current_status 1报名中 2即将开始 3比赛进行中 4作品评选中 5公示中 6已结束 function Competition(props){ - const {mygetHelmetapi, showNotification} = props; + const {mygetHelmetapi, showNotification, history} = props; const {main_web_site_url} = mygetHelmetapi; + const {hash} = history && history.location; const [loading, setLoading] = useState(false); - const [curPage, setCurPage] = useState(1); + const [curPage, setCurPage] = useState(hashDate(hash) || 1); //是否加入专家评审流程 const [expertReview,setExpertReview] = useState(undefined); //竞赛任务总数 @@ -60,7 +61,7 @@ function Competition(props){ className="column-select" showArrow defaultValue={' '} - onChange={(value)=>{setExpertReview(value);setCurPage(1);}} + onChange={(value)=>{setExpertReview(value);updateUrl(1);}} > @@ -259,6 +260,16 @@ function Competition(props){ }) } + // 修改路由,跳转到第几页 + function updateUrl(page){ + setCurPage(page); + window.location.href=`/expert/admin/competition/#page=${page}`; + } + + function hashDate(hash) { + return parseInt(hash.split("&")[0].substring(hash.split("&")[0].indexOf("=")+1)); + } + //获取竞赛任务列表 useEffect(()=>{ setLoading(true); @@ -352,6 +363,11 @@ function Competition(props){ }); pulicReview && setPublicReview(false); },[lookRules,lookExperts,pulicReview]) + + //监听hash路由的变化,由此控制页数 + useEffect(()=>{ + setCurPage(hashDate(hash) || 1); + },[hash]) return(
@@ -360,7 +376,7 @@ function Competition(props){ dataSource={competitionList} columns={columns} total={total} - setCurPage={setCurPage} + setCurPage={(page)=>{updateUrl(page)}} current={curPage} />