diff --git a/app/forms/competitions/save_team_form.rb b/app/forms/competitions/save_team_form.rb index 1b2b6c4a8..be07a6365 100644 --- a/app/forms/competitions/save_team_form.rb +++ b/app/forms/competitions/save_team_form.rb @@ -39,9 +39,9 @@ class Competitions::SaveTeamForm # 存在已报名老师 enrolled_teacher_members = competition.team_members.where(user_id: all_teachers) - .where.not(competition_team_id: team.id).includes(:user) + .where.not(competition_team_id: team.id).pluck(:user_id) if enrolled_teacher_members.present? - errors.add(:teacher_ids, :enrolled, names: enrolled_teacher_members.map { |m| m.user.real_name }.join(',')) + errors.add(:teacher_ids, :enrolled, names: User.where(id: enrolled_teacher_members).map(&:real_name).join(',')) return end end @@ -72,9 +72,9 @@ class Competitions::SaveTeamForm # 存在已报名成员 enrolled_members = competition.team_members.where(user_id: all_members) - .where.not(competition_team_id: team.id).includes(:user) + .where.not(competition_team_id: team.id).pluck(:user_id) if enrolled_members.present? - errors.add(:member_ids, :enrolled, names: enrolled_members.map { |m| m.user.real_name }.join(',')) + errors.add(:member_ids, :enrolled, names: User.where(id: enrolled_members).map(&:real_name).join(',')) return end end diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 793542f4b..8c6f3be0b 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -47,8 +47,7 @@ export function initAxiosInterceptors(props) { proxy="https://pre-newweb.educoder.net" proxy="https://test-newweb.educoder.net" - - // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; + // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 const requestMap = {}; @@ -94,16 +93,17 @@ export function initAxiosInterceptors(props) { config.url = url; } } - - if (config.method === "post") { - if (requestMap[config.url] === true) { // 避免重复的请求 导致页面f5刷新 也会被阻止 显示这个方法会影响到定制信息定制信息是get 请求 - // console.log(config); - // console.log(JSON.parse(config)); - // console.log(config.url); - // console.log("被阻止了是重复请求================================="); - return false; - } - } + // + // console.log(config); + if (config.method === "post") { + if (requestMap[config.url] === true) { // 避免重复的请求 导致页面f5刷新 也会被阻止 显示这个方法会影响到定制信息 + // console.log(config); + // console.log(JSON.parse(config)); + // console.log(config.url); + // console.log("被阻止了是重复请求================================="); + return false; + } + } // 非file_update请求 if (config.url.indexOf('update_file') === -1) { requestMap[config.url] = true; diff --git a/public/react/src/modules/competition/Registration.js b/public/react/src/modules/competition/Registration.js index 66f98e56f..d39c6ec42 100644 --- a/public/react/src/modules/competition/Registration.js +++ b/public/react/src/modules/competition/Registration.js @@ -31,6 +31,7 @@ class Registration extends React.Component { *"teacher_staff": { // 为空表示不支持老师报名 *"member_staff": { // 为空表示不支持学生报名 * personal// 是否是个人赛 + * type 是按设计图来的 * **/ constructor(props) { super(props) diff --git a/public/react/src/modules/competition/competmodal/PersonModal.js b/public/react/src/modules/competition/competmodal/PersonModal.js index 121c170b5..37b72dc0e 100644 --- a/public/react/src/modules/competition/competmodal/PersonModal.js +++ b/public/react/src/modules/competition/competmodal/PersonModal.js @@ -295,6 +295,13 @@ class PersonModal extends Component { // ////console.log(result); if (result) { if (result.data) { + try { + if (result.data.status === 0) { + this.props.showNotification(`报名成功,预祝您夺得桂冠`); + } + } catch (e) { + + } this.props.Tmoconfirm1(true); } } @@ -1304,7 +1311,7 @@ class PersonModal extends Component { {/*导师*/} { teacher_staff === undefined || teacher_staff === null ? - "" : +
:
:
@@ -123,10 +124,10 @@ class CompetitionsIndex extends Component{ size="large" dataSource={datas&&datas} renderItem={(item,key) => ( -
this.setcompetitonurl(item.competition_status==="ended"?`/newcompetitions/${item.identifier}/common_header`:item.competition_status==="nearly_published"? this.props.current_user&&this.props.current_user.business===true?`/newcompetitions/${item.identifier}/common_header`:this.props.current_user&&this.props.current_user.admin===true?`/newcompetitions/${item.identifier}/common_header`:null:item.competition_status==="progressing"?`/newcompetitions/${item.identifier}/common_header`:null)}> + >
{item.competition_status==="nearly_published"? @@ -180,18 +181,18 @@ class CompetitionsIndex extends Component{ - this.setcompetitonurl(item.competition_status==="ended"?`/newcompetitions/${item.identifier}/common_header`:item.competition_status==="nearly_published"? this.props.current_user&&this.props.current_user.business===true?`/newcompetitions/${item.identifier}/common_header`:this.props.current_user&&this.props.current_user.admin===true?`/newcompetitions/${item.identifier}/common_header`:null:item.competition_status==="progressing"?`/newcompetitions/${item.identifier}/common_header`:null)} - >{item.name}{item.sub_title===null?"":`——${item.sub_title}`} + {item.name}{item.sub_title===null?"":`——${item.sub_title}`} {/*{item.sub_title===null?"":*/} {/*{item.sub_title}}*/} {/**/} } /> - {item.description} + {item.description}
-
+ ) diff --git a/public/react/src/modules/competitions/Competitimain/Competitionsindex.css b/public/react/src/modules/competitions/Competitimain/Competitionsindex.css index dda7fcf40..aa2c347f3 100644 --- a/public/react/src/modules/competitions/Competitimain/Competitionsindex.css +++ b/public/react/src/modules/competitions/Competitimain/Competitionsindex.css @@ -102,6 +102,7 @@ white-space: nowrap; display: inline-block; margin-right: 15px; + color:#000 !important; } .competitionsrelative{ @@ -130,13 +131,14 @@ text-align: center; color: #fff; font-size: 22px; - display: flex; + align-items: center; justify-content: space-around; flex-direction: column; } .CompetitionsList:hover .CompetitionsListzhezhao{ display: block; + display: flex; } .competitionstitlesshou:hover a{ cursor: pointer; @@ -154,4 +156,8 @@ background-position: center !important; background-position: 50% !important; background-repeat: no-repeat !important; +} + +.span666{ + color:#666666 !important; } \ No newline at end of file diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css index 22810c4b5..264642b7d 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.css @@ -56,7 +56,7 @@ } .teamsLayoucolor-orange { - color: #ff6800!important; + color: #ff6800 !important; font-size: 16px; } @@ -69,7 +69,7 @@ .CompetitionCommonbannerfont{ height:100%; - width: 365px; + width: 365px !important; line-height: 34px; } @@ -333,16 +333,19 @@ text-align: center; color: #fff; font-size: 22px; + +} + +.relative{position: relative;} + +.relative:hover .CompetitionsListzhezhao{ + display: block; display: flex; align-items: center; justify-content: space-around; flex-direction: column; } -.relative{position: relative;} - -.relative:hover .CompetitionsListzhezhao{ display: block;} - .image_urlbox{ width: 705px; /*height: 400px;*/ @@ -379,4 +382,19 @@ .ranknameslast{ font-size:16px; color:rgba(12,158,254,1); +} + +.textleft{ + text-align: left; +} + +.textright{ + text-align: right; +} + +.userranksclass{ + text-align: left; + width: 18%; + padding-left: 12px; + margin-right: 28px; } \ No newline at end of file diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js index 9c80366f3..e82cb52d7 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js @@ -22,7 +22,8 @@ class CompetitionCommon extends Component{ mdContentdata:undefined, chart_rules:undefined, Competitionedittype:false, - chartdata:undefined + chartdata:undefined, + has_url:false } } @@ -148,16 +149,19 @@ class CompetitionCommon extends Component{ }) }else{ if(module_url.substring(0,7)=='http://'||module_url.substring(0,8)=='https://') { - window.location.href= module_url + // window.location.href= module_url + window.open(module_url) }else{ - window.location.href="https://"+module_url; + window.open(`https://${module_url}`) + // window.location.href=; } return } this.setState({ module_id:id, - module_type:typeid + module_type:typeid, + has_url:has_url }) } @@ -214,10 +218,23 @@ class CompetitionCommon extends Component{ this.setState({ tabkey:key }) + let url=`/competitions/${this.props.match.params.identifier}/charts.json`; + axios.get(url,{params:{ + stage_id:key===0||key===null?undefined:key + }}).then((response) => { + if(response.status===200){ + this.setState({ + chartdata:response.data + }) + } + }).catch((error) => { + console.log(error) + }) + } render() { - let {data,bannerdata,module_type,Competitionedittype,mdContentdata}=this.state; + let {data,has_url,module_type,Competitionedittype,mdContentdata}=this.state; return ( data===undefined?"":
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContents.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionContents.js index a49384f71..ca99fde8e 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionContents.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionContents.js @@ -26,9 +26,9 @@ class CompetitionContents extends Component{ return (
- {this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true?this.props.Competitionedittype===false?:"":""} + :"":"":""}
diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js index 8432613e3..f287b66a5 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import {Button,Layout,Tabs,Icon, Card, Avatar, Row, Col ,Table} from 'antd'; import {markdownToHTML,getImageUrl} from 'educoder'; +import axios from 'axios'; import NoneData from "../../courses/shixunHomework/shixunHomework"; const { Content } = Layout; @@ -11,20 +12,63 @@ class CompetitionContents extends Component{ constructor(props) { super(props) this.state={ - + personal:undefined } } componentDidMount(){ window.document.title = '竞赛'; + let url=`/competitions/${this.props.match.params.identifier}/competition_staff.json`; + axios.get(url) + .then((response) => { + if(response.status===200){ + console.log(response) + this.setState({ + personal:response.data.personal + }) + } + }).catch((error) => { + console.log(error) + }) } + derivefun=(url)=>{ + axios.get(url).then((response)=>{ + if(response === undefined){ + return + } + if(response.data.status&&response.data.status===-1){ + this.props.showNotification(response.data.message); + }else if(response.data.status&&response.data.status===-2){ + // if(response.data.message === "100"){ + // // 已超出文件导出的上限数量(100 ),建议: + // + // this.setState({ + // DownloadType:true, + // DownloadMessageval:100 + // }) + // }else { + // //因附件资料超过500M + // this.setState({ + // DownloadType:true, + // DownloadMessageval:500 + // }) + // } + this.props.showNotification(response.data.message); + }else { + // this.props.showNotification(`正在下载中`); + // window.open("/api"+url, '_blank'); + this.props.slowDownload(url); + } + }).catch((error) => { + console.log(error) + }); + } render() { - const operations = -
+ const operations = const columns = [ @@ -71,13 +115,14 @@ class CompetitionContents extends Component{ const data = []; let {chart_rules,chartdata}=this.props; + let {personal}=this.state; chartdata===undefined?"":chartdata.teams.length===0||chartdata.teams.length<3?"":chartdata.teams.map((item,key)=>{ if(key>2){ let list={ usersum:key+1, userimg:item.user_image, - username:item.record_user_name, + username:personal===undefined||personal===null?item.record_user_name:personal===true?item.record_user_name:item.team_name, school:item.school_name, spendtime:item.spend_time, score:item.score, @@ -89,10 +134,10 @@ class CompetitionContents extends Component{ // - // console.log(this.props.chartdata&&this.props.chartdata.user_ranks) + //console.log(chartdata&&chartdata.teams) return (
- {chart_rules===undefined?"":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?"":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?this.props.has_url===false?operations:"":"":""}> {chart_rules.stages.map((item,key)=>{ return( @@ -122,7 +167,7 @@ class CompetitionContents extends Component{ {chartdata===undefined?"":chartdata.teams.length===0?"":chartdata.teams.map((item,key)=>{ - if(key===3){ + if(key===2){ return( -

{item.user_name}

+

{personal===undefined||personal===null?item.record_user_name:personal===true?item.record_user_name:item.team_name}

@@ -158,7 +203,7 @@ class CompetitionContents extends Component{ })} {chartdata===undefined?"":chartdata.teams.length===0?"":chartdata.teams.map((item,key)=>{ - if(key===1){ + if(key===0){ return( -

{item.record_user_name}

+

{personal===undefined||personal===null?item.record_user_name:personal===true?item.record_user_name:item.team_name}

@@ -194,7 +239,7 @@ class CompetitionContents extends Component{ } })} {chartdata===undefined?"":chartdata.teams.length===0?"":chartdata.teams.map((item,key)=>{ - if(key===2){ + if(key===1){ return( -

{item.record_user_name}

+

{personal===undefined||personal===null?item.record_user_name:personal===true?item.record_user_name:item.team_name}

@@ -237,9 +282,9 @@ class CompetitionContents extends Component{