背景
因為el-table實現(xiàn)了分頁查詢,所以想要實現(xiàn)el-table需要重新編寫一個查詢全部數(shù)據(jù)的方法文章來源:http://www.zghlxwxcb.cn/news/detail-697865.html
查詢全部數(shù)據(jù)
listQuery:文章來源地址http://www.zghlxwxcb.cn/news/detail-697865.html
export default{
return{
listQuery:{
//page:1,
//limit:20,
//如果想兼容按條件導出,可以定義查詢條件
age:undefined,
sex:undefined
},
}
}
getAllList(){
return findAll(this.listQuery).then(response=>{
return response.data['items']
}).catch(error=>{console.log(error)})
}
導出
async handleDownload(){
this.downloadLoading=true
import('@/vendr/Export2Excel').then(excel=>{
const tHeader=[]
const filterVal=[]
this.getAllList().then(resp=>{
const data=this.formatJson(filterVal,resp)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '測試數(shù)據(jù)'+parseTime(new Date(),'{y}{m}n5n3t3z{h}{i}{s}')
})
})
}).catch(error=>{console.log(error)})
this.downloadLoading=false
},
formatJson(filterVal,all_list){
//給表頭添加序號
all_list.forEach((item,index)=>{
item.index=index+1
})
return all_list.map(v=>filterVal.map(j=>{
if (j==='update_time'){
return parseTime(v[j])
}else{
return v[j]
}
}))
}
到了這里,關于【Vue-Element-Admin】導出el-table全部數(shù)據(jù)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!