战队信息

dev_sync_trustie
cxt 5 years ago
parent 387d0183dd
commit 3fed71a411

@ -5,8 +5,7 @@ $(document).on('turbolinks:load', function(){
autoclose: true,
language: 'zh-CN',
format: 'yyyy-mm-dd',
startDate: '2017-04-01',
endDate: '-1d'
startDate: '2017-04-01'
};
var defineDateRangeSelect = function(element){
@ -19,5 +18,60 @@ $(document).on('turbolinks:load', function(){
};
defineDateRangeSelect('.teaching-mode-date');
}
defineDateRangeSelect('.competition-start-end-date');
var $basic_form = $('form.basic-setting-form');
$basic_form.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
name: "required",
subTitle: "required",
startTime: "required",
endTime: "required",
mode: "required",
identifier: "required"
}
});
// 保存按钮
$basic_form.on('click', ".submit-btn", function(){
$basic_form.find('.submit-btn').attr('disabled', 'disabled');
$basic_form.find('.error').html('');
var valid = $basic_form.valid();
$('input[name="navbar[][name]"]').each(function(_, e){
var $ele = $(e);
if($ele.val() === undefined || $ele.val().length === 0){
$ele.addClass('danger text-danger');
valid = false;
} else {
$ele.removeClass('danger text-danger');
}
});
if(!valid) return;
$.ajax({
method: 'PATCH',
dataType: 'json',
url: $form.attr('action'),
data: new FormData($form[0]),
processData: false,
contentType: false,
success: function(data){
$.notify({ message: '保存成功' });
window.location.reload();
},
error: function(res){
var data = res.responseJSON;
$form.find('.error').html(data.message);
},
complete: function(){
$form.find('.submit-btn').attr('disabled', false);
}
});
});
});

@ -60,7 +60,12 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
def index
@personal = current_competition.personal?
admin_or_business? ? all_competition_teams : user_competition_teams
if admin_or_business?
all_competition_teams
user_competition_teams
else
user_competition_teams
end
end
def create
@ -113,8 +118,8 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
teams = teams.joins(users: { user_extension: :school }).where('schools.name LIKE ?', "%#{keyword}%")
end
@count = teams.count
@teams = paginate(teams.includes(:user, users: { user_extension: :school }))
@all_count = teams.count
@all_teams = paginate(teams.includes(:user, users: { user_extension: :school }))
end
def user_competition_teams

@ -12,6 +12,34 @@
<div class="card-body row">
<%= form_tag(admins_competition_competition_settings_path(unsafe_params), method: :post, class: 'basic-setting-form flex-1', remote: true) do %>
<div class="container competition-mode-container">
<div class="row align-items-center mb-1">
<div class="col-1 text-right">
主标题
</div>
<div class="col-5 text-left">
<%= text_field_tag(:name, @competition.name, autocomplete: 'off', class: 'form-control', placeholder: '竞赛标题') %>
</div>
</div>
<div class="row align-items-center mb-1">
<div class="col-1 text-right">
副标题
</div>
<div class="col-5 text-left">
<%= text_field_tag(:sub_title, @competition.sub_title, autocomplete: 'off', class: 'form-control', placeholder: '竞赛副标题') %>
</div>
</div>
<div class="row align-items-center mb-1">
<div class="col-1 text-right">
起止时间
</div>
<div class="col-5 competition-start-end-date d-flex">
<%= text_field_tag :start_time, @competition.start_time&.strftime('%Y-%m-%d'), autocomplete: 'off', class: 'form-control start-date mx-0 mr-2', placeholder: '竞赛开始时间' %>
<%= text_field_tag :end_time, @competition.end_time&.strftime('%Y-%m-%d'), autocomplete: 'off', class: 'form-control end-date mx-0', placeholder: '竞赛截止时间' %>
</div>
</div>
<div class="row align-items-center mb-1">
<div class="col-1 text-right">
竞赛模式
@ -42,12 +70,12 @@
<label class="form-radio-label mb-0" for="mode_3">教学模式(参赛者报名参赛,统计战队课堂和实训数据)</label>
</div>
<div class="col-6 teaching-mode-date d-flex">
<%= text_field_tag :start_time, @competition.competition_mode_setting&.start_time, autocomplete: 'off', class: 'form-control start-date mx-0 mr-2', placeholder: '统计数据的开始时间' %>
<%= text_field_tag :end_time, @competition.competition_mode_setting&.end_time, autocomplete: 'off', class: 'form-control end-date mx-0', placeholder: '统计数据的结束时间' %>
<%= text_field_tag :teach_start_time, @competition.competition_mode_setting&.start_time, autocomplete: 'off', class: 'form-control start-date mx-0 mr-2', placeholder: '统计数据的开始时间' %>
<%= text_field_tag :teach_end_time, @competition.competition_mode_setting&.end_time, autocomplete: 'off', class: 'form-control end-date mx-0', placeholder: '统计数据的结束时间' %>
</div>
</div>
<div class="row align-items-center mb-1">
<div class="row align-items-center mb-2">
<div class="col-1 text-right">
</div>
<div class="col-5 text-left">
@ -56,7 +84,7 @@
</div>
</div>
<div class="row align-items-center mb-1">
<div class="row align-items-center mb-2">
<div class="col-1 text-right">
URL
</div>
@ -65,7 +93,7 @@
</div>
</div>
<div class="row align-items-center mb-1">
<div class="row align-items-center mb-2">
<div class="col-1 text-right">
主办方
</div>
@ -74,7 +102,7 @@
</div>
</div>
<div class="row align-items-center mb-1">
<div class="row align-items-center mb-2">
<div class="col-1 text-right">
奖金
</div>
@ -86,16 +114,16 @@
</div>
</div>
<div class="row align-items-center mb-1">
<div class="row align-items-center mb-2">
<div class="col-1 text-right">
获奖人
奖项
</div>
<div class="col-5 text-left">
<%= number_field_tag(:bonus, @competition.bonus, autocomplete: 'off', step: 1, min: 0, class: 'form-control', placeholder: '请输入总奖金额') %>
<%= number_field_tag(:awards_count, @competition.awards_count, autocomplete: 'off', step: 1, min: 0, class: 'form-control', placeholder: '请输入奖项数') %>
</div>
</div>
<div class="row des-row align-items-center mb-1">
<div class="row des-row align-items-center mb-2">
<div class="col-1 text-right">
描述
</div>
@ -104,7 +132,9 @@
</div>
</div>
<div class="row des-row align-items-center mb-1">
<div class="error my-2 danger text-danger"></div>
<div class="row des-row align-items-center mb-2">
<div class="col-1 text-right">
</div>
<div class="col-5 text-left">
@ -112,7 +142,6 @@
</div>
</div>
</div>
<% end %>
</div>
</div>

@ -1,13 +1,11 @@
json.count @count
json.count @all_count
json.personal @personal
json.competition_teams do
json.array! @teams.each do |team|
json.array! @all_teams&.each do |team|
json.extract! team, :id, :name, :invite_code
json.team_type team.en_team_type
json.school_name team.user.school_name
json.manage_permission current_user.id == team.user_id
json.creator do
json.partial! 'users/user_simple', user: team.user
json.role team.team_members.find(&:creator?).en_role
@ -25,3 +23,29 @@ json.competition_teams do
end
end
end
json.my_teams @teams.each do |team|
json.extract! team, :id, :name, :invite_code
json.team_type team.en_team_type
json.school_name team.user.school_name
json.manage_permission current_user.id == team.user_id
json.creator do
json.partial! 'users/user_simple', user: team.user
json.role team.team_members.find(&:creator?).en_role
end
json.team_members do
json.array! team.team_members.each do |member|
json.partial! 'users/user_simple', user: member.user
json.user_id member.user_id
json.role member.en_role
json.identity member.user.identity
json.school_name member.user.school_name
json.student_id member.user.student_id
end
end
end

Loading…
Cancel
Save