|
|
|
@ -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){
|
|
|
|
|