You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
58 lines
1.6 KiB
$(document).on('turbolinks:load', function() {
|
|
if ($('body.admins-courses-index-page').length > 0) {
|
|
let searchContainer = $(".course-list-form");
|
|
let searchForm = $("form.search-form",searchContainer);
|
|
|
|
searchContainer.on('change', '.course-homepage-show', function(){
|
|
searchForm.find('input[type="submit"]').trigger('click');
|
|
});
|
|
|
|
//导出
|
|
searchContainer.on('click', "#course-export", function () {
|
|
window.location.href = "/admins/courses.xlsx?" + searchForm.serialize();
|
|
});
|
|
|
|
$(".course-list-container").on("change", '.course-setting-form', function () {
|
|
var s_id = $(this).attr("data-id");
|
|
var s_value = $(this).val();
|
|
var s_name = $(this).attr("name");
|
|
var json = {};
|
|
json[s_name] = s_value;
|
|
$.ajax({
|
|
url: "/admins/courses/" + s_id,
|
|
type: "PUT",
|
|
dataType:'script',
|
|
data: json
|
|
});
|
|
});
|
|
|
|
// ************** 学校选择 *************
|
|
searchForm.find('.school-select').select2({
|
|
theme: 'bootstrap4',
|
|
placeholder: '请选择单位',
|
|
minimumInputLength: 1,
|
|
ajax: {
|
|
delay: 500,
|
|
url: '/api/schools/search.json',
|
|
dataType: 'json',
|
|
data: function (params) {
|
|
return {keyword: params.term};
|
|
},
|
|
processResults: function (data) {
|
|
return {results: data.schools}
|
|
}
|
|
},
|
|
templateResult: function (item) {
|
|
if (!item.id || item.id === '') return item.text;
|
|
return item.name;
|
|
},
|
|
templateSelection: function (item) {
|
|
if (item.id) {
|
|
}
|
|
return item.name || item.text;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|