竞赛调整

dev_sync_trustie
杨树明 5 years ago
parent ddf7bbfcbf
commit ed27ace015

@ -21,7 +21,8 @@ class CompetitionCommon extends Component{
module_type:undefined, module_type:undefined,
mdContentdata:undefined, mdContentdata:undefined,
chart_rules:undefined, chart_rules:undefined,
Competitionedittype:false Competitionedittype:false,
chartdata:undefined
} }
} }
@ -40,7 +41,6 @@ class CompetitionCommon extends Component{
console.log(error) console.log(error)
}) })
} }
} }
getbannerdata=()=>{ getbannerdata=()=>{
@ -61,9 +61,8 @@ class CompetitionCommon extends Component{
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}) })
//console.log(this.props)
if(this.props.user&&this.props.user.login!= ""){
if(this.props.user&&this.props.user.login!= ""){
const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`;
axios.get((zul)).then((result) => { axios.get((zul)).then((result) => {
if (result) { if (result) {
@ -99,7 +98,6 @@ class CompetitionCommon extends Component{
} }
getnewchartdata=(typeid,tabkey)=>{ getnewchartdata=(typeid,tabkey)=>{
if(typeid==="chart"){ if(typeid==="chart"){
let url=`/competitions/${this.props.match.params.identifier}/chart_rules.json`; let url=`/competitions/${this.props.match.params.identifier}/chart_rules.json`;
axios.get(url) axios.get(url)
@ -117,9 +115,8 @@ class CompetitionCommon extends Component{
}) })
} }
} }
getrightdata=(id,typeid,module_url,has_url,listkey)=>{
getrightdata=(id,typeid,module_url,has_url,listkey)=>{
if(typeid==="enroll"){ if(typeid==="enroll"){
this.props.history.replace(`/newcompetitions/${this.props.match.params.identifier}/enroll`); this.props.history.replace(`/newcompetitions/${this.props.match.params.identifier}/enroll`);
return return
@ -131,9 +128,17 @@ class CompetitionCommon extends Component{
let url=`${module_url}`; let url=`${module_url}`;
axios.get(url).then((response) => { axios.get(url).then((response) => {
if(response.status===200){ if(response.status===200){
this.setState({
mdContentdata:response.data if(typeid==="chart"){
}) this.setState({
chartdata:response.data
})
}else{
this.setState({
mdContentdata:response.data
})
}
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -147,14 +152,13 @@ class CompetitionCommon extends Component{
module_id:id, module_id:id,
module_type:typeid module_type:typeid
}) })
} }
Competitionedit=()=>{ Competitionedit=()=>{
this.setState({ this.setState({
Competitionedittype:true Competitionedittype:true
}) })
} }
hideCompetitionedit=()=>{ hideCompetitionedit=()=>{
@ -175,7 +179,6 @@ class CompetitionCommon extends Component{
} }
if(url===undefined){ if(url===undefined){
let {data,signupdata}=this.state; let {data,signupdata}=this.state;
if(signupdata.enrolled===true){ if(signupdata.enrolled===true){
this.props.history.replace(`/courses/${data.course_id}`); this.props.history.replace(`/courses/${data.course_id}`);
}else{ }else{
@ -194,19 +197,18 @@ class CompetitionCommon extends Component{
} }
}) })
} }
} }
}else{ }else{
this.props.history.replace(url); this.props.history.replace(url);
} }
} }
Competitioncallback=(key)=>{
Competitioncallback=(key)=>{
this.setState({ this.setState({
tabkey:key tabkey:key
}) })
} }
render() { render() {
let {data,bannerdata,module_type,Competitionedittype,mdContentdata}=this.state; let {data,bannerdata,module_type,Competitionedittype,mdContentdata}=this.state;
@ -300,7 +302,6 @@ class CompetitionCommon extends Component{
<Layout className={'teamsLayout mt40'}> <Layout className={'teamsLayout mt40'}>
<Sider> <Sider>
<Menu mode="inline" className="CompetitionMenu" defaultSelectedKeys={['1']} onClick={(e)=>this.getrightdatas(e)}> <Menu mode="inline" className="CompetitionMenu" defaultSelectedKeys={['1']} onClick={(e)=>this.getrightdatas(e)}>
{data&&data.competition_modules.map((item,key)=>{ {data&&data.competition_modules.map((item,key)=>{
return( return(
<Menu.Item key={item.position}> <Menu.Item key={item.position}>
@ -314,7 +315,6 @@ class CompetitionCommon extends Component{
</Menu.Item> </Menu.Item>
) )
})} })}
</Menu> </Menu>
</Sider> </Sider>

@ -19,9 +19,14 @@ class CompetitionContents extends Component{
window.document.title = '竞赛'; window.document.title = '竞赛';
} }
render() { render() {
const operations = <Button className={"fr"} type="primary" ghost onClick={()=>this.props.Competitionedit()}>编辑</Button>; const operations =
<div>
<Button className={"fr"} type="primary" ghost onClick={()=>this.props.Competitionedit()}>编辑</Button>
<Button className={"fr mr20"} type="primary" ghost>
<a href={`/competitions/${this.props.match.params.identifier}/charts.xlsx`}>导出</a>
</Button>
</div>
const columns = [ const columns = [
{ {
title: 'usersum', title: 'usersum',
@ -61,143 +66,163 @@ class CompetitionContents extends Component{
}, },
]; ];
const data = [ const data = [];
{ let {chart_rules,chartdata}=this.props;
usersum: '1', chartdata===undefined?"":chartdata.teams.length===0?"":chartdata.teams.map((item,key)=>{
userimg: 'John Brown', if(key>3){
username: "小头鹰", let list={
school: '吉首大学', usersum:key,
spendtime: '150000', userimg:item.user_image,
score:123123 username:item.record_user_name,
school:item.school_name,
spendtime:item.spend_time,
score:item.score,
user_login:item.user_login
}
data.push(list)
} }
]; })
let {chart_rules,tabkey}=this.props;
console.log(this.props.chartdata&&this.props.chartdata.user_ranks)
return ( return (
<div> <div>
{chart_rules===undefined?"":<Tabs onChange={(e)=>this.props.Competitioncallback(e)} activeKey={this.props.tabkey} tabBarExtraContent={this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true?this.props.Competitionedittype===false?operations:"":""}> {chart_rules===undefined?"":<Tabs onChange={(e)=>this.props.Competitioncallback(e)} activeKey={this.props.tabkey} tabBarExtraContent={this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true?this.props.Competitionedittype===false?operations:"":""}>
{chart_rules.stages.map((item,key)=>{ {chart_rules.stages.map((item,key)=>{
return( return(
<TabPane tab={item.name} key={item.id===null?0:item.id}> <TabPane tab={item.name} key={item.id===null?0:item.id}>
{chart_rules.rule_contents.map((items,keys)=>{ {chart_rules.rule_contents.map((items,keys)=>{
if(item.id===items.competition_stage_id){ if(item.id===items.competition_stage_id){
return( return(
<Content key={keys} className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML(items.content).replace(/▁/g, "▁▁▁")}}> <Content key={keys} className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML(items.content).replace(/▁/g, "▁▁▁")}}></Content>
</Content>
) )
}else if(item.id===null&&items.competition_stage_id===0){ }else if(item.id===null&&items.competition_stage_id===0){
return( return(
<Content key={keys} className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML(items.content).replace(/▁/g, "▁▁▁")}}> <Content key={keys} className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML(items.content).replace(/▁/g, "▁▁▁")}}></Content>
</Content>
) )
} }
})} })}
</TabPane> </TabPane>
) )
})} })}
</Tabs>} </Tabs>}
<Col className="gutter-row Competitioncharts mt30 mb30"> <Col className="gutter-row Competitioncharts mt30 mb30">总排名</Col>
总排名
</Col>
<Row calssName={"Competition399"}> <Row calssName={"Competition399"}>
<Col className="mt40" xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}> {chartdata===undefined?"":chartdata.teams.length===0?"":chartdata.teams.map((item,key)=>{
<Card
className={"Competitionthird"} if(key===1){
cover={ return(
<div className={"Competitionthirdbox center"}> <Col xs={{ span: 11, offset: 1 }} lg={{ span: 6, offset: 1 }}>
<li className="pr Competitioncenter"> <Card
<img src={getImageUrl("images/educoder/huangguan-two.png")}/> className={"Competitionfirst"}
<div className={"mt10"}> cover={
<a href="/users/p45296381" className="color-dark"> <div className={"Competitionfirstbox center"}>
<img className={"rankingimg"} src={getImageUrl("images/avatars/User/45459?t=1566570434")} /> <li className="pr Competitioncenter">
<p className="task-hide rankName mt5 jinshaifont">蒙睿</p> <img src={getImageUrl("images/educoder/huangguan.png")}/>
</a> <div className={"mt10"}>
<a href={`/users/${item.user_login}`} className="color-dark">
<img className={"rankingimg"} src={getImageUrl(item.user_image)} />
<p className="task-hide rankName mt5 jinshaifont">{item.record_user_name}</p>
</a>
</div>
</li>
</div>
}
>
<Meta
title={<div className={"center"}>
<div className={"rankfonttop"}>{item.school_name}</div>
<div className={"rankfontmid"}>{item.spend_time}</div>
</div>}
description={
<div className={"rankfontbottoms"}>{item.score}</div>
}
/>
</Card>
</Col>
)
}
if(key===2){
return(
<Col className="mt30" xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 1 }}>
<Card
className={"Competitionsecondary "}
cover={
<div className={"Competitionsecondarybox center"}>
<li className=" pr Competitioncenter ">
<img src={getImageUrl("images/educoder/huangguan-three.png")}/>
<div className={"mt10"}>
<a href={`/users/${item.user_login}`} className="color-dark">
<img className={"rankingimg"} src={getImageUrl(item.user_image)} />
<p className="task-hide rankName mt5 jinshaifont">{item.record_user_name}</p>
</a>
</div>
</li>
</div>
}
>
<Meta
title={<div className={"center"}>
<div className={"rankfonttop"}>{item.school_name}</div>
<div className={"rankfontmid"}>{item.spend_time}</div>
</div>}
description={
<div className={"rankfontbottom"}>{item.score}</div>
}
/>
</Card>
</Col>
)
}
if(key===3){
return(
<Col className="mt40" xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}>
<Card
className={"Competitionthird"}
cover={
<div className={"Competitionthirdbox center"}>
<li className="pr Competitioncenter">
<img src={getImageUrl("images/educoder/huangguan-two.png")}/>
<div className={"mt10"}>
<a href={`/users/${item.user_login}`} className="color-dark">
<img className={"rankingimg"} src={getImageUrl(item.user_image)} />
<p className="task-hide rankName mt5 jinshaifont">{item.user_name}</p>
</a>
</div>
</li>
</div> </div>
</li> }
</div> >
} <Meta
> title={<div className={"center"}>
<Meta <div className={"rankfonttop"}>{item.school_name}</div>
title={<div className={"center"}> <div className={"rankfontmid"}>{item.spend_time}</div>
<div className={"rankfonttop"}>吉首大学</div> </div>}
<div className={"rankfontmid"}>78:01:02</div> description={
</div>} <div className={"rankfontbottom"}>{item.score}</div>
description={ }
<div className={"rankfontbottom"}>3423.45</div> />
} </Card>
/> </Col>
</Card>
</Col> )
<Col xs={{ span: 11, offset: 1 }} lg={{ span: 6, offset: 1 }}> }
<Card
className={"Competitionfirst"} })}
cover={
<div className={"Competitionfirstbox center"}>
<li className="pr Competitioncenter">
<img src={getImageUrl("images/educoder/huangguan.png")}/>
<div className={"mt10"}>
<a href="/users/p37219480" className="color-dark">
<img className={"rankingimg"} src={getImageUrl("images/avatars/User/46128?t=1561087919")} />
<p className="task-hide rankName mt5 jinshaifont">李羿锟</p>
</a>
</div>
</li>
</div>
}
>
<Meta
title={<div className={"center"}>
<div className={"rankfonttop"}>吉首大学</div>
<div className={"rankfontmid"}>78:01:02</div>
</div>}
description={
<div className={"rankfontbottoms"}>3423.45</div>
}
/>
</Card>
</Col>
<Col className="mt30" xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 1 }}>
<Card
className={"Competitionsecondary "}
cover={
<div className={"Competitionsecondarybox center"}>
<li className=" pr Competitioncenter ">
<img src={getImageUrl("images/educoder/huangguan-three.png")}/>
<div className={"mt10"}>
<a href="/users/p53601847" className="color-dark">
<img className={"rankingimg"} src={getImageUrl("images/avatars/User/26650?t=1561087884")} />
<p className="task-hide rankName mt5 jinshaifont">陈翊</p>
</a>
</div>
</li>
</div>
}
>
<Meta
title={<div className={"center"}>
<div className={"rankfonttop"}>吉首大学</div>
<div className={"rankfontmid"}>78:01:02</div>
</div>}
description={
<div className={"rankfontbottom"}>3423.45</div>
}
/>
</Card>
</Col>
</Row> </Row>
<Row className={"mt80 mb80"}> <Row className={"mt80 mb80"}>
<Table className="Competitiontransparent" columns={columns} dataSource={data} showHeader={false} pagination={false}/> {chartdata===undefined?"":chartdata.teams.length===0?"":<Table className="Competitiontransparent" columns={columns} dataSource={data} showHeader={false} pagination={false}/>}
</Row> </Row>

Loading…
Cancel
Save