$(document).on('turbolinks:load', function() { var $modal = $('.modal.admin-import-course-member-modal'); if ($modal.length > 0) { var $form = $modal.find('form.admin-import-course-member-form'); var resetFileInputFunc = function(file){ file.after(file.clone().val("")); file.remove(); } $modal.on('show.bs.modal', function(){ $modal.find('.file-names').html('选择文件'); $modal.find('.upload-file-input').trigger('click'); }); $modal.on('hide.bs.modal', function(){ resetFileInputFunc($modal.find('.upload-file-input')); }); $modal.on('change', '.upload-file-input', function(e){ var file = $(this)[0].files[0]; $modal.find('.file-names').html(file ? file.name : '请选择文件'); }) var importFormValid = function(){ if($form.find('input[name="file"]').val() == undefined || $form.find('input[name="file"]').val().length == 0){ $form.find('.error').html('请选择文件'); return false; } return true; }; var buildResultMessage = function(data){ var messageHtml = "
数据 | 失败原因 |
---|---|
' + item.data + ' | ' + item.message + ' |