|
66 | 66 | this.multipleSelection = val; |
67 | 67 | }, |
68 | 68 | handleDownload() { |
69 | | - require.ensure([], () => { |
70 | | - const { export_json_to_excel } = require('vendor/Export2Excel'); |
71 | | - const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']; |
72 | | - const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']; |
73 | | - const list = this.multipleSelection; |
74 | | - const data = this.formatJson(filterVal, list); |
75 | | - export_json_to_excel(tHeader, data, '列表excel'); |
76 | | - this.$refs.multipleTable.clearSelection(); |
77 | | - }) |
| 69 | + if (this.multipleSelection.length) { |
| 70 | + require.ensure([], () => { |
| 71 | + const { export_json_to_excel } = require('vendor/Export2Excel'); |
| 72 | + const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']; |
| 73 | + const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']; |
| 74 | + const list = this.multipleSelection; |
| 75 | + const data = this.formatJson(filterVal, list); |
| 76 | + export_json_to_excel(tHeader, data, '列表excel'); |
| 77 | + this.$refs.multipleTable.clearSelection(); |
| 78 | + }) |
| 79 | + } else { |
| 80 | + this.$message({ |
| 81 | + message: '请选择一条或多条记录导出', |
| 82 | + type: 'warning' |
| 83 | + }); |
| 84 | + } |
78 | 85 | }, |
79 | 86 | formatJson(filterVal, jsonData) { |
80 | 87 | return jsonData.map(v => filterVal.map(j => v[j])) |
|
0 commit comments