// 导出excel downloadExcel() { zjkBase.zjkBaseIndustry(this.queryData).then(res => { this.tableData = res.data.items for (let i in this.tableData) { this.tableData[i].selectionTime = parseTime( this.tableData[i].selectionTime, '{y}-{m}-{d}' ) } import('@/vendor/Export2Excel').then(excel => { const tHeader = [ '人员名称', '性别', '移动电话', '学历', '工作年限', '行业名称', '推荐单位' ] // checkContent const data = this.formatJson( [ 'personName', 'sex', 'mobilePhone', 'highestEducation', 'workingYears', 'industry', 'recommendUnit' ], this.tableData )
excel.export_json_to_excel({
header: tHeader, // Header Required
data, // Specific data Required
filename: '专家选用excel', // Optional
autoWidth: true, // Optional
bookType: 'xlsx' // Optional
})
})
})
},
//封装的方法
formatJson(filterVal, jsonData) {
return jsonData.map(v =>
filterVal.map(j => {
if (j === 'timestamp') {
return parseTime(v[j])
}
return v[j]
})
)
},