forked from Gitlink/forgeplus-react
竞赛列表页记录第几页
This commit is contained in:
parent
f6ffe6357c
commit
5e98cebfd3
|
@ -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);}}
|
||||
>
|
||||
<Option key={' '} >专家评审</Option>
|
||||
<Option key={true} >已提交评审</Option>
|
||||
|
@ -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(
|
||||
<div className="centerbox competitionList">
|
||||
|
@ -360,7 +376,7 @@ function Competition(props){
|
|||
dataSource={competitionList}
|
||||
columns={columns}
|
||||
total={total}
|
||||
setCurPage={setCurPage}
|
||||
setCurPage={(page)=>{updateUrl(page)}}
|
||||
current={curPage}
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue