diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 0309e2d72..42d85d480 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -42,7 +42,7 @@ <%= link_to "附件", "javascript:void(0)", class: "down_btn fr", :onclick => "alert('没有学生提交作业,无法下载附件')" %> <% else%> <%= link_to "附件", zipdown_assort_path(obj_class: @homework.class, obj_id: @homework, format: :json), - remote: true, class: "down_btn fr" %> + remote: true, class: "down_btn fr", :id => "download_homework_attachments" %> <% end%> 列表 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 828be910d..d9100b0bb 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -897,8 +897,31 @@ $(function(){ } } + }); + $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { + if(status == 'success'){ + var res = JSON.parse(data.responseText); + if(res.length<1){ + return; + } + if(res.length==1){ + location.href = '/zipdown/download?file='+res[0].file;return; + } + document.getElementById('light').style.display='block'; + $container = $('#light .upload_box_ul'); + $container.empty(); + for(var i = 0; i 1){ + des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; + } else { + des = '第'+res[i].index+'个学生的作品下载'; + } + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); - }) + } + } + }); });