// 导出excel
outExe() {
this.$confirm('此操作将导出excel文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.excelData = this.dataList //你要导出的数据list。
this.export2Excel()
}).catch(() => {
});
},
export2Excel() {
var that = this;
require.ensure([], () => {
const { export_json_to_excel } = require('../excel/Export2Excel.js'); //这里必须使用绝对路径
const tHeader = ["车牌号", "注册号", "计费类型", "车类型", "入场时间", "所属车位池", "车库名称",]; // 导出的表头名
const filterVal = ['car_no','car_no','fee_type', 'car_type','entry_time','plate_pool','garage_name']; // 导出的表头字段名
const list = that.carlist;
const data = that.formatJson(filterVal, list);
// let time1,time2 = '';
// if(this.start !== '') {
// time1 = that.moment(that.start).format('YYYY-MM-DD')
// }
// if(this.end !== '') {
// time2 = that.moment(that.end).format('YYYY-MM-DD')
// }
console.log(export_json_to_excel);
export_json_to_excel(tHeader, data, `车辆管理在场车辆信息${that.totals.totalNum}条`);// 导出的表格名称,根据需要自己命名
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
<el-button icon="el-icon-upload" type="success" size="medium" @click="outExe()">导出EXCEL报表</el-button>