Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_auth
cxt 5 years ago
commit 72b95c7701

@ -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

@ -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;

@ -31,6 +31,7 @@ class Registration extends React.Component {
*"teacher_staff": { // 为空表示不支持老师报名
*"member_staff": { // 为空表示不支持学生报名
* personal// 是否是个人赛
* type 是按设计图来的
* **/
constructor(props) {
super(props)

@ -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 ?
"" :
<div style={{marginLeft: "53px", minHeight: "14px", height: "14px"}}></div> :
<div>
<div style={{
@ -1368,7 +1375,7 @@ class PersonModal extends Component {
{/*队员*/}
{
member_staff === undefined || member_staff === null ?
"" :
<div style={{marginLeft: "53px", minHeight: "18px", height: "18px"}}></div> :
<div>
<div style={{
display: "flex",

@ -88,6 +88,7 @@ class CompetitionsIndex extends Component{
background-position: center;
background-repeat: no-repeat;
}
`
}
</style>
@ -123,10 +124,10 @@ class CompetitionsIndex extends Component{
size="large"
dataSource={datas&&datas}
renderItem={(item,key) => (
<div
<a href={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}
className={item.competition_status==="ended"?"competitionstitlesshou":item.competition_status==="nearly_published"?
this.props.current_user&&this.props.current_user.admin===true?"competitionstitlesshou":this.props.current_user&&this.props.current_user.business===true?"competitionstitlesshou":"endedfont":"competitionstitlesshou"}
onClick={()=>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)}>
>
<div className={"CompetitionsList"} >
{item.competition_status==="nearly_published"?
@ -180,18 +181,18 @@ class CompetitionsIndex extends Component{
<List.Item.Meta
title={<a className={item.competition_status==="ended"?"competitionstitlesshou":item.competition_status==="nearly_published"?
this.props.current_user&&this.props.current_user.admin===true?"competitionstitlesshou":this.props.current_user&&this.props.current_user.business===true?"competitionstitlesshou":"endedfont":"competitionstitlesshou"}>
<span className={"competitionstitles"}
onClick={()=>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}`}</span>
<a className={"competitionstitles"}
href={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}`}</a>
{/*<span>{item.sub_title===null?"":*/}
{/*<Tag className="competitionsrelative" color="#87d068">{item.sub_title}</Tag>}*/}
{/*</span>*/}
</a>}
/>
{item.description}
<span className={"span666"}>{item.description}</span>
</List.Item>
</div>
</div>
</a>
)

@ -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;
}

@ -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;
}

@ -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?"":<div className={"educontent clearfix mt20 "}>

@ -26,9 +26,9 @@ class CompetitionContents extends Component{
return (
<div className={"fr"}>
{this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true?this.props.Competitionedittype===false?<Button className={"fr"} type="primary" ghost onClick={()=>this.props.Competitionedit()}>
{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?<Button className={"fr"} type="primary" ghost onClick={()=>this.props.Competitionedit()}>
编辑
</Button>:"":""}
</Button>:"":"":""}
<div className={this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true?"mt50 mb100 ":"mb100 "}>
<Content className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML(mdContentdata===undefined?"":mdContentdata.md_content===undefined||mdContentdata.md_content===null?"":mdContentdata.md_content).replace(/▁/g, "▁▁▁")}}>
</Content>

@ -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 =
<div>
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>
<a onClick={()=>this.derivefun(`/competitions/${this.props.match.params.identifier}/charts.xlsx`)}>导出</a>
</Button>
</div>
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 (
<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?this.props.has_url===false?operations:"":"":""}>
{chart_rules.stages.map((item,key)=>{
return(
<TabPane tab={item.name} key={item.id===null?0:item.id}>
@ -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(
<Col className="mt40" xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }}>
<Card
@ -134,7 +179,7 @@ class CompetitionContents extends Component{
<div className={"mt10"}>
<a href={`/users/${item.user_login}`} className="color-dark">
<img className={"rankingimg"} src={getImageUrl(`images/${item.user_image===null?`avatars/User/0?1442652658`:item.user_image}`)} />
<p className="task-hide rankName mt5 jinshaifont">{item.user_name}</p>
<p className="task-hide rankName mt5 jinshaifont">{personal===undefined||personal===null?item.record_user_name:personal===true?item.record_user_name:item.team_name}</p>
</a>
</div>
</li>
@ -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(
<Col xs={{ span: 11, offset: 1 }} lg={{ span: 6, offset: 1 }}>
<Card
@ -170,7 +215,7 @@ class CompetitionContents extends Component{
<div className={"mt10"}>
<a href={`/users/${item.user_login}`} className="color-dark">
<img className={"rankingimg"} src={getImageUrl(`images/${item.user_image===null?`avatars/User/0?1442652658`:item.user_image}`)} />
<p className="task-hide rankName mt5 jinshaifont">{item.record_user_name}</p>
<p className="task-hide rankName mt5 jinshaifont">{personal===undefined||personal===null?item.record_user_name:personal===true?item.record_user_name:item.team_name}</p>
</a>
</div>
</li>
@ -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(
<Col className="mt30" xs={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 1 }}>
<Card
@ -206,7 +251,7 @@ class CompetitionContents extends Component{
<div className={"mt10"}>
<a href={`/users/${item.user_login}`} className="color-dark">
<img className={"rankingimg"} src={getImageUrl(`images/${item.user_image===null?`avatars/User/0?1442652658`:item.user_image}`)} />
<p className="task-hide rankName mt5 jinshaifont">{item.record_user_name}</p>
<p className="task-hide rankName mt5 jinshaifont">{personal===undefined||personal===null?item.record_user_name:personal===true?item.record_user_name:item.team_name}</p>
</a>
</div>
</li>
@ -237,9 +282,9 @@ class CompetitionContents extends Component{
<style>
{
`
.ant-col-4 {
width: 19%;
}
.ant-col-9 {
width: 35.5%;
}
`
}
@ -251,24 +296,24 @@ class CompetitionContents extends Component{
<Col span={4} order={1}>
<span className={"ranknames"}>您当前排名:{item.rank}</span>
</Col>
<Col span={4} order={2}>
<Col className="userranksclass" span={3} order={2}>
{item.user_name}
</Col>
<Col span={4} order={3}>
<Col className="textleft" span={9} order={3}>
{item.team_name}
</Col>
<Col span={4} order={4}>
<Col span={3} order={4}>
{item.cost_time}
</Col>
<Col span={4} order={5}>
<Col className="textright" span={3} order={5}>
<span className={"ranknameslast"}>{item.score}</span>
</Col>
</Row>
)
})}
</div>}
<Row className={"mt80 mb80"}>
{chartdata===undefined?"":chartdata.teams.length===0||chartdata.teams.length<3?"":<Table className="Competitiontransparent" columns={columns} dataSource={data} showHeader={false} pagination={false}/>}
<Row className={"mt20 mb80"}>
{chartdata===undefined?"":chartdata.teams.length===0||chartdata.teams.length<4?"":<Table className="Competitiontransparent" columns={columns} dataSource={data} showHeader={false} pagination={false}/>}
</Row>

Loading…
Cancel
Save