$("#download").click(function(){
debugger;
var tableData = $("#tb_departments").bootstrapTable('getData');
var exportTableJson = [];
for(i = 0;i < tableData.length; i++){
var j = {};
j.couponName = tableData[i].couponName;
j.startDate = tableData[i].startDate;
j.endDate = tableData[i].endDate;
j.pointNumber = tableData[i].pointNumber;
j.pointType = tableData[i].pointType;
j.displayCategoryName = tableData[i].displayCategoryName;
j.rank = tableData[i].rank;
j.jan = tableData[i].jan;
j.itemName = tableData[i].itemName;
j.storeCodes = tableData[i].storeCodes;
j.couponImage = tableData[i].couponImage;
j.recommendFlag = tableData[i].recommendFlag;
j.hope = tableData[i].hope;
j.hopeTwo = tableData[i].hopeTwo;
j.hopeThree = tableData[i].hopeThree;
j.hopeFour = tableData[i].hopeFour;
j.updatedUser = tableData[i].updatedUser;
j.updatedTime = tableData[i].updatedTime;
j.deleteFlg = tableData[i].deleteFlg;
j.planStatus = tableData[i].planStatus;
exportTableJson.push(j);
}
exportJsonExcel_(exportTableJson);
})
var exportJsonExcel_ = function(tableData){
debugger;
var date = getNowDate();
var title = "操作履歴" + "_" + date;
var option = {};
option.fileName = title;
option.datas=[{
sheetData: tableData,
sheetName: name,
sheetFilter:['couponName','startDate','endDate','pointNumber','pointType','displayCategoryName','rank','jan','itemName','storeCodes','couponImage','recommendFlag','hope','hopeTwo','hopeThree','hopeFour','updatedUser','updatedTime','deleteFlg','planStatus'],
sheetHeader:['クーポン名','開始日','終了日','ポイント','タイプ','カテゴリー','表示顺位','JAN','商品名','店舗名コード','オススメ','画像ファイル名','第1希望','第2希望','第3希望','第4希望','更新者名','更新日','効・無効','ステータス']
}];
var toExcel = new ExportJsonExcel(option);
toExcel.saveExcel();
}
function getNowDate(){
debugger;
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var seconds = date.getSeconds;
if(month >= 1 && month <= 9){
month = "0" + month;
}
if(day >= 1 && day <= 9){
day = "0" + day;
}
var currentdate = year + month + day;
return currentdate;
}