竞赛调整

dev_sync_trustie
cxt 5 years ago
parent c2476f2d40
commit 827a127796

@ -20,9 +20,9 @@ $(document).on('turbolinks:load', function(){
defineDateRangeSelect('.teaching-mode-date');
defineDateRangeSelect('.competition-start-end-date');
var $basic_form = $('form.basic-setting-form');
var $basicForm = $('form.basic-setting-form');
$basic_form.validate({
$basicForm.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
@ -36,29 +36,43 @@ $(document).on('turbolinks:load', function(){
});
// 保存按钮
$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();
$basicForm.on('click', ".submit-btn", function(){
$basicForm.find('.submit-btn').attr('disabled', 'disabled');
$basicForm.find('.error').html('');
var valid = $basicForm.valid();
if($("input[name='mode'[checked]]").val() == 2) {
var $courseId = $("input[name='course_id'");
if($courseId.val() === undefined || $course_id.val().length === 0){
$courseId.addClass('danger text-danger');
valid = false;
} else {
$courseId.removeClass('danger text-danger');
}
} else if ($("input[name='mode'[checked]]").val() == 4) {
var $techStartTime = $("input[name='teach_start_time'");
var $techEndTime = $("input[name='teach_end_time'");
if($techStartTime.val() === undefined || $techStartTime.val().length === 0){
$techStartTime.addClass('danger text-danger');
valid = false;
} else {
$techStartTime.removeClass('danger text-danger');
}
$('input[name="navbar[][name]"]').each(function(_, e){
var $ele = $(e);
if($ele.val() === undefined || $ele.val().length === 0){
$ele.addClass('danger text-danger');
if($techEndTime.val() === undefined || $techEndTime.val().length === 0){
$techEndTime.addClass('danger text-danger');
valid = false;
} else {
$ele.removeClass('danger text-danger');
$techEndTime.removeClass('danger text-danger');
}
});
}
if(!valid) return;
$.ajax({
method: 'PATCH',
method: 'POST',
dataType: 'json',
url: $form.attr('action'),
data: new FormData($form[0]),
url: $basicForm.attr('action'),
data: new FormData($basicForm[0]),
processData: false,
contentType: false,
success: function(data){

@ -10,7 +10,7 @@
<span class="flex-1">基础设置</span>
</div>
<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 %>
<%= simple_form_for(@competition, url: a_path(@laboratory), method: 'patch', html: { enctype: 'multipart/form-data' }) do |f| %>
<div class="container competition-mode-container">
<div class="row align-items-center mb-1">
<div class="col-1 text-right">

@ -5,6 +5,7 @@ json.competition_teams do
json.extract! team, :id, :name, :invite_code
json.team_type team.en_team_type
json.school_name team.user.school_name
json.created_at team.created_at.strftime("%Y-%m-%d %H:%M")
json.creator do
json.partial! 'users/user_simple', user: team.user

Loading…
Cancel
Save