import ExportJsonExcel from "js-export-excel";
const sureExport = (option) => {
let toExcel = new ExportJsonExcel(option);
toExcel.saveExcel();
}
const exportExcel1 = (exportDataList: any) => {
const option: any = {};
const dataList = exportDataList;
let dataTable = []; // dataTable代表excel文件中的数据内容
if (dataList) {
for (let i in dataList) {
let obj = {
"开始充电时间": dataList[i].startTime,
"手机号": dataList[i].phoneNumber,
"订单编号": dataList[i].cmsOrderId,
"订单状态": dataList[i].status,
"充电金额": dataList[i].totalFee,
"充电度数": dataList[i].totalPower,
"车型": dataList[i].vehicleType,
"启动方式": dataList[i].startModeName,
"创建时间": dataList[i].created,
"充电停止原因": dataList[i].stopReason,
"运营商": dataList[i].cpoName,
"充电站类型": dataList[i].stationTypeName,
"支付方式": dataList[i].paymentMethod,
"开票状态": dataList[i].invoiceStatus,
"Vin": dataList[i].vin,
"用户编号": dataList[i].partnerId,
"充电站编号": dataList[i].stationId,
"充电站名称": dataList[i].stationName,
"省": dataList[i].province,
"市": dataList[i].city,
"充电终端类型": dataList[i].equipmentTypeName,
"充电终端编号": dataList[i].connectorId,
"充电终端功率": dataList[i].power,
"充电站评级": dataList[i].stationScore,
"位置属性": dataList[i].locationAttributionName
};
dataTable.push(obj); // 设置excel每列获取的数据源
}
}
const time = moment().format('YYYYMMDDHHmmss');
option.fileName = `订单_${time}`;
option.datas = [
{
sheetData: dataTable,
// sheetName: "sheet",
sheetHeader: ["开始充电时间","手机号", "订单编号","订单状态","充电金额","充电度数","车型","启动方式","创建时间","充电停止原因","运营商","充电站类型","支付方式","开票状态","Vin","用户编号","充电站编号","充电站名称","省","市","充电终端类型","充电终端编号","充电终端功率","充电站评级","位置属性"],
sheetFilter: ["开始充电时间","手机号", "订单编号","订单状态","充电金额","充电度数","车型","启动方式","创建时间","充电停止原因","运营商","充电站类型","支付方式","开票状态","Vin","用户编号","充电站编号","充电站名称","省","市","充电终端类型","充电终端编号","充电终端功率","充电站评级","位置属性"],
// columnWidths:['10','10','20']//excel列宽度设置
},
];
sureExport(option);
}