@ -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,7 +20,8 @@
</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>
<div class="df pl20 pr20">
<% if teacher_staff.present? %>
<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">
<input type="text" class="input-100-35 fl" <%= @team_user.user_extensions.identity == 0 ? "disabled" : "" %> autocomplete="off" placeholder="请您输入老师姓名进行搜索" id="teacher_search_input"
<input type="text" class="input-100-35 fl" <%= @team_user.user_extensions.identity == 0 ? "disabled" : "" %> autocomplete="off" placeholder="请您输入老师姓名进行搜索" id="teacher_search_input"
@ -31,73 +37,82 @@
<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>
<div class="df pl20 pr20">
<% end %>
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
<% if min_member_staff > 0 %>
<div class="flex1 search-new">
<div class="df pl20 pr20">
<input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的成员搜索" id="user_search_input">
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
<span class="search-span" style="background: #fff;"></span>
<div class="flex1 search-new">
<input type="hidden" id="member_id" data-select="0">
<input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的成员搜索" id="user_search_input">
<input type="hidden" id="member_name">
<span class="search-span" style="background: #fff;"></span>
<input type="hidden" id="member_school">
<input type="hidden" id="member_id" data-select="0">
<input type="hidden" id="member_student_id">
<input type="hidden" id="member_name">
<a class="fl searchicon" style="top:0px;" onclick="search_non_member_user()"><i class="iconfont icon-sousuo fl"></i></a>
<input type="hidden" id="member_school">
<ul class="pointerTeacher none" id="pointerStudent">
<input type="hidden" id="member_student_id">
</ul>
<a class="fl searchicon" style="top:0px;" onclick="search_non_member_user()"><i class="iconfont icon-sousuo fl"></i></a>
<ul class="pointerTeacher none" id="pointerStudent">
</ul>
</div>
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="<%= none_edit ? '' : 'add_member()' %>">添加成员</a>
</div>
</div>
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="<%= none_edit ? '' : 'add_member()' %>">添加成员</a>
</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">
<span class="t-c-1">姓名</span>
<span class="t-c-1">姓名</span>
<span class="t-c-2">角色</span>
<span class="t-c-2">角色</span>
<span class="t-c-3">单位</span>
<span class="t-c-3">单位</span>
<span class="t-c-4">其他</span>
<span class="t-c-4">其他</span>
<span class="t-c-5">操作</span>
<span class="t-c-5">操作</span>
</p>
<% if @team.try(:id).present? %>
<% 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-2"><%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></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-5"></span>
</p>
</p>
<% if @team.try(:id).present? %>
<p class="personListLine clearfix pt5 pb5 personListMember" id="create_li">
<% @team.teachers.includes(user: :user_extensions).each do |teacher| %>
<span class="t-c-1"><%= @team.user.show_name %></span>
<% next if teacher.user_id == @team.user_id %>
<span class="t-c-2"><%= @team.user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></span>
<p class="personListLine clearfix pt5 pb5 personListMember team-teacher team-teacher-<%= teacher.user.id %>">
<span class="t-c-3"><%= @team.user.school_name %></span>
<input type="hidden" name="teacher_ids[]" value="<%= teacher.user.id %>">
<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-1"><%= teacher.user.show_name %></span>
<span class="t-c-5"></span>
<span class="t-c-2">导师</span>
<span class="t-c-3"><%= teacher.user.school_name %></span>
<span class="t-c-4">职称:<%= teacher.user.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>
</p>
</p>
<% if @team.teacher.present? && @team.teacher != @team.user %>
<% end %>
<p class="personListLine clearfix pt5 pb5 personListMember">
<input type="hidden" name="teacher" value="<%= @team.teacher_id %>">
<% @team.members.includes(user: :user_extensions).each do |team_user| %>
<span class="t-c-1"><%= @team.teacher.show_name %></span>
<% next if team_user.user_id == @team.user_id %>
<span class="t-c-2">导师</span>
<p class="personListLine clearfix pt3 pb3 personListMember team-member">
<span class="t-c-3"><%= @team.teacher.school_name %></span>
<input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>">
<span class="t-c-4">职称:<%= @team.teacher.identity %></span>
<span class="t-c-1"><%= team_user.user.show_name %></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-2">成员</span>
</p>
<span class="t-c-3"><%= team_user.user.school_name %></span>
<% end %>
<span class="t-c-4">学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %></span>
<% @team.team_members.where(:role => 2, :is_teacher => 0).each do |team_user| %>
<span class="t-c-5">
<p class="personListLine clearfix pt3 pb3 personListMember">
<% unless none_edit %>
<input type="hidden" name="member_ids[]" value="<%= team_user.user_id %>">
<span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span>
<span class="t-c-1"><%= team_user.user.show_name %></span>
<% end %>
<span class="t-c-2">成员</span>
</span>
<span class="t-c-3"><%= team_user.user.school_name %></span>
<span class="t-c-4">学号:<%= team_user.user.user_extensions.student_id.present? ? team_user.user.user_extensions.student_id : "--" %></span>
<span class="t-c-5">
<% unless none_edit %>
<span class="delete_member" data-tip-down="删除"><i class="iconfont icon-guanbi font-14 color-grey-c"></i></span>
<% end %>
</span>
</p>
<% end %>
<% else %>
<p class="personListLine clearfix pt5 pb5 personListMember" id="create_li">
<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-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-5"></span>
</p>
</p>
<% end %>
<% end %>
</div>
<% else %>
<% 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-2"><%= @team_user.user_extensions.identity == 0 ? "导师/创建者" : "创建者" %></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-5"></span>
</p>
<% end %>
</div>
<p class="color-orange none ml20" id="competition_team_form_notice"></p>
<p class="color-orange none ml20" id="competition_team_form_notice"></p>
<div class="clearfix edu-txt-center mt20">
<div class="clearfix edu-txt-center mt20">
@ -111,69 +126,81 @@
<script>
<script>
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());
$("#team_name_notice").hide();
var memberMinimum = parseInt($("#member_minimum").val());
$("#competition_team_form_notice").hide();
$("#competition_team_form").submit();
var teacherCount = $("#member_block .personListMember.team-teacher").length;
hideModal();
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();
$("#competition_team_form_notice").hide();
$("#competition_team_form").submit();
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){
}
$("#teacher_notice").html("该老师已添加").show();
if($("#teacher_id").attr("data-select") == 1 || $(".team-teacher.team-teacher-" + $("#teacher_id").val()).length != 0){
} else{
$("#teacher_notice").html("该老师已添加").show();
$("#teacher_notice").hide();
return;
$("input[name='teacher']").parent().remove();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember">' +
' <input type="hidden" name="teacher" value="'+$("#teacher_id").val()+'">' +
' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' +
' <span class="t-c-2">导师</span>' +
' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' +
' <span class="t-c-4">职称:'+$("#teacher_title").val()+'</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>';
$(li).insertAfter($("#create_li"));
$("#teacher_id").attr("data-select", 1);
}
}
}
}
$("#teacher_notice").hide();
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-teacher team-teacher-' + $("#teacher_id").val() + '">' +
' <input type="hidden" name="teacher_ids[]" value="'+$("#teacher_id").val()+'">' +
' <span class="t-c-1">'+$("#teacher_name").val()+'</span>' +
' <span class="t-c-2">导师</span>' +
' <span class="t-c-3">'+$("#teacher_school").val()+'</span>' +
' <span class="t-c-4">职称:'+$("#teacher_title").val()+'</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>';
$(li).insertAfter($("#create_li"));
$("#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){
}
$("#member_notice").html("该队员已添加").show();
if($("#member_id").attr("data-select") == 1 || $(".team-member.team-member-" + $("#member_id").val()).length != 0){
} else{
$("#member_notice").html("该队员已添加").show();
$("#member_notice").hide();
return;
var li = '<p class="personListLine clearfix pt3 pb3 personListMember">' +
}
' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' +
' <span class="t-c-1">'+$("#member_name").val()+'</span>' +
$("#member_notice").hide();
' <span class="t-c-2">成员</span>' +
var li = '<p class="personListLine clearfix pt3 pb3 personListMember team-member team-member-' + $("#member_id").val() + '">' +
' <span class="t-c-3">'+$("#member_school").val()+'</span>' +
' <input type="hidden" name="member_ids[]" value="'+$("#member_id").val()+'">' +
' <span class="t-c-4">学号:'+$("#member_student_id").val()+'</span>' +
' <span class="t-c-1">'+$("#member_name").val()+'</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-2">成员</span>' +
' </p>';
' <span class="t-c-3">'+$("#member_school").val()+'</span>' +
$("#member_block").append(li);
' <span class="t-c-4">学号:'+$("#member_student_id").val()+'</span>' +
$("#member_id").attr("data-select", 1);
' <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>';
}
$("#member_block").append(li);
$("#member_id").attr("data-select", 1);
}
}
$("#user_search_input").on("keydown", function(event){
$("#user_search_input").on("keydown", function(event){