- 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();
}