|
|
|
@ -1,7 +1,12 @@
|
|
|
|
|
<% 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| %>
|
|
|
|
|
<input type="hidden" id="max_num" value="<%= @competition.max_num %>">
|
|
|
|
|
<input type="hidden" id="min_num" value="<%= @competition.min_num %>">
|
|
|
|
|
<% teacher_staff = @competition.competition_staffs.where(category: 'teacher').first %>
|
|
|
|
|
<% 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" name="com_id" value="<%= @competition.id %>">
|
|
|
|
|
|
|
|
|
@ -15,7 +20,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
<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>
|
|
|
|
|
<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"
|
|
|
|
@ -31,73 +37,82 @@
|
|
|
|
|
<a class="fl ml20 white-btn edu-blueback-btn mt4" onclick="add_teacher()">添加导师</a>
|
|
|
|
|
</div>
|
|
|
|
|
<p style="line-height: 27px;height: 27px"><span id="teacher_notice" class="color-orange-tip ml73 none"></span></p>
|
|
|
|
|
<div class="df pl20 pr20">
|
|
|
|
|
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
|
|
|
|
|
<div class="flex1 search-new">
|
|
|
|
|
<input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的成员搜索" id="user_search_input">
|
|
|
|
|
<span class="search-span" style="background: #fff;"></span>
|
|
|
|
|
<input type="hidden" id="member_id" data-select="0">
|
|
|
|
|
<input type="hidden" id="member_name">
|
|
|
|
|
<input type="hidden" id="member_school">
|
|
|
|
|
<input type="hidden" id="member_student_id">
|
|
|
|
|
<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>
|
|
|
|
|
<% end %>
|
|
|
|
|
<% if min_member_staff > 0 %>
|
|
|
|
|
<div class="df pl20 pr20">
|
|
|
|
|
<label class="mt3"><span class="mr3 color-orange">*</span>队员:</label>
|
|
|
|
|
<div class="flex1 search-new">
|
|
|
|
|
<input type="text" class="search-new-input fl" <%= none_edit ? "disabled" : "" %> autocomplete="off" style="width: 100%" placeholder="请您输入想要添加的成员搜索" id="user_search_input">
|
|
|
|
|
<span class="search-span" style="background: #fff;"></span>
|
|
|
|
|
<input type="hidden" id="member_id" data-select="0">
|
|
|
|
|
<input type="hidden" id="member_name">
|
|
|
|
|
<input type="hidden" id="member_school">
|
|
|
|
|
<input type="hidden" id="member_student_id">
|
|
|
|
|
<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>
|
|
|
|
|
<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>
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
<div class="bor-grey-e ml20 mr20 mt5" id="member_block">
|
|
|
|
|
<p class="pt10 pb10 clearfix bor-bottom-greyE personListLine">
|
|
|
|
|
<span class="t-c-1">姓名</span>
|
|
|
|
|
<span class="t-c-2">角色</span>
|
|
|
|
|
<span class="t-c-3">单位</span>
|
|
|
|
|
<span class="t-c-4">其他</span>
|
|
|
|
|
<span class="t-c-5">操作</span>
|
|
|
|
|
<div class="bor-grey-e ml20 mr20 mt5" id="member_block">
|
|
|
|
|
<p class="pt10 pb10 clearfix bor-bottom-greyE personListLine">
|
|
|
|
|
<span class="t-c-1">姓名</span>
|
|
|
|
|
<span class="t-c-2">角色</span>
|
|
|
|
|
<span class="t-c-3">单位</span>
|
|
|
|
|
<span class="t-c-4">其他</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>
|
|
|
|
|
<% if @team.try(:id).present? %>
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
<% @team.teachers.includes(user: :user_extensions).each do |teacher| %>
|
|
|
|
|
<% next if teacher.user_id == @team.user_id %>
|
|
|
|
|
<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-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>
|
|
|
|
|
<% if @team.teacher.present? && @team.teacher != @team.user %>
|
|
|
|
|
<p class="personListLine clearfix pt5 pb5 personListMember">
|
|
|
|
|
<input type="hidden" name="teacher" value="<%= @team.teacher_id %>">
|
|
|
|
|
<span class="t-c-1"><%= @team.teacher.show_name %></span>
|
|
|
|
|
<span class="t-c-2">导师</span>
|
|
|
|
|
<span class="t-c-3"><%= @team.teacher.school_name %></span>
|
|
|
|
|
<span class="t-c-4">职称:<%= @team.teacher.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>
|
|
|
|
|
<% end %>
|
|
|
|
|
<% @team.team_members.where(:role => 2, :is_teacher => 0).each do |team_user| %>
|
|
|
|
|
<p class="personListLine clearfix pt3 pb3 personListMember">
|
|
|
|
|
<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-2">成员</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>
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
<% @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 %>">
|
|
|
|
|
<span class="t-c-1"><%= team_user.user.show_name %></span>
|
|
|
|
|
<span class="t-c-2">成员</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 %>
|
|
|
|
|
</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>
|
|
|
|
|
<div class="clearfix edu-txt-center mt20">
|
|
|
|
@ -111,69 +126,81 @@
|
|
|
|
|
<script>
|
|
|
|
|
function submit_competition_team_form(){
|
|
|
|
|
if($("input[name='name']").val().trim() == ""){
|
|
|
|
|
$("#team_name_notice").html("请输入战队名").show();
|
|
|
|
|
} else{
|
|
|
|
|
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){
|
|
|
|
|
$("#competition_team_form_notice").html("战队成员需为"+min_num+"-"+max_num+"人").show();
|
|
|
|
|
} else{
|
|
|
|
|
$("#team_name_notice").hide();
|
|
|
|
|
$("#competition_team_form_notice").hide();
|
|
|
|
|
$("#competition_team_form").submit();
|
|
|
|
|
hideModal();
|
|
|
|
|
}
|
|
|
|
|
$("#team_name_notice").html("请输入战队名").show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var teacherMaximum = parseInt($("#teacher_maximum").val());
|
|
|
|
|
var teacherMinimum = parseInt($("#teacher_minimum").val());
|
|
|
|
|
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();
|
|
|
|
|
$("#competition_team_form_notice").hide();
|
|
|
|
|
$("#competition_team_form").submit();
|
|
|
|
|
hideModal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add_teacher(){
|
|
|
|
|
if($("#teacher_search_input").attr("disabled") != "disabled"){
|
|
|
|
|
if($("#teacher_name").val() == "" || $("#teacher_name").val() != $("#teacher_search_input").val()){
|
|
|
|
|
$("#teacher_id").attr("data-select", 0);
|
|
|
|
|
$("#teacher_notice").html("指导老师需从搜索下拉列表中选择").show();
|
|
|
|
|
} else{
|
|
|
|
|
if($("#teacher_id").attr("data-select") == 1){
|
|
|
|
|
$("#teacher_notice").html("该老师已添加").show();
|
|
|
|
|
} else{
|
|
|
|
|
$("#teacher_notice").hide();
|
|
|
|
|
$("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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if($("#teacher_search_input").attr("disabled") != "disabled"){
|
|
|
|
|
if($("#teacher_name").val() == "" || $("#teacher_name").val() != $("#teacher_search_input").val()){
|
|
|
|
|
$("#teacher_id").attr("data-select", 0);
|
|
|
|
|
$("#teacher_notice").html("指导老师需从搜索下拉列表中选择").show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if($("#teacher_id").attr("data-select") == 1 || $(".team-teacher.team-teacher-" + $("#teacher_id").val()).length != 0){
|
|
|
|
|
$("#teacher_notice").html("该老师已添加").show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$("#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(){
|
|
|
|
|
$("#member_notice").hide();
|
|
|
|
|
if($("#member_name").val() == "" || $("#member_name").val() != $("#user_search_input").val()){
|
|
|
|
|
$("#member_id").attr("data-select", 0);
|
|
|
|
|
$("#member_notice").html("队员需从搜索下拉列表中选择").show();
|
|
|
|
|
} else{
|
|
|
|
|
if($("#member_id").attr("data-select") == 1){
|
|
|
|
|
$("#member_notice").html("该队员已添加").show();
|
|
|
|
|
} else{
|
|
|
|
|
$("#member_notice").hide();
|
|
|
|
|
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>' +
|
|
|
|
|
' <span class="t-c-2">成员</span>' +
|
|
|
|
|
' <span class="t-c-3">'+$("#member_school").val()+'</span>' +
|
|
|
|
|
' <span class="t-c-4">学号:'+$("#member_student_id").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>';
|
|
|
|
|
$("#member_block").append(li);
|
|
|
|
|
$("#member_id").attr("data-select", 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$("#member_notice").hide();
|
|
|
|
|
if($("#member_name").val() == "" || $("#member_name").val() != $("#user_search_input").val()){
|
|
|
|
|
$("#member_id").attr("data-select", 0);
|
|
|
|
|
$("#member_notice").html("队员需从搜索下拉列表中选择").show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if($("#member_id").attr("data-select") == 1 || $(".team-member.team-member-" + $("#member_id").val()).length != 0){
|
|
|
|
|
$("#member_notice").html("该队员已添加").show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#member_notice").hide();
|
|
|
|
|
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()+'">' +
|
|
|
|
|
' <span class="t-c-1">'+$("#member_name").val()+'</span>' +
|
|
|
|
|
' <span class="t-c-2">成员</span>' +
|
|
|
|
|
' <span class="t-c-3">'+$("#member_school").val()+'</span>' +
|
|
|
|
|
' <span class="t-c-4">学号:'+$("#member_student_id").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>';
|
|
|
|
|
$("#member_block").append(li);
|
|
|
|
|
$("#member_id").attr("data-select", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#user_search_input").on("keydown", function(event){
|
|
|
|
|