function capitalEstimateExport(){
$.post(BASE_PATH+'report/preFeeList', {houseStatus:$('#houseStatus').val(), houseName:$('#houseName').val(),timeFromStr:$('#timeFromStr').val(),timeToStr:$('#timeToStr').val()}, function(data){
if(data.records.length > 0){
debugger
var dlist = data.records;
var obj = {title:"", titleForKey:"", data:""};
obj.title = ["房源编号","房源名字","房源小区","房源地址(路、弄、号、室)","预计付款","实际付款","是否需交租","预计收租","实际收租","是否需收租"];
obj.titleForKey = ["houseNo","houseName","houseEstate","houseAddress","willPay","actPay","payIsOverdue","willRent","actRent","rentIsOverdue"];
obj.data = dlist;
exportCsv(obj);
} else{
alert("没有数据,无法导出!");
}
});
}
function exportCsv(obj){
var title = obj.title;
var titleForKey = obj.titleForKey;
var data = obj.data;
var str = [];
str.push(obj.title.join(",")+"\n");
for(var i=0;i<data.length;i++){
var temp = [];
for(var j=0;j<titleForKey.length;j++){
temp.push(data[i][titleForKey[j]]);
}
str.push(temp.join(",")+"\n");
}
var uri = 'data:text/csv;charset=utf-8,\uFEFF' + encodeURIComponent(str.join(""));
var downloadLink = document.createElement("a");
downloadLink.href = uri;
downloadLink.download = "资金预估报表.csv";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}