From 5e98cebfd3d6ead06ddeb02eae757cdc1c24d156 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2022 17:07:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=AC=AC=E5=87=A0=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/military/expert/competionList/index.jsx | 24 +++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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} />