index.vue 897 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <div>
  3. <el-button type="success" size="small" icon="el-icon-download" @click="submit()">导 出</el-button>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. props:['tablecols','param','excelTitle'],
  9. data () {
  10. return {}
  11. },
  12. methods:{
  13. async submit () {
  14. this.param.content.isAll = true
  15. const res = await this.$api.requested(this.param)
  16. let table = JSON.parse(JSON.stringify(this.tablecols))
  17. table.forEach((e,index) => {
  18. if (e.title === '省市县') {
  19. table[index].title = '省'
  20. table.splice(index + 1,0,{title:'市',columnname:'city'},{title:'县',columnname:'county'})
  21. }
  22. });
  23. let hd = table.map(e=>{
  24. return e.title
  25. })
  26. let ft = table.map(e=>{
  27. return e.columnname
  28. })
  29. this.tool.exportExcel(hd,ft,res.data,this.excelTitle)
  30. }
  31. }
  32. }
  33. </script>
  34. <style>
  35. </style>