angular post 带参数 导出excel


原文地址:http://www.cnblogs.com/xujanus/p/5985644.html

html

 <button class="btn btn-info" ng-click="getDownloadLink()">导出查询结果</button>

js

// 导出查询结果
$scope.getDownloadLink = function () {
    var url = $rootScope.interfaceCtx + '/salesorder/exportOrderList.do';
    var params = {
        bizType:$scope.selectOrderType,
        bizNo:$scope.selectOrderTypeRefCode,
        channelId:$scope.channelId,
        prodId:$scope.prodId,
        orgId:$scope.orgId,
        userId:$scope.buyerAccountId,
        dateType:$scope.selectTimeType,
        dateStart:$scope.effStartDate,
        dateEnd:$scope.effEndDate,
        orderStatus:$scope.selectInsureState,
        promoter:$scope.promoterAccountId,
        holderId:$scope.policyHolderId,
        insuredId:$scope.insuredPersonId,
    };
    $http.post(url,params,{responseType: 'arraybuffer'}).success(function (res) {
     //begin
var blob = new Blob([res], {type: "application/vnd.ms-excel"}); var objectUrl = URL.createObjectURL(blob); var aForExcel = $("<a><span class='forExcel'>下载excel</span></a>").attr("href",objectUrl); $("body").append(aForExcel); $(".forExcel").click(); aForExcel.remove();
     //end }).error(function (res) {$scope.toastError(res);}); };

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM