Skip to content

Commit 83e8dfc

Browse files
spiritreePanJiaChen
authored andcommitted
fix selectExcel bug
1 parent 77ff823 commit 83e8dfc

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/views/excel/selectExcel.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,22 @@
6666
this.multipleSelection = val;
6767
},
6868
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+
}
7885
},
7986
formatJson(filterVal, jsonData) {
8087
return jsonData.map(v => filterVal.map(j => v[j]))

0 commit comments

Comments
 (0)