diff --git a/app/assets/javascripts/admins/competition_settings/index.js b/app/assets/javascripts/admins/competition_settings/index.js index 9eb53d529..e974d2550 100644 --- a/app/assets/javascripts/admins/competition_settings/index.js +++ b/app/assets/javascripts/admins/competition_settings/index.js @@ -107,6 +107,34 @@ $(document).on('turbolinks:load', function(){ } }); }); + + var selectOptions = { + theme: 'bootstrap4', + placeholder: '请输入要添加的单位名称', + multiple: true, + minimumInputLength: 1, + ajax: { + delay: 500, + url: '/api/schools/for_option.json', + dataType: 'json', + data: function(params){ + return { keyword: params.term }; + }, + processResults: function(data){ + return { results: data.schools } + } + }, + templateResult: function (item) { + if(!item.id || item.id === '') return item.text; + return item.name || item.text; + }, + templateSelection: function(item){ + return item.name || item.text; + } + } + + $('.sponsor-select').select2(selectOptions); + $('.allow-school-select').select2(selectOptions); } }); @@ -291,7 +319,7 @@ $(function () { } }); - $('form.stage-update-form').on('click', ".update-stage", function () { + $('.competition-chart-setting').on('click', ".update-stage", function () { var updateForm = $(this).parents("form"); $(this).attr('disabled', 'disabled'); updateForm.find('.error').html(''); @@ -450,24 +478,83 @@ function Del_tab(item) { $(item).parents(".large_panel_part").remove(); } //新增tab -function addNewTab() { - var count = parseInt($("#large_panel").find(".large_panel_part").length)+1; - var html = '
\n' + - ' tab标题\n' + - '
\n' + - ' \n' + - '
\n' + - ' 总排行榜占比:\n' + - '
\n' + - ' \n' + - '
%\n' + - '
\n' + - ' 新增子阶段\n' + - '
\n' + - ' 删除\n' + - ' 保存\n' + - '
\n' + - '
'; - $("#large_panel").append(html); - +function addNewTab(competition_id) { + if($(".new-stage-form").length > 0){ + alert("请先保存上一个tab"); + } else { + var count = parseInt($("#large_panel").find(".large_panel_part").length)+1; + var html = '
' + + '
\n' + + ' tab标题\n' + + '
\n' + + ' \n' + + '
\n' + + ' 总排行榜占比:\n' + + '
\n' + + ' \n' + + '
%\n' + + '
\n' + + ' 新增子阶段\n' + + '
\n' + + ' 删除\n' + + ' 保存\n' + + '
\n' + + '
\n' + + '
\n' + + ' 第1阶段\n' + + '
\n' + + '
\n' + + ' 有效时间:\n' + + '
\n' + + ' \n' + + '
\n' + + ' ~\n' + + '
\n' + + ' \n' + + '
\n' + + ' 任务完成要求:\n' + + '
\n' + + ' \n' + + '
\n' + + ' /\n' + + '
\n' + + ' \n' + + '
\n' + + ' (总任务)\n' + + ' 成绩来源:\n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + ' 任务1\n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + '
\n' + + ' 任务2\n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + '
\n' + + ' 任务3\n' + + '
\n' + + ' \n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + ' \n' + + ' 删除\n' + + ' \n' + + '
\n' + + '
'; + $("#large_panel").append(html); + } } \ No newline at end of file diff --git a/app/controllers/admins/competition_stages_controller.rb b/app/controllers/admins/competition_stages_controller.rb index 5445d59a9..63e2429e3 100644 --- a/app/controllers/admins/competition_stages_controller.rb +++ b/app/controllers/admins/competition_stages_controller.rb @@ -1,14 +1,8 @@ class Admins::CompetitionStagesController < Admins::BaseController def create - Admins::CompetitionStageUpdateService.call(current_competition, update_form_params) + Admins::CompetitionStageCreateService.call(current_competition, update_form_params) render_ok - if current_competition.competition_stages.exists?(name: params[:stage_name]) - render_error "已存在同名的阶段" - else - current_competition.competition_stages << CompetitionStage.new(name: params[:stage_name]) - render_ok - end end def update diff --git a/app/controllers/competitions/competitions_controller.rb b/app/controllers/competitions/competitions_controller.rb index 2c3d00529..18e5bb371 100644 --- a/app/controllers/competitions/competitions_controller.rb +++ b/app/controllers/competitions/competitions_controller.rb @@ -30,6 +30,8 @@ class Competitions::CompetitionsController < Competitions::BaseController def show @competition = current_competition + + current_competition.increment(:visits) end def update diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 039d5e5c8..2504b8eb8 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1436,7 +1436,7 @@ class PollsController < ApplicationController if poll_un_anony user_login = u_user.login user_name = u_user.real_name.present? ? u_user.real_name : "--" - user_class = poll.course.user_group_name + user_class = poll.course.user_group_name(u_user.id) user_student_id = u_user.student_id.present? ? u_user.student_id : "--" user_school_name = u_user.school_name.present? ? u_user.school_name : "--" user_cell += [user_login,user_name, user_class, u_user.mail, user_student_id, user_school_name] diff --git a/app/services/admins/competition_stage_create_service.rb b/app/services/admins/competition_stage_create_service.rb index d11276ef3..4389a727d 100644 --- a/app/services/admins/competition_stage_create_service.rb +++ b/app/services/admins/competition_stage_create_service.rb @@ -10,8 +10,6 @@ class Admins::CompetitionStageCreateService < ApplicationService ActiveRecord::Base.transaction do stage = CompetitionStage.create!(competition_id: competition.id, name: params[:stage_name], score_rate: (params[:score_rate].to_i / 100).round(2)) - stage.competition_stage_sections.destroy_all - params[:stage].each do |section| stage_section = CompetitionStageSection.create!(competition_id: competition.id, competition_stage_id: stage.id, start_time: section["start_time"], end_time: section["end_time"], diff --git a/app/views/admins/competition_settings/index.html.erb b/app/views/admins/competition_settings/index.html.erb index 44e3da7ee..537291149 100644 --- a/app/views/admins/competition_settings/index.html.erb +++ b/app/views/admins/competition_settings/index.html.erb @@ -97,13 +97,8 @@
主办方
-
- + - +
+ <%= select_tag :sponsor_schools, options_for_select([], @competition.sponsor_schools), class: 'form-control sponsor-select' %>
@@ -111,13 +106,8 @@
开放范围
-
- + - +
+ <%= select_tag :region_schools, options_for_select([], @competition.region_schools), class: 'form-control allow-school-select' %>
@@ -333,7 +323,7 @@
排行榜设置 - + 新增tab + + 新增tab 实训ID填写示例:实训地址为https://www.educoder.net/shixuns/u5plmgka/challenges,则填写“u5plmgka”
@@ -430,7 +420,7 @@ 新增子阶段
删除 - 保存 + 保存
@@ -462,7 +452,26 @@
-
+
+
+ 任务1 +
+ +
+
+
+ 任务2 +
+ +
+
+
+ 任务3 +
+ +
+
+
删除 @@ -481,4 +490,4 @@ -<% end %> +<% end %> \ No newline at end of file diff --git a/public/react/config/webpack.config.prod.js b/public/react/config/webpack.config.prod.js index 886d97313..1cc105517 100644 --- a/public/react/config/webpack.config.prod.js +++ b/public/react/config/webpack.config.prod.js @@ -321,7 +321,7 @@ module.exports = { }, compress: { drop_debugger: true, - drop_console: true + drop_console: false } } }), diff --git a/public/react/src/modules/competition/CompetitionMaxImg.js b/public/react/src/modules/competition/CompetitionMaxImg.js index c5d99a88b..ce12ade1c 100644 --- a/public/react/src/modules/competition/CompetitionMaxImg.js +++ b/public/react/src/modules/competition/CompetitionMaxImg.js @@ -16,9 +16,6 @@ class CompetitionMaxImg extends React.Component { componentDidUpdate = (prevProps) => { if (prevProps.GetenrollmentAPI != this.props.GetenrollmentAPI) { - // ////console.log("团队竞赛报名大图componentDidUpdate"); - // ////console.log(this.props); - // ////console.log(this.props.GetenrollmentAPI); this.setState({ GetenrollmentAPI: this.props.GetenrollmentAPI, }) diff --git a/public/react/src/modules/competition/Registration.js b/public/react/src/modules/competition/Registration.js index 9bffc492c..cd6254981 100644 --- a/public/react/src/modules/competition/Registration.js +++ b/public/react/src/modules/competition/Registration.js @@ -2,7 +2,8 @@ import React, {Component} from 'react'; import { BrowserRouter as Router, Route, - Switch + Switch, + Link } from 'react-router-dom'; import axios from 'axios'; import moment from 'moment'; @@ -62,13 +63,16 @@ class Registration extends React.Component { itemid: undefined, itemiddata: [], pint: 0, - + competition_name: undefined, + mutiple_limited: false, + teamutiple_limited: false, + members_count: 0, } } componentDidMount() { - console.log(this.props); + // console.log(this.props); // //////console.log("componentDidMount Registration"); // //// //////console.log("调用子组件 "); @@ -87,8 +91,8 @@ class Registration extends React.Component { componentDidUpdate = (prevProps) => { if (prevProps.user != this.props.user) { - console.log("componentDidUpdate"); - console.log(this.props); + // console.log("componentDidUpdate"); + // console.log(this.props); ////console.log("Registration"); ////console.log("componentDidUpdate"); ////console.log(this.props.user.admin); @@ -101,6 +105,7 @@ class Registration extends React.Component { //获取报名配置API GetenrollmentAPI = () => { + // console.log("调用了GetenrollmentAPI"); const url = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; axios.get((url)).then((result) => { if (result) { @@ -112,26 +117,56 @@ class Registration extends React.Component { personal: result.data.personal, enroll_ended: result.data.enroll_ended, enrolled: result.data.enrolled, - teacher_staff: result.data.teacher_staff, - member_staff: result.data.member_staff, + teacher_staff: result.data.teacher_staff === undefined || result.data.teacher_staff === null ? undefined : result.data.teacher_staff, + member_staff: result.data.member_staff === undefined || result.data.member_staff === null ? undefined : result.data.member_staff, + }) - if (result.data.enroll_ended === true) { - this.setState({ - pint: 0 - }) - } else if (result.data.enrolled === true) { - this.setState({ - pint: 2 - }) - } else if (result.data.enrolled === false) { - this.setState({ - pint: 1 - }) + + try { + if (result.data.member_staff) { + this.setState({ + mutiple_limited: result.data.member_staff.mutiple_limited, + + }) + } + + + } catch (e) { + + } + + try { + if (result.data.teacher_staff) { + this.setState({ + teamutiple_limited: result.data.teacher_staff.mutiple_limited + }) + } + + } catch (e) { + + } + + if (result.data.personal === true) { + if (result.data.enroll_ended === true) { + this.setState({ + pint: 0 + }) + } else if (result.data.enrolled === true) { + this.setState({ + pint: 2 + }) + } else if (result.data.enrolled === false) { + this.setState({ + pint: 1 + }) + } } + } } }).catch((error) => { - //// //////console.log(error); + console.log("GetenrollmentAPI"); + console.log(error); }) } @@ -161,6 +196,8 @@ class Registration extends React.Component { data: result.data.my_teams, competition_teams: result.data.competition_teams, personal: result.data.personal, + competition_name: result.data.competition_name, + members_count: result.data.members_count }) } else { //普通账号 @@ -170,6 +207,8 @@ class Registration extends React.Component { data: result.data.my_teams, competition_teams: result.data.competition_teams, personal: result.data.personal, + competition_name: result.data.competition_name, + members_count: result.data.members_count }) } } else { @@ -183,6 +222,9 @@ class Registration extends React.Component { count: result.data.count, competition_teams: result.data.competition_teams, personal: result.data.personal, + competition_name: result.data.competition_name, + members_count: result.data.members_count + }) } else { @@ -192,6 +234,9 @@ class Registration extends React.Component { count: result.data.count, competition_teams: result.data.competition_teams, personal: result.data.personal, + competition_name: result.data.competition_name, + members_count: result.data.members_count + }) } @@ -203,6 +248,9 @@ class Registration extends React.Component { data: result.data.my_teams, count: result.data.count, personal: result.data.personal, + competition_name: result.data.competition_name, + members_count: result.data.members_count + }) } else { @@ -212,6 +260,9 @@ class Registration extends React.Component { data: result.data.my_teams, count: result.data.count, personal: result.data.personal, + competition_name: result.data.competition_name, + members_count: result.data.members_count + }) } @@ -225,6 +276,9 @@ class Registration extends React.Component { count: result.data.count, competition_teams: result.data.competition_teams, personal: result.data.personal, + competition_name: result.data.competition_name, + members_count: result.data.members_count + }) @@ -258,109 +312,120 @@ class Registration extends React.Component { } - Getdatatype5 = (keyword, page, per_page, admin) => { - //搜索关键字 keyword - //页数 page - //分页 per_page - const datas = { - keyword: keyword, - page: page, - per_page: per_page, - }; - let url = `/competitions/${this.props.match.params.identifier}/competition_teams.json`; - axios.get((url), {params: datas}).then((result) => { - this.setState({ - loadingstate: false, - }) - if (result) { - if (result.data) { - //// //////console.log(result); - if (result.data.personal === false) { - //不是个人赛 - ////console.log("Getdatatype5"); - ////console.log(result.data.my_teams.length); - if (result.data.my_teams.length === 0) { - // 没有创建数据的 - //管理员 - ////console.log("a"); - ////console.log(this.state.competition_teams); - ////console.log(result.data.competition_teams); - this.setState({ - type: 4, - count: result.data.count, - competition_teams: result.data.competition_teams, - data: result.data.my_teams, - personal: result.data.personal, - - }) - } else { - //有数据的 - ////console.log("b"); - - if (result.data.my_teams[0].manage_permission === true) { - this.setState({ - type: 5, - data: result.data.my_teams, - count: result.data.count, - competition_teams: result.data.competition_teams, - personal: result.data.personal, - - - }) - } else { - ////console.log("c"); - - this.setState({ - type: 4, - data: result.data.my_teams, - count: result.data.count, - competition_teams: result.data.competition_teams, - personal: result.data.personal, - - }) - } - } - } else { - //团队赛 - //////console.log("d"); - - this.setState({ - type: 6, - data: result.data.my_teams, - count: result.data.count, - competition_teams: result.data.competition_teams, - personal: result.data.personal, - - }) - } - - } - } - - }).catch((error) => { - ////console.log("k"); - - ////console.log(error); - ////console.log("报错了"); - if (admin === true) { - //管理员 - this.setState({ - count: 0, - competition_teams: [], - data: [], - loadingstate: false, - }) - } else { - //普通账号 - this.setState({ - count: 0, - competition_teams: [], - data: [], - loadingstate: false, - }) - } - }) - } + // Getdatatype5 = (keyword, page, per_page, admin) => { + // //搜索关键字 keyword + // //页数 page + // //分页 per_page + // const datas = { + // keyword: keyword, + // page: page, + // per_page: per_page, + // }; + // let url = `/competitions/${this.props.match.params.identifier}/competition_teams.json`; + // axios.get((url), {params: datas}).then((result) => { + // this.setState({ + // loadingstate: false, + // }) + // if (result) { + // if (result.data) { + // //// //////console.log(result); + // if (result.data.personal === false) { + // //不是个人赛 + // ////console.log("Getdatatype5"); + // ////console.log(result.data.my_teams.length); + // if (result.data.my_teams.length === 0) { + // // 没有创建数据的 + // //管理员 + // ////console.log("a"); + // ////console.log(this.state.competition_teams); + // ////console.log(result.data.competition_teams); + // this.setState({ + // type: 4, + // count: result.data.count, + // competition_teams: result.data.competition_teams, + // data: result.data.my_teams, + // personal: result.data.personal, + // competition_name: result.data.competition_name, + // members_count:result.data.members_count + // + // + // }) + // } else { + // //有数据的 + // ////console.log("b"); + // + // if (result.data.my_teams[0].manage_permission === true) { + // this.setState({ + // type: 5, + // data: result.data.my_teams, + // count: result.data.count, + // competition_teams: result.data.competition_teams, + // personal: result.data.personal, + // competition_name: result.data.competition_name, + // members_count:result.data.members_count + // + // + // }) + // } else { + // ////console.log("c"); + // + // this.setState({ + // type: 4, + // data: result.data.my_teams, + // count: result.data.count, + // competition_teams: result.data.competition_teams, + // personal: result.data.personal, + // competition_name: result.data.competition_name, + // members_count:result.data.members_count + // + // + // }) + // } + // } + // } else { + // //团队赛 + // //////console.log("d"); + // + // this.setState({ + // type: 6, + // data: result.data.my_teams, + // count: result.data.count, + // competition_teams: result.data.competition_teams, + // personal: result.data.personal, + // competition_name: result.data.competition_name, + // members_count:result.data.members_count + // + // + // }) + // } + // + // } + // } + // + // }).catch((error) => { + // ////console.log("k"); + // + // ////console.log(error); + // ////console.log("报错了"); + // if (admin === true) { + // //管理员 + // this.setState({ + // count: 0, + // competition_teams: [], + // data: [], + // loadingstate: false, + // }) + // } else { + // //普通账号 + // this.setState({ + // count: 0, + // competition_teams: [], + // data: [], + // loadingstate: false, + // }) + // } + // }) + // } //团队竞赛翻页 @@ -370,7 +435,7 @@ class Registration extends React.Component { loadingstate: true, }) const {keyword, per_page} = this.state; - this.Getdatatype5(keyword, pageNumber, per_page, this.props.user.admin); + this.Getdata(keyword, pageNumber, per_page, this.props.user.admin); }; /** @@ -381,7 +446,7 @@ class Registration extends React.Component { //已经报名 this.setState({ messagePerbool: true, - intpermessages: "您已报名,无需重复报" + intpermessages: "你已经报名,不能重复报名" }) return; } @@ -393,7 +458,7 @@ class Registration extends React.Component { }) return } - if (this.props.user.admin === true) { + if (this.props.user.is_teacher === true) { //老师 if (this.state.teacher_staff === null) { //禁止老师 @@ -447,7 +512,7 @@ class Registration extends React.Component { }) return } - if (this.props.user.admin === true) { + if (this.props.user.is_teacher === true) { //老师 if (this.state.teacher_staff === null) { //禁止老师 @@ -493,7 +558,7 @@ class Registration extends React.Component { }) if (bool) { //确认 - + this.Refreshteam(); } else { //取消 @@ -556,7 +621,7 @@ class Registration extends React.Component { messageexitol: true }) - let url = `/competitions/${"gcc-task-2020"}/competition_teams/${this.state.itemid}/leave.json`; + let url = `/competitions/${this.props.match.params.identifier}/competition_teams/${this.state.itemid}/leave.json`; axios.post(url).then((response) => { if (response) { if (response.data) { @@ -587,7 +652,7 @@ class Registration extends React.Component { pages: 1, limit: 20, }) - this.Getdatatype5(value, 1, 20, this.props.user.admin); + this.Getdata(value, 1, 20, this.props.user.admin); } //个人竞赛 @@ -618,10 +683,10 @@ class Registration extends React.Component { render() { - const {page, pages, limit, type, tmodalsType, tmodalsTypes, data, count, competition_teams, Newtit, itemiddata, messagePerbool, messageexitol, GetenrollmentAPI, loadingstate, pint} = this.state; + const {page, pages, limit, type, tmodalsType, tmodalsTypes, data, count, competition_teams, Newtit, itemiddata, messagePerbool, messageexitol, GetenrollmentAPI, loadingstate, pint, competition_name, mutiple_limited, teamutiple_limited, members_count} = this.state; return ( -
+
+ {item.name === undefined || item.name === null || item.name === "" ? "--" : item.name}

+ >{item.name === undefined || item.name === null || item.name === "" ? "--" : item.name}
{ index === 0 ?

创建者

: -

{item.type === undefined || item.type === null || item.type === "" ? "--" : item.type}

+ >{item.type === undefined || item.type === null || item.type === "" ? "--" : item.type} } -

{item.school_name === undefined || item.school_name === null || item.school_name === "" ? "--" : item.school_name}

-

{item.school_name === undefined || item.school_name === null || item.school_name === "" ? "--" : item.school_name} + {item.identity === undefined || item.identity === null || item.identity === "" ? "--" : item.identity}

+ >{item.identity === undefined || item.identity === null || item.identity === "" ? "--" : item.identity} { index === 0 ? -

: -

); var cpersondiv1Items = []; + // console.log("this.props.teamutiple_limited "); + // console.log(this.props.teamutiple_limited ); if (teacher_ids) { cpersondiv1Items = teacher_ids.map((item, index) => - +

  • this.getdatacpersondiv1Items(item)} + onMouseDown={() => this.getdatacpersondiv1Items(item)} + > -

    {item.name === undefined || item.name === null || item.name === "" ? "--" : item.name}

    -

    {item.identity === undefined || item.identity === null || item.identity === "" ? "--" : item.identity}

    -

    {item.school_name === undefined || item.school_name === null || item.school_name === "" ? "--" : item.school_name}

    -
    + + {item.name === undefined || item.name === null || item.name === "" ? + -- + : + {item.name} + } + {item.identity === undefined || item.identity === null || item.identity === "" ? +

    --

    + : + {item.identity}} + {item.school_name === undefined || item.school_name === null || item.school_name === "" ? + +

    --

    + : + {item.school_name} + } + + { + this.props.teamutiple_limited === undefined || this.props.teamutiple_limited === null ? +

    {""}

    + : + ( + this.props.teamutiple_limited === true ? +

    {item.enrollable === false ? "已加入其他战队" : ""}

    + : +

    {""}

    + ) + + } + + +
  • +
    ); } const cpersondiv1 = (
    -
    +
    { cpersondiv1Items.length === 0 ? @@ -778,48 +1073,115 @@ class PersonModal extends Component { var persondiv2Items = []; if (member_ids) { persondiv2Items = member_ids.map((item, index) => - + + +
  • this.getdatacpersondiv1Items2(item)} + onMouseDown={() => this.getdatacpersondiv1Items2(item)} > -

    {item.name === undefined || item.name === null || item.name === "" ? "--" : item.name}

    -

    {item.identity === undefined || item.identity === null || item.identity === "" ? "--" : item.identity}

    -

    {item.school_name === undefined || item.school_name === null || item.school_name === "" ? "--" : item.school_name}

    -

    {item.enrollable === false ? "" : "已加入其他战队"}

    -
    + + {item.name === undefined || item.name === null || item.name === "" ? + -- + : + {item.name} + } + {item.student_id === undefined || item.student_id === null || item.student_id === "" ? +

    --

    + : + {"学号:" + item.student_id}} + {item.school_name === undefined || item.school_name === null || item.school_name === "" ? + +

    --

    + : + {item.school_name} + } + + { + this.props.mutiple_limited === undefined || this.props.mutiple_limited === null ? +

    {""}

    + : + ( + this.props.mutiple_limited === true ? +

    {item.enrollable === false ? "已加入其他战队" : ""}

    + : +

    {""}

    + ) + + } + + +
  • +
    ); } const persondiv2 = (
    {/*this.state.loading2*/} -
    +
    { persondiv2Items.length === 0 ? @@ -857,16 +1219,16 @@ class PersonModal extends Component { width="620px" > - + {/**/}
    {/*队名*/} - {/* this.onSearch(value)}*/} - {/*/>*/} trigger.parentNode} visible={this.state.person2}> @@ -1021,6 +1379,7 @@ class PersonModal extends Component { placeholder="请输入想要队员姓名的任意关键字进行搜索" onPressEnter={this.startSearch2} onFocus={this.inputOnFocus2} + onBlur={this.inputOnBlur2} onChange={(e) => this.studentsonChange(e)} value={this.state.keywordstudents} suffix={ @@ -1114,8 +1473,21 @@ class PersonModal extends Component { ) : "" } + { + GetenrollmentAPI && GetenrollmentAPI.member_staff ? + ( + Thecurrentnumberboolstu === true ? +

    战队队员为{GetenrollmentAPI.member_staff.minimum}-{GetenrollmentAPI.member_staff.maximum}人,现在为{Thecurrentnumberstu}人

    - + : "" + ) : + "" + }
    { + try { + if (this.state.yslzxueshiskmcdm1) { + if (this.state.yslzxueshiskmcdm1.length === 0) { + this.props.showNotification(`请输入您的邀请码`); + return + } + + } + } catch (e) { + + } + + let url = `/competitions/${this.props.match.params.identifier}/competition_teams/join.json`; axios.post(url, { invite_code: this.state.yslzxueshiskmcdm1 diff --git a/public/react/src/modules/competition/personal/PersonalCompetititem.js b/public/react/src/modules/competition/personal/PersonalCompetititem.js index bd6a092eb..4abbb5348 100644 --- a/public/react/src/modules/competition/personal/PersonalCompetititem.js +++ b/public/react/src/modules/competition/personal/PersonalCompetititem.js @@ -9,13 +9,21 @@ import moment from 'moment'; import {SnackbarHOC, WordsBtn, getImageUrl} from 'educoder'; import {TPMIndexHOC} from '../../tpm/TPMIndexHOC'; import competition from '../comcss/competition.css'; -import {Button, message} from 'antd'; +import {Button, message, Tooltip} from 'antd'; // 点击按钮复制功能 function jsCopy() { var e = document.getElementById("copy_invite_code"); e.select(); document.execCommand("Copy"); codesuccess() + // const range=document.createRange(); + // window.getSelection().removeAllRanges(); + // range.selectNode(e.target); + // window.getSelection().addRange(range); + // const successful =document.execCommand('copy'); + // if(successful){ + // codesuccess() + // } } function codesuccess() { @@ -25,17 +33,13 @@ function codesuccess() { class PersonalCompetititem extends React.Component { constructor(props) { super(props) - this.state = { - data: "" - } + } componentDidMount() { // // ////console.log(this.props.data) - this.setState({ - data: this.props.data, - }) + } @@ -47,7 +51,7 @@ class PersonalCompetititem extends React.Component { } render() { - const {data} = this.props; + const {key, item} = this.props; // ////console.log("PersonalCompetititem"); // ////console.log(data); // ////console.log(data[0]); @@ -60,12 +64,14 @@ class PersonalCompetititem extends React.Component { return (
    { - data && data[0] ?
    -
    +
    - +

    {data[0].creator.name}

    + }}>{item.creator.name}

    -

    {data[0].name}

    + }}>{item.name}

    -
    - { - data && data[0].team_members.map((item, index) => { - return ( + {this.props.type === 5 || this.props.type === 2 ? +
    + { + item && item.team_members.map((item, index) => { + return ( + + index === 0 ? + + + + : index === 1 ? + - index === 0 ? - + + : index === 2 ? + - - : index === 1 ? - + + : index === 3 ? +
    + - - : index === 2 ? - + - - : index === 3 ? + + + +
    + : "" + ) + }) + } + +
    : +
    + { + item && item.team_members.map((item, index) => { + return ( + + index === 0 ? + + + + : index === 1 ? - : index === 4 ? + : index === 2 ? - : index === 5 ? -
    + : index === 3 ? + : index === 4 ? + - + + : index === 5 ? +
    + - -
    - : "" - ) - }) - } + -
    -
    + + +
    + : "" + ) + }) + } + +
    + } +
    -
    +
    邀请码: {data[0].invite_code === null || data[0].invite_code === undefined ? "" : data[0].invite_code} + }}>{item.invite_code === null || item.invite_code === undefined ? "" : item.invite_code}
    + value={item.invite_code === null || item.invite_code === undefined ? "" : item.invite_code}/>
    - {data[0].invite_code === null || data[0].invite_code === undefined ? + {item.invite_code === null || item.invite_code === undefined ? : - { - jsCopy() - }} - > - - + + { + jsCopy() + }} + > + + } { this.props.type === 5 ? -
    -
    this.props.Exittheteamshow(data[0].id, true)}> -

    this.props.Exittheteamshow(data[0].id, true)}>删除战队

    + +
    this.props.Exittheteamshow(item.id, false)}> +

    this.props.Exittheteamshow(item.id, false)}>删除战队

    -
    this.props.Createateamedit(data[0])}> -

    this.props.Createateamedit(data[0])}>编辑战队

    +
    this.props.Createateamedit(item)}> +

    this.props.Createateamedit(item)}>编辑战队

    : this.props.type === 2 ? -
    - -
    this.props.Exittheteamshow(data[0].id, false)}> -

    this.props.Exittheteamshow(data[0].id, false)}>退出战队

    +
    this.props.Exittheteamshow(item.id, false)}> +

    this.props.Exittheteamshow(item.id, false)}>删除战队

    +
    +
    this.props.Createateamedit(item)}> +

    this.props.Createateamedit(item)}>编辑战队

    -
    : this.props.type === 3 ? @@ -220,8 +282,8 @@ class PersonalCompetititem extends React.Component { }} > -
    this.props.Exittheteamshow(data[0].id, false)}> -

    this.props.Exittheteamshow(data[0].id, false)}>退出战队

    +
    this.props.Exittheteamshow(item.id, false)}> +

    this.props.Exittheteamshow(item.id, false)}>退出战队

    diff --git a/public/react/src/modules/competitions/Competitimain/CompetitionsIndex.js b/public/react/src/modules/competitions/Competitimain/CompetitionsIndex.js index 61e6419b7..2009588b4 100644 --- a/public/react/src/modules/competitions/Competitimain/CompetitionsIndex.js +++ b/public/react/src/modules/competitions/Competitimain/CompetitionsIndex.js @@ -1,20 +1,11 @@ import React, { Component } from 'react'; import { Link } from 'react-router-dom'; -import { Menu, Icon, List, Avatar,Row, Col,Tag,Pagination} from 'antd'; +import { Menu, Icon, List, Avatar,Row, Col,Tag,Pagination,Alert} from 'antd'; import {getImageUrl} from 'educoder'; import axios from 'axios'; import './Competitionsindex.css'; import NoneData from "../../courses/coursesPublic/NoneData"; -const { SubMenu } = Menu; - -const IconText = ({ type, text }) => ( - - - {text} - -); - class CompetitionsIndex extends Component{ constructor(props) { super(props) @@ -78,9 +69,8 @@ class CompetitionsIndex extends Component{ } render() { let {datas,page,count}=this.state; - admin: true - business: false - console.log(this.props.current_user&&this.props.current_user.business) + + return (
    @@ -133,7 +123,11 @@ class CompetitionsIndex extends Component{ dataSource={datas&&datas} renderItem={(item,key) => (
    +
    + {item.competition_status==="nearly_published"? + this.props.current_user&&this.props.current_user.admin===true?"":this.props.current_user&&this.props.current_user.business===true?"":
    即将发布 敬请期待
    :""} + {/*
    即将发布 敬请期待
    */} {item.description===null||item.description===undefined||item.description===""?