@ -1,7 +1,12 @@
<% none_edit = @team.try(:id).present? && @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% none_edit = @team.try(:id).present? && @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<%= labelled_form_for @team, :html => {:id => 'competition_team_form', :multipart => true, :remote => true} do |f| %>
<%= labelled_form_for @team, :html => {:id => 'competition_team_form', :multipart => true, :remote => true} do |f| %>
<input type="hidden" id="max_num" value="<%= @competition.max_num %>">
<% teacher_staff = @competition.competition_staffs.where(category: 'teacher').first %>
<input type="hidden" id="min_num" value="<%= @competition.min_num %>">
<% min_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:minimum) %>
<% max_member_staff = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) %>
<input type="hidden" id="teacher_maximum" value="<%= teacher_staff.try(:maximum) || 0 %>">
<input type="hidden" id="teacher_minimum" value="<%= teacher_staff.try(:minimum) || 0 %>">
<input type="hidden" id="member_maximum" value="<%= max_member_staff || 0 %>">
<input type="hidden" id="member_minimum" value="<%= min_member_staff || 0 %>">
<input type="hidden" id="team_id" value="<%= @team.try(:id) %>">
<input type="hidden" id="team_id" value="<%= @team.try(:id) %>">
<input type="hidden" name="com_id" value="<%= @competition.id %>">
<input type="hidden" name="com_id" value="<%= @competition.id %>">
@ -15,6 +20,7 @@
</div>
</div>
<p style="line-height: 27px;height: 27px"><span id="team_name_notice" class="color-orange-tip ml73 none"></span></p>
<p style="line-height: 27px;height: 27px"><span id="team_name_notice" class="color-orange-tip ml73 none"></span></p>
<% if teacher_staff.present? %>
<div class="df pl20 pr20">
<div class="df pl20 pr20">
<label class="ml10 mt3">导师:</label>
<label class="ml10 mt3">导师:</label>
<div class="flex1 pr search-new">
<div class="flex1 pr search-new">
@ -31,6 +37,8 @@
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="add_teacher()">添加导师</a>
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="add_teacher()">添加导师</a>
</div>
</div>
<p style="line-height: 27px;height: 27px"><span id="teacher_notice" class="color-orange-tip ml73 none"></span></p>
<p style="line-height: 27px;height: 27px"><span id="teacher_notice" class="color-orange-tip ml73 none"></span></p>
<% end %>
<% if min_member_staff > 0 %>
<div class="df pl20 pr20">
<div class="df pl20 pr20">
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
<div class="flex1 search-new">
<div class="flex1 search-new">
@ -47,6 +55,7 @@
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="<%= none_edit ? '' : 'add_member()' %>">添加成员</a>
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="<%= none_edit ? '' : 'add_member()' %>">添加成员</a>
</div>
</div>
<p style="line-height: 27px;height: 27px"><span id="member_notice" class="color-orange-tip ml73 none"></span></p>
<p style="line-height: 27px;height: 27px"><span id="member_notice" class="color-orange-tip ml73 none"></span></p>
<% end %>
<div class="bor-grey-e ml20 mr20 mt5" id="member_block">
<div class="bor-grey-e ml20 mr20 mt5" id="member_block">
<p class="pt10 pb10 clearfix bor-bottom-greyE personListLine">
<p class="pt10 pb10 clearfix bor-bottom-greyE personListLine">
@ -57,25 +66,30 @@
<span class="t-c-5">操作</span>
<span class="t-c-5">操作</span>
</p>
</p>
<% if @team.try(:id).present? %>
<% if @team.try(:id).present? %>
<p class="personListLine clearfix pt5 pb5 personListMember" id="create_li">
<% creator_teacher = @team.user.user_extensions.identity == 0 %>
<p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li">
<span class="t-c-1"><%= @team.user.show_name %></span>
<span class="t-c-1"><%= @team.user.show_name %></span>
<span class="t-c-2"><%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-2"><%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-3"><%= @team.user.school_name %></span>
<span class="t-c-3"><%= @team.user.school_name %></span>
<span class="t-c-4"><%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-4"><%= @team.user.user_extensions.identity == 0 ? "职称:#{@team.user.identity}" : "学号:#{@team.user.user_extensions.student_id.present? ? @team.user.user_extensions.student_id : "--"}" %></span>
<span class="t-c-5"></span>
<span class="t-c-5"></span>
</p>
</p>
<% if @team.teacher.present? && @team.teacher != @team.user %>
<p class="personListLine clearfix pt5 pb5 personListMember">
<% @team.teachers.includes(user: :user_extensions).each do |teacher| %>
<input type="hidden" name="teacher" value="<%= @team.teacher_id %>">
<% next if teacher.user_id == @team.user_id %>
<span class="t-c-1"><%= @team.teacher.show_name %></span>
<p class="personListLine clearfix pt5 pb5 personListMember team-teacher team-teacher-<%= teacher.user.id %>">
<input type="hidden" name="teacher_ids[]" value="<%= teacher.user.id %>">
<span class="t-c-1"><%= teacher.user.show_name %></span>
<span class="t-c-2">导师</span>
<span class="t-c-2">导师</span>
<span class="t-c-3"><%= @team.teacher.school_name %></span>
<span class="t-c-3"><%= teacher.us er.school_name %></span>
<span class="t-c-4">职称:<%= @team. teacher.identity %></span>
<span class="t-c-4">职称:<%= teacher.us er.identity %></span>
<span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>
<span class="t-c-5"><span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span></span>
</p>
</p>
<% end %>
<% end %>
<% @team.team_members.where(:role => 2, :is_teacher => 0).each do |team_user| %>
<p class="personListLine clearfix pt3 pb3 personListMember">
<% @team.members.includes(user: :user_extensions).each do |team_user| %>
<% next if team_user.user_id == @team.user_id %>
<p class="personListLine clearfix pt3 pb3 personListMember team-member">
<input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>">
<input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>">
<span class="t-c-1"><%= team_user.user.show_name %></span>
<span class="t-c-1"><%= team_user.user.show_name %></span>
<span class="t-c-2">成员</span>
<span class="t-c-2">成员</span>
@ -89,7 +103,8 @@
</p>
</p>
<% end %>
<% end %>
<% else %>
<% else %>
<p class="personListLine clearfix pt5 pb5 personListMember" id="create_li">
<% creator_teacher = @team_user.user_extensions.identity == 0 %>
<p class="personListLine clearfix pt5 pb5 personListMember <%= creator_teacher ? 'team-teacher' : 'team-member' %>" id="create_li">
<span class="t-c-1"><%= @team_user.show_name %></span>
<span class="t-c-1"><%= @team_user.show_name %></span>
<span class="t-c-2"><%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-2"><%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<span class="t-c-3"><%= @team_user.school_name %></span>
<span class="t-c-3"><%= @team_user.school_name %></span>
@ -112,33 +127,46 @@
function submit_competition_team_form(){
function submit_competition_team_form(){
if($("input[name='name']").val().trim() == ""){
if($("input[name='name']").val().trim() == ""){
$("#team_name_notice").html("请输入战队名").show();
$("#team_name_notice").html("请输入战队名").show();
} else{
return;
var max_num = parseInt($("#max_num").val());
}
var min_num = parseInt($("#min_num").val());
if($("#member_block .personListMember").length > max_num || $("#member_block .personListMember").length < min_num){
var teacherMaximum = parseInt($("#teacher_maximum").val());
$("#competition_team_form_notice").html("战队成员需为"+min_num+"-"+max_num+"人").show();
var teacherMinimum = parseInt($("#teacher_minimum").val());
} else{
var memberMaximum = parseInt($("#member_maximum").val());
var memberMinimum = parseInt($("#member_minimum").val());
var teacherCount = $("#member_block .personListMember.team-teacher").length;
if (teacherMaximum != 0 && teacherCount > teacherMaximum || teacherMinimum != 0 && teacherCount < teacherMinimum) {
$("#competition_team_form_notice").html("战队导师需为"+teacherMinimum+"-"+teacherMaximum+"人,现为" + teacherCount + '人').show();
return;
}
var memberCount = $("#member_block .personListMember.team-member").length;
if (memberMaximum != 0 && memberCount > memberMaximum || memberMinimum != 0 && memberCount < memberMinimum) {
$("#competition_team_form_notice").html("战队成员需为"+memberMinimum+"-"+memberMaximum+"人,现为" + memberCount + '人').show();
return;
}
$("#team_name_notice").hide();
$("#team_name_notice").hide();
$("#competition_team_form_notice").hide();
$("#competition_team_form_notice").hide();
$("#competition_team_form").submit();
$("#competition_team_form").submit();
hideModal();
hideModal();
}
}
}
}
function add_teacher(){
function add_teacher(){
if($("#teacher_search_input").attr("disabled") != "disabled"){
if($("#teacher_search_input").attr("disabled") != "disabled"){
if($("#teacher_name").val() == "" || $("#teacher_name").val() != $("#teacher_search_input").val()){
if($("#teacher_name").val() == "" || $("#teacher_name").val() != $("#teacher_search_input").val()){
$("#teacher_id").attr("data-select", 0);
$("#teacher_id").attr("data-select", 0);
$("#teacher_notice").html("指导老师需从搜索下拉列表中选择").show();
$("#teacher_notice").html("指导老师需从搜索下拉列表中选择").show();
} else{
return;
if($("#teacher_id").attr("data-select") == 1){
}
if($("#teacher_id").attr("data-select") == 1 || $(".team-teacher.team-teacher-" + $("#teacher_id").val()).length != 0){
$("#teacher_notice").html("该老师已添加").show();
$("#teacher_notice").html("该老师已添加").show();
} else{
return;
}
$("#teacher_notice").hide();
$("#teacher_notice").hide();
$("input[name='teacher']").parent().remove();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-teacher team-teacher-' + $("#teacher_id").val() + '">' +
var li = '<p class="personListLine clearfix pt3 pb3 personListMember">' +
' <input type="hidden" name="teacher_ids[]" value="'+$("#teacher_id").val()+'">' +
' <input type="hidden" name="teacher" value="'+$("#teacher_id").val()+'">' +
' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' +
' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' +
' <span class="t-c-2">导师</span>' +
' <span class="t-c-2">导师</span>' +
' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' +
' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' +
@ -149,20 +177,21 @@
$("#teacher_id").attr("data-select", 1);
$("#teacher_id").attr("data-select", 1);
}
}
}
}
}
}
function add_member(){
function add_member(){
$("#member_notice").hide();
$("#member_notice").hide();
if($("#member_name").val() == "" || $("#member_name").val() != $("#user_search_input").val()){
if($("#member_name").val() == "" || $("#member_name").val() != $("#user_search_input").val()){
$("#member_id").attr("data-select", 0);
$("#member_id").attr("data-select", 0);
$("#member_notice").html("队员需从搜索下拉列表中选择").show();
$("#member_notice").html("队员需从搜索下拉列表中选择").show();
} else{
return;
if($("#member_id").attr("data-select") == 1){
}
if($("#member_id").attr("data-select") == 1 || $(".team-member.team-member-" + $("#member_id").val()).length != 0){
$("#member_notice").html("该队员已添加").show();
$("#member_notice").html("该队员已添加").show();
} else{
return;
}
$("#member_notice").hide();
$("#member_notice").hide();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember">' +
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-member team-member-' + $("#member_id").val() + ' ">' +
' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' +
' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' +
' <span class="t-c-1">'+$("#member_name").val()+'</span>' +
' <span class="t-c-1">'+$("#member_name").val()+'</span>' +
' <span class="t-c-2">成员</span>' +
' <span class="t-c-2">成员</span>' +
@ -173,8 +202,6 @@
$("#member_block").append(li);
$("#member_block").append(li);
$("#member_id").attr("data-select", 1);
$("#member_id").attr("data-select", 1);
}
}
}
}
$("#user_search_input").on("keydown", function(event){
$("#user_search_input").on("keydown", function(event){
var code;
var code;