perf: use import replace require.ensure
This commit is contained in:
parent
0dfa56c73e
commit
7fef8568c2
4 changed files with 20 additions and 21 deletions
|
@ -17,7 +17,7 @@
|
|||
</el-select>
|
||||
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
|
||||
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">添加</el-button>
|
||||
<el-button class="filter-item" type="primary" v-waves icon="el-icon-download" @click="handleDownload">导出</el-button>
|
||||
<el-button class="filter-item" type="primary" :loading="downloadLoading" v-waves icon="el-icon-download" @click="handleDownload">导出</el-button>
|
||||
<el-checkbox class="filter-item" style='margin-left:15px;' @change='tableKey=tableKey+1' v-model="showAuditor">显示审核人</el-checkbox>
|
||||
</div>
|
||||
|
||||
|
@ -196,7 +196,8 @@ export default {
|
|||
type: [{ required: true, message: 'type is required', trigger: 'change' }],
|
||||
timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
|
||||
title: [{ required: true, message: 'title is required', trigger: 'blur' }]
|
||||
}
|
||||
},
|
||||
downloadLoading: false
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
|
@ -330,12 +331,13 @@ export default {
|
|||
})
|
||||
},
|
||||
handleDownload() {
|
||||
require.ensure([], () => {
|
||||
const { export_json_to_excel } = require('@/vendor/Export2Excel')
|
||||
this.downloadLoading = true
|
||||
import('@/vendor/Export2Excel').then(excel => {
|
||||
const tHeader = ['时间', '地区', '类型', '标题', '重要性']
|
||||
const filterVal = ['timestamp', 'province', 'type', 'title', 'importance']
|
||||
const data = this.formatJson(filterVal, this.list)
|
||||
export_json_to_excel(tHeader, data, 'table数据')
|
||||
excel.export_json_to_excel(tHeader, data, 'table数据')
|
||||
this.downloadLoading = false
|
||||
})
|
||||
},
|
||||
formatJson(filterVal, jsonData) {
|
||||
|
|
|
@ -60,13 +60,12 @@ export default {
|
|||
},
|
||||
handleDownload() {
|
||||
this.downloadLoading = true
|
||||
require.ensure([], () => {
|
||||
const { export_json_to_excel } = require('@/vendor/Export2Excel')
|
||||
import('@/vendor/Export2Excel').then(excel => {
|
||||
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
|
||||
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
|
||||
const list = this.list
|
||||
const data = this.formatJson(filterVal, list)
|
||||
export_json_to_excel(tHeader, data, this.filename)
|
||||
excel.export_json_to_excel(tHeader, data, this.filename)
|
||||
this.downloadLoading = false
|
||||
})
|
||||
},
|
||||
|
|
|
@ -66,16 +66,15 @@ export default {
|
|||
handleDownload() {
|
||||
if (this.multipleSelection.length) {
|
||||
this.downloadLoading = true
|
||||
require.ensure([], () => {
|
||||
const { export_json_to_excel } = require('@/vendor/Export2Excel')
|
||||
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
|
||||
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
|
||||
const list = this.multipleSelection
|
||||
const data = this.formatJson(filterVal, list)
|
||||
export_json_to_excel(tHeader, data, this.filename)
|
||||
this.$refs.multipleTable.clearSelection()
|
||||
this.downloadLoading = false
|
||||
})
|
||||
import('@/vendor/Export2Excel').then(excel => {
|
||||
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
|
||||
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
|
||||
const list = this.multipleSelection
|
||||
const data = this.formatJson(filterVal, list)
|
||||
excel.export_json_to_excel(tHeader, data, this.filename)
|
||||
this.$refs.multipleTable.clearSelection()
|
||||
this.downloadLoading = false
|
||||
})
|
||||
} else {
|
||||
this.$message({
|
||||
message: '请至少选择一条记录',
|
||||
|
|
|
@ -59,13 +59,12 @@ export default {
|
|||
},
|
||||
handleDownload() {
|
||||
this.downloadLoading = true
|
||||
require.ensure([], () => {
|
||||
const { export_txt_to_zip } = require('@/vendor/Export2Zip')
|
||||
import('@/vendor/Export2Zip').then(zip => {
|
||||
const tHeader = ['序号', '文章标题', '作者', '阅读数', '发布时间']
|
||||
const filterVal = ['id', 'title', 'author', 'pageviews', 'display_time']
|
||||
const list = this.list
|
||||
const data = this.formatJson(filterVal, list)
|
||||
export_txt_to_zip(tHeader, data, this.filename, this.filename)
|
||||
zip.export_txt_to_zip(tHeader, data, this.filename, this.filename)
|
||||
this.downloadLoading = false
|
||||
})
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue