You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/views/competitions/enroll.html.erb

189 lines
11 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<div class="enroll-b">
<div class="enroll-t" style="background:url('/images/educoder/competition/anon.png') no-repeat top center;">
<div class="educontent edu-txt-center">
<p class="main_title"><%= @competition.name %></p>
<% if @maximum_staff > 1 %>
<p class="sub_title"><%= @competition.sub_title %></p>
<p class="edu-txt-right inline mt20">
<% unless User.current.logged? %>
<%= link_to "创建战队", signin_path, :remote => true, :class => "enroll-in-b enroll-in-b-green fr" %>
<% else %>
<% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if !@can_enroll %>
<a onclick="notice_box('您已经加入了战队,不能再创建')" class="enroll-in-b enroll-in-b-green fr">创建战队</a>
<% else %>
<a href="<%= new_competition_team_path(:com_id => @competition.id) %>" data-remote="true" class="enroll-in-b enroll-in-b-green fr">创建战队</a>
<% end %>
<% else %>
<a onclick="notice_box('报名已截止')" class="enroll-in-b enroll-in-b-green fr">创建战队</a>
<% end %>
<% end %>
<% unless User.current.logged? %>
<%= link_to "加入战队", signin_path, :remote => true, :class => "enroll-in-b fr" %>
<% else %>
<% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if !@can_enroll %>
<a onclick="notice_box('您已经加入了战队,不能重复加入')" class="enroll-in-b fr">加入战队</a>
<% else %>
<a class="enroll-in-b fr" onclick="joinTeam();">加入战队</a>
<% end %>
<% else %>
<a onclick="notice_box('报名已截止')" class="enroll-in-b enroll-in-b-green fr">加入战队</a>
<% end %>
<% end %>
</p>
<% else %>
<!--个人报名-->
<% unless User.current.logged? %>
<p class="edu-txt-right inline mt20"><%= link_to "立即报名", signin_path, :remote => true, :class => "enroll-in-b fr" %></p>
<% else %>
<p class="edu-txt-right inline mt20">
<% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if !@can_enroll %>
<a href="javascript:void(0)" onclick="notice_box('您已报名')" class="enroll-in-b enroll-in-b-green fr">立即报名</a>
<% else %>
<%= link_to "立即报名", personal_enroll_competition_teams_path(:com_id => @competition.id), :remote => true, :class => "enroll-in-b enroll-in-b-green fr" %>
<% end %>
<% else %>
<a onclick="notice_box('报名已截止')" class="enroll-in-b enroll-in-b-green fr">立即报名</a>
<% end %>
</p>
<% end %>
<% end %>
</div>
</div>
<% if @show_notice %>
<p class="mt30 color-orange-tip font-16 edu-txt-center">您还未指定指导老师,将造成成绩无效</p>
<% end %>
<div>
<div class="educontent" style="width: 934px;">
<% if @is_enroll.present? %>
<div class="pb30">
<% if @maximum_staff > 1 %>
<!--战队报名显示-->
<div class="clearfix mt30 pr88">
<% @is_enroll.each do |team| %>
<li class="clearfix joinTeamInfo">
<span class="fl mr20 ml20">
<%= link_to image_tag(url_to_avatar(team.user), :width => "48", :height => "48", :class => "radius fl mr10"), user_path(team.user), :title => team.user.show_name, :target => "_blank", :alt => "用户头像" %>
<span class="fl task-hide mt12 font-16" style="width: 140px;"><span data-tip-down="<%= team.name %>"><%= team.name %></span></span>
</span>
<span class="fl mr20 edu-txt-left mt14" style="width: 280px">
<span class="inline">
<% if team.teacher_id.present? %>
<a href="<%= user_path(team.teacher) %>" class="fl" target="_blank" data-tip-down="指导老师:<%= team.teacher.show_name %>"><%= image_tag(url_to_avatar(team.teacher), :width => "26", :height => "26", :class => "radius fl mr4") %></a>
<% end %>
<% team.team_members.where("user_id != #{team.teacher_id.present? ? team.teacher_id : '-1'}")[0, 9].each do |member| %>
<%= link_to image_tag(url_to_avatar(member.user), :width => "20", :height => "20", :class => "radius fl mr5 mt3"), user_path(member.user), :title => member.user.show_name, :target => "_blank", :class => "fl", :alt => "用户头像" %>
<% end %>
<% if team.team_members.size > 9 %>
<label class="mt5 team-p-s mt3">...</label>
<% end %>
</span>
</span>
<span class="fl mr10 mt13 font-16">邀请码:<label class="color-orange"><%= team.invite_code %></label></span>
<% if @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if User.current.admin? || User.current == team.user %>
<a href="<%= edit_competition_team_path(team) %>" data-remote="true" class="fl mt13 mr10" data-tip-down="编辑"><i class="iconfont icon-bianjidaibeijing color-blue fl"></i></a>
<% end %>
<% else %>
<% if User.current.admin? || User.current == team.user %>
<a href="<%= edit_competition_team_path(team) %>" data-remote="true" class="fl mt13 mr10" data-tip-down="编辑"><i class="iconfont icon-bianjidaibeijing color-blue fl"></i></a>
<a href="javascript:void(0)" class="font-16 color-grey-c fl mt12" onclick="delete_confirm_box('<%= exit_team_competition_team_path(team) %>', '是否确认删除战队')" data-tip-down="删除"><i class="iconfont icon-shanchu color-grey-c font-15"></i></a>
<% else %>
<a href="javascript:void(0)" class="font-16 color-grey-c fl mt12" onclick="delete_confirm_box('<%= exit_team_competition_team_path(team) %>', '是否确认退出战队')">退出</a>
<% end %>
<% end %>
<%= link_to '进入大赛', competition_path(@competition), class: 'enrollOperation' %>
<% if @competition.identifier == 'gcc-course-2019' %>
<%= link_to '战队详情', competition_team_path(id: team.id), class: 'enrollOperation' %>
<% end %>
</li>
<% end %>
</div>
<% else %>
<!--个人报名显示-->
<div class="clearfix enroll-info mt30">
<span class="mr60 fl">已报名</span>
<span class="mr40 fl task-hide edu-txt-center" data-tip-down="<%= User.current.show_name %>" style="width: 100px;"><%= User.current.show_name %></span>
<span class="color-grey-6 fr task-hide edu-txt-center" data-tip-down="<%= User.current.school_name %>" style="width: 200px;"><%= User.current.school_name %></span>
</div>
<% end %>
</div>
<% elsif !User.current.admin? %>
<div class="edu-txt-center">
<p class="font-30 color-green mb30">您还未参与报名哦,赶紧来挑战吧~</p>
<img src="/images/educoder/competition/noTeam.png"/>
</div>
<% end %>
<% if User.current.admin?%>
<div class="mt20">
<input class="fl ml20 mb5" style="padding: 5px; width: 200px; line-height: 20px;" maxlength="10" placeholder="输入学校名称进行搜索" type="text" id="school_name">
<a href="javascript:void(0);" class="fl task-btn task-btn-orange ml5 mb5" onclick="search_enroll_team();">搜索</a>
<span class="fl mb5 ml10 pr5 none">战队数:<span id="search_teams_count" class="color-orange"></span>个</span>
<span class="fl mb5 ml10 pr5 none">成员数:<span id="team_members_count" class="color-orange"></span>个</span>
<span class="fr mb5 pr5"><%= @maximum_staff > 1 ? "战队总数" : "报名人数" %><span class="color-orange"><%= @team_count %></span>个</span>
<div class="cl"></div>
<% if @teams.present? %>
<%= render :partial => "competitions/team_list" %>
<% else %>
<div class="edu-txt-center">
<p class="font-30 color-green mb30">还没有人报名~</p>
<img src="/images/educoder/competition/noTeam.png"/>
</div>
<% end %>
</div>
<% end %>
</div>
</div>
</div>
<script>
/*加入战队弹框以及点击加入的事件*/
function joinTeam() {
var str = "<div class='df pl20 pr20 mt10'><span class='fl mt5'>邀请码:</span><input type='text' id='codeinput' class='input-flex-40 greyInput' placeholder='请输入您的邀请码'/></div><div class='mb20'><span class='mt3 color-red none' id='codeInput-notice' style='margin-left: 76px;'>战队成员已满,无法加入</span></div>";
var htmlvalue = '<div class="task-popup" style="width:500px;"><div class="task-popup-title clearfix">加入战队</div>' +
'<div class="task-popup-content">' + str + '</div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>' +
'<a href="javascript:void(0)" class="task-btn task-btn-orange fr" onclick="joinSure();">加入</a></div></div>';
pop_box_new(htmlvalue, 500, 205);
}
function joinSure() {
if ($("#codeinput").val().trim() == "") {
$("#codeInput-notice").html("请输入邀请码");
$("#codeInput-notice").removeClass("none");
} else {
$.post(
'<%= join_team_competition_teams_path(:com_id => @competition.id) %>',
{"code": $("#codeinput").val().trim()}
);
hideModal();
}
}
$("#school_name").on("keydown", function(event){
var code;
if (!event) {
event = window.event; //针对ie浏览器
code = event.keyCode;
}
else {
code = event.keyCode;
}
if(code == 13) {
search_enroll_team();
return false;
}
});
function search_enroll_team(){
$.get(
'<%= enroll_competition_path(@competition) %>',
{schoolname: $("#school_name").val().trim()});
}
</script>