Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

selectExcel.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="app-container">
  3. <!-- $t is vue-i18n global function to translate lang -->
  4. <el-input style='width:340px;' :placeholder="$t('excel.placeholder')" prefix-icon="el-icon-document" v-model="filename"></el-input>
  5. <el-button style='margin-bottom:20px' type="primary" icon="document" @click="handleDownload" :loading="downloadLoading">{{$t('excel.selectedExport')}}</el-button>
  6. <el-table :data="list" v-loading="listLoading" element-loading-text="拼命加载中" border fit highlight-current-row @selection-change="handleSelectionChange"
  7. ref="multipleTable">
  8. <el-table-column type="selection" align="center"></el-table-column>
  9. <el-table-column align="center" label='Id' width="95">
  10. <template slot-scope="scope">
  11. {{scope.$index}}
  12. </template>
  13. </el-table-column>
  14. <el-table-column label="Title">
  15. <template slot-scope="scope">
  16. {{scope.row.title}}
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="Author" width="110" align="center">
  20. <template slot-scope="scope">
  21. <el-tag>{{scope.row.author}}</el-tag>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="Readings" width="115" align="center">
  25. <template slot-scope="scope">
  26. {{scope.row.pageviews}}
  27. </template>
  28. </el-table-column>
  29. <el-table-column align="center" label="PDate" width="220">
  30. <template slot-scope="scope">
  31. <i class="el-icon-time"></i>
  32. <span>{{scope.row.display_time}}</span>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </div>
  37. </template>
  38. <script>
  39. import { fetchList } from '@/api/article'
  40. export default {
  41. name: 'selectExcel',
  42. data() {
  43. return {
  44. list: null,
  45. listLoading: true,
  46. multipleSelection: [],
  47. downloadLoading: false,
  48. filename: ''
  49. }
  50. },
  51. created() {
  52. this.fetchData()
  53. },
  54. methods: {
  55. fetchData() {
  56. this.listLoading = true
  57. fetchList(this.listQuery).then(response => {
  58. this.list = response.data.items
  59. this.listLoading = false
  60. })
  61. },
  62. handleSelectionChange(val) {
  63. this.multipleSelection = val
  64. },
  65. handleDownload() {
  66. if (this.multipleSelection.length) {
  67. this.downloadLoading = true
  68. import('@/vendor/Export2Excel').then(excel => {
  69. const tHeader = ['Id', 'Title', 'Author', 'Readings', 'Date']
  70. const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
  71. const list = this.multipleSelection
  72. const data = this.formatJson(filterVal, list)
  73. excel.export_json_to_excel({
  74. header: tHeader,
  75. data,
  76. filename: this.filename
  77. })
  78. this.$refs.multipleTable.clearSelection()
  79. this.downloadLoading = false
  80. })
  81. } else {
  82. this.$message({
  83. message: 'Please select at least one item',
  84. type: 'warning'
  85. })
  86. }
  87. },
  88. formatJson(filterVal, jsonData) {
  89. return jsonData.map(v => filterVal.map(j => v[j]))
  90. }
  91. }
  92. }
  93. </script>