美文网首页
附件下载

附件下载

作者: 张小小小七 | 来源:发表于2018-06-04 11:47 被阅读20次
    下载.png
    1. 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>
    
    1. 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();        
    }
    

    相关文章

      网友评论

          本文标题:附件下载

          本文链接:https://www.haomeiwen.com/subject/jimesftx.html