// 導出excel
? $('#btnExp').click(function () {
layer.msg('導出成功');
var jsonData =layui.table.cache.testReload;
{#console.log(jsonData.length);#}
{#console.log(jsonData);#}
? ? ? for(var k=0;k
delete jsonData[k]["sysdepartmentid"];
delete jsonData[k]["othername"];
delete jsonData[k]["sysadmin"];
delete jsonData[k]["systemid"];
delete jsonData[k]["statusid"];
delete jsonData[k]["lv"];
delete jsonData[k]["new"];
delete jsonData[k]["appdepartment"];
delete jsonData[k]["department3id"];
delete jsonData[k]["type"];
delete jsonData[k]["useage"];
delete jsonData[k]["appdepartmentid"];
delete jsonData[k]["rdteam"];
delete jsonData[k]["remarks"];
delete jsonData[k]["lvid"];
delete jsonData[k]["typeid"];
delete jsonData[k]["record"];
delete jsonData[k]["newid"];
delete jsonData[k]["appadmin"];
delete jsonData[k]["verno"];
delete jsonData[k]["sysdepartment"];
delete jsonData[k]["Id"];
delete jsonData[k]["LAY_TABLE_INDEX"];
delete jsonData[k]["sysaim"];
}
//列標題轰豆,逗號隔開敬扛,每一個逗號就是隔開一個單元格
let str =`運行狀態(tài),服務交付通道,產品名稱,IT屬主單位,業(yè)務屬主單位,部署位置,IT負責人,調用的總頒系統(tǒng),功能區(qū),產品縮寫\n`;
//增加\t為了不讓表格顯示科學計數(shù)法或者其他格式
for(let i =0 ;i
for(let item in jsonData[i]){
str+=`${jsonData[i][item] +'\t'},`;
}
str+='\n';
}
//encodeURIComponent解決中文亂碼
? ? ? ? ? let uri ='data:text/csv;charset=utf-8,\ufeff' +encodeURIComponent(str);
//通過創(chuàng)建a標簽實現(xiàn)
? ? ? ? ? var link =document.createElement("a");
link.href =uri;
//對下載的文件命名
? ? ? ? ? link.download ="新增系統(tǒng)產品名錄.xls";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});