let downBillObj = this.listForm;
let form = document.createElement('form');//定义一个form表单
form.setAttribute("style", "display:none");
form.setAttribute("id", "formID");
form.setAttribute("method", "post");
form.setAttribute("action", process.env.VUE_APP_BASE_API + Network.API.API_AIRTICKET .REPORT_SALE_TICKET_EXCEL);
for (const key in downBillObj) {
if(key == 'page' || key == 'size'){
continue;
}
let input = document.createElement('input');
input.setAttribute("type", "hidden");
input.setAttribute("name", key);
downBillObj[key] ? input.setAttribute("value", downBillObj[key]) : input.setAttribute("value", ' ');
form.appendChild(input);
}
let node = document.getElementById("formID");
if(node){
document.body.removeChild(node);
}
document.body.appendChild(form);//将表单放置在web中
form.submit();//表单提交
第二种方法
/**将属性中含有null的,,全部置为''空字符串 */
for (var key in this.mydata) {
/*key表示每一个健*/
if (this.mydata[key] === null) {
this.mydata[key] = "";
}
}
let json = JSON.parse(JSON.stringify(this.mydata));
json.fromCreateTime = json.fromCreateTime ? this.dateStrToTimestamp(json.fromCreateTime + ' 00:00:00') : ''
json.toCreateTime = json.toCreateTime ? this.dateStrToTimestamp(json.toCreateTime + ' 23:59:59') : ''
let url = Network.API["API_HOTEL"]["REPORT_PAY_EXCEL"] + "?" + this.JsonToUrlParams(json);
window.open(url, "_blank");