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