forked from Gitlink/forgeplus-react
竞赛评审任务结果页面URL不携带参数请求竞赛详情接口
This commit is contained in:
parent
0bebecb28b
commit
feaf59c146
|
@ -98,6 +98,14 @@ export function getCompetition(id) {
|
|||
});
|
||||
}
|
||||
|
||||
// 获取竞赛详情接口
|
||||
export function getCompetitionDetail(id) {
|
||||
return fetch({
|
||||
url: `${main_web_site_url}/api/v1/competitions/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
// 查看竞赛/任务的评分细则
|
||||
export function getScoringDetails(params) {
|
||||
return fetch({
|
||||
|
|
|
@ -2,8 +2,9 @@ import React, { useEffect, useState } from "react";
|
|||
import Link from "react-router-dom/Link";
|
||||
import PaginationTable from "src/military/components/paginationTable";
|
||||
import GradesModal from "./gradesModal";
|
||||
import { getFinalScoreRankingList, getWinnersAndPublicists, selectWinnersAndPublicists } from "../api";
|
||||
import { Checkbox, Input, message, Modal } from "antd";
|
||||
import { getCompetitionDetail, getFinalScoreRankingList, getWinnersAndPublicists, selectWinnersAndPublicists } from "../api";
|
||||
import { getTaskDetail } from "src/military/task/api";
|
||||
import { Checkbox, Input, message, Modal, Spin } from "antd";
|
||||
import sucess from './image/sucess.svg';
|
||||
import './index.scss';
|
||||
import '../index.scss';
|
||||
|
@ -21,6 +22,7 @@ function ReviewResult({ history, match, mygetHelmetapi}) {
|
|||
const [errorMessage,setErrorMessage] = useState();
|
||||
const [result, setResult] = useState(undefined);
|
||||
const [goNum, setGoNum] = useState(-1);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
// 模态框
|
||||
const [opsDetail, setOpsDetail] = useState(undefined);
|
||||
|
@ -93,6 +95,35 @@ function ReviewResult({ history, match, mygetHelmetapi}) {
|
|||
})
|
||||
},[status])
|
||||
|
||||
//监听status, name, taskModeId 的变化,如果其中任意一个没有值都去请求任务详情接口获取其数据
|
||||
useEffect(()=>{
|
||||
const bool = status && name && taskModeId;
|
||||
if(containerType == 1 && !bool){
|
||||
setLoading(true);
|
||||
//创客任务
|
||||
containerId && getTaskDetail(containerId).then(response=>{
|
||||
if(response){
|
||||
window.location.href=`${window.location.href}#status=${response.status}&name=${response.name}&taskModeId=${response.taskModeId}`;
|
||||
}
|
||||
}).finally(()=>{
|
||||
setLoading(false);
|
||||
})
|
||||
}
|
||||
|
||||
const competitionBool = status && name && identifier;
|
||||
if(containerType == 2 && !competitionBool){
|
||||
setLoading(true);
|
||||
//竞赛
|
||||
containerId && getCompetitionDetail(containerId).then(response=>{
|
||||
if(response && response.message == "success"){
|
||||
window.location.href=`${window.location.href}#status=${response.data.current_status}&identifier=${response.data.identifier}&name=${response.data.title}`;
|
||||
}
|
||||
}).finally(()=>{
|
||||
setLoading(false);
|
||||
})
|
||||
}
|
||||
},[status, name, taskModeId, identifier])
|
||||
|
||||
function detail(item){
|
||||
setOpsDetail(item);
|
||||
setVisible(true);
|
||||
|
@ -151,53 +182,55 @@ function ReviewResult({ history, match, mygetHelmetapi}) {
|
|||
})
|
||||
}
|
||||
return (
|
||||
<div className="expert_review_system centerbox">
|
||||
<div className="head_title mb20">
|
||||
<div className="df pb10 pt10">
|
||||
<span className="font-16 font-w">评审结果</span>
|
||||
<button className="but41_border goback_but" onClick={()=>{history.go(goNum)}}>返回上一页</button>
|
||||
</div>
|
||||
<p className="mt10"><span className="font-w">{containerType ==1 ? '任务':'竞赛'}名称</span><span className="ml10">{decodeURI(name)}</span></p>
|
||||
<p className="mt10 pb20">
|
||||
<span className="font-w color-grey3">{containerType ==1 ? '任务':'竞赛'}链接</span>
|
||||
{containerType == 1 && <Link className="taskLink ml10" target="_blank" to={`/task/taskDetail/${containerId}`} >{`${window.location.origin}/task/taskDetail/${containerId}`}</Link>}
|
||||
{containerType == 2 && <a href={`${main_web_site_url}/competitions/${identifier}/home`} target="_blank" className="taskLink ml10">{`${main_web_site_url}/competitions/${identifier}/home`}</a>}
|
||||
</p>
|
||||
</div>
|
||||
{status > 3 ? <React.Fragment>
|
||||
<p className="font-16 font-w mb10">应征者排名</p>
|
||||
<PaginationTable
|
||||
dataSource= {dataList}
|
||||
columns= {columns}
|
||||
scroll={{ y: 384 }}
|
||||
/>
|
||||
<div className="openResult">
|
||||
{status == 4 && <button className={(containerType ==1 && winIds && taskModeId == 1 && winIds.length >1) || result === null ? 'disableBut': 'but41_fill'} onClick={openResult}>公示结果</button>}
|
||||
</div>
|
||||
</React.Fragment>:<div className="nodata font-20">暂无数据,此任务暂未进入成果评选阶段。</div>}
|
||||
<Modal
|
||||
title= "请确认公示范围"
|
||||
visible= {openResultVisible}
|
||||
wrapClassName="openResultModal"
|
||||
width={390}
|
||||
onCancel= {()=>setOpenResultVisible(false)}
|
||||
onOk={onOk}>
|
||||
<div className="df">
|
||||
公示排名前
|
||||
<Input placeholder="请输入" onChange={(e)=>{setOpenRange(e.target.value)}}/>
|
||||
名
|
||||
<Spin spinning={loading}>
|
||||
<div className="expert_review_system centerbox">
|
||||
<div className="head_title mb20">
|
||||
<div className="df pb10 pt10">
|
||||
<span className="font-16 font-w">评审结果</span>
|
||||
<button className="but41_border goback_but" onClick={()=>{history.go(goNum)}}>返回上一页</button>
|
||||
</div>
|
||||
<p className={`mt5 ${errorMessage && 'errorMes'}`}>{errorMessage || "若未填写此排名,则公示所有名次"}</p>
|
||||
</Modal>
|
||||
<p className="mt10"><span className="font-w">{containerType ==1 ? '任务':'竞赛'}名称</span><span className="ml10">{decodeURI(name)}</span></p>
|
||||
<p className="mt10 pb20">
|
||||
<span className="font-w color-grey3">{containerType ==1 ? '任务':'竞赛'}链接</span>
|
||||
{containerType == 1 && <Link className="taskLink ml10" target="_blank" to={`/task/taskDetail/${containerId}`} >{`${window.location.origin}/task/taskDetail/${containerId}`}</Link>}
|
||||
{containerType == 2 && <a href={`${main_web_site_url}/competitions/${identifier}/home`} target="_blank" className="taskLink ml10">{`${main_web_site_url}/competitions/${identifier}/home`}</a>}
|
||||
</p>
|
||||
</div>
|
||||
{status > 3 ? <React.Fragment>
|
||||
<p className="font-16 font-w mb10">应征者排名</p>
|
||||
<PaginationTable
|
||||
dataSource= {dataList}
|
||||
columns= {columns}
|
||||
scroll={{ y: 384 }}
|
||||
/>
|
||||
<div className="openResult">
|
||||
{status == 4 && <button className={(containerType ==1 && winIds && taskModeId == 1 && winIds.length >1) || result === null ? 'disableBut': 'but41_fill'} onClick={openResult}>公示结果</button>}
|
||||
</div>
|
||||
</React.Fragment>:<div className="nodata font-20">暂无数据,此任务暂未进入成果评选阶段。</div>}
|
||||
<Modal
|
||||
title= "请确认公示范围"
|
||||
visible= {openResultVisible}
|
||||
wrapClassName="openResultModal"
|
||||
width={390}
|
||||
onCancel= {()=>setOpenResultVisible(false)}
|
||||
onOk={onOk}>
|
||||
<div className="df">
|
||||
公示排名前
|
||||
<Input placeholder="请输入" onChange={(e)=>{setOpenRange(e.target.value)}}/>
|
||||
名
|
||||
</div>
|
||||
<p className={`mt5 ${errorMessage && 'errorMes'}`}>{errorMessage || "若未填写此排名,则公示所有名次"}</p>
|
||||
</Modal>
|
||||
|
||||
<GradesModal
|
||||
visible={visible}
|
||||
setVisible={setVisible}
|
||||
taskId={containerId}
|
||||
opsDetail={opsDetail}
|
||||
containerType={containerType}
|
||||
/>
|
||||
</div>
|
||||
<GradesModal
|
||||
visible={visible}
|
||||
setVisible={setVisible}
|
||||
taskId={containerId}
|
||||
opsDetail={opsDetail}
|
||||
containerType={containerType}
|
||||
/>
|
||||
</div>
|
||||
</Spin>
|
||||
)
|
||||
}
|
||||
export default ReviewResult;
|
Loading…
Reference in New Issue