下载.png
- HTML
<div class="operate-btn col-md-8 fl" style="margin-top:0">
<div class="icon-buttons">
<span class="icon-box" data-bind="click:events.downloadFilesFunc">
<i class="iconbtn icon-download"></i>下载</span>
<span class="icon-box" data-bind="click:events.delAttach">
<i class="iconbtn icon-del"></i>删除</span>
</div>
</div>
- JS
downloadFilesFunc : function(){
//获取后台需要的chr_id
var filesData = viewModel.filesDataTable.getSimpleData({
type : 'select'
});
if(filesData == undefined || filesData == null || filesData.length != 1){
ip.ipInfoJump("请分条下载!","info");
return;
}
var fileIdArr =[];
for(var i=0;i<filesData.length;i++){
fileIdArr.push(filesData[i].chrId);
}
//将附件id:chr_id传给后台,下载附件
var form = $("<form id='downloadForm'>");
form.attr('style', 'display:none');
form.attr('target', '');
form.attr('method', 'get');
var url = '/attach/downloadFile.do?attachmentId=' + filesData[0].chrId;
form.attr('action', url);
var input = $('<input>');
input.attr('type', 'hidden');
input.attr('name', 'attachmentId');
input.attr('value', filesData[0].chrId);
$('body').append(form);
form.append(input);
form.submit();
form.remove();
$('#downloadForm').remove();
}
网友评论