【fix bug】导入导出加全局遮罩
This commit is contained in:
+24
-1
@@ -1,13 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-config-provider :locale="locale">
|
<a-config-provider :locale="locale">
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<router-view/>
|
<a-spin :spinning="isImporting || isExporting" :tip="tipText" class="port-spin">
|
||||||
|
<router-view/>
|
||||||
|
</a-spin>
|
||||||
</div>
|
</div>
|
||||||
</a-config-provider>
|
</a-config-provider>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
|
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
|
||||||
import enquireScreen from '@/utils/device'
|
import enquireScreen from '@/utils/device'
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
@@ -15,6 +18,21 @@ export default {
|
|||||||
locale: zhCN
|
locale: zhCN
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
isImporting: state => state.app.isImporting,
|
||||||
|
isExporting: state => state.app.isExporting
|
||||||
|
}),
|
||||||
|
tipText () {
|
||||||
|
if (this.isImporting) {
|
||||||
|
return '正在导入,请稍候...'
|
||||||
|
}
|
||||||
|
if (this.isExporting) {
|
||||||
|
return '正在导出,请稍候...'
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
},
|
||||||
created () {
|
created () {
|
||||||
const that = this
|
const that = this
|
||||||
enquireScreen(deviceType => {
|
enquireScreen(deviceType => {
|
||||||
@@ -37,4 +55,9 @@ export default {
|
|||||||
#app {
|
#app {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.port-spin > div > .ant-spin {
|
||||||
|
height: 100vh!important;
|
||||||
|
max-height: unset!important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -270,6 +270,8 @@ export const JeroListMixin = {
|
|||||||
param.selections = this.selectedRowKeys.join(',')
|
param.selections = this.selectedRowKeys.join(',')
|
||||||
}
|
}
|
||||||
console.log('导出参数', param)
|
console.log('导出参数', param)
|
||||||
|
// 添加全局遮罩
|
||||||
|
this.$store.commit('SET_IS_EXPORTING', true)
|
||||||
downFile(this.url.exportXlsUrl, param).then((data) => {
|
downFile(this.url.exportXlsUrl, param).then((data) => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
this.$message.warning('文件下载失败')
|
this.$message.warning('文件下载失败')
|
||||||
@@ -288,15 +290,22 @@ export const JeroListMixin = {
|
|||||||
document.body.removeChild(link) // 下载完成移除元素
|
document.body.removeChild(link) // 下载完成移除元素
|
||||||
window.URL.revokeObjectURL(url) // 释放掉blob对象
|
window.URL.revokeObjectURL(url) // 释放掉blob对象
|
||||||
}
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
// 去掉全局遮罩
|
||||||
|
this.$store.commit('SET_IS_EXPORTING', false)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/* 导入 */
|
/* 导入 */
|
||||||
handleImportExcel (info) {
|
handleImportExcel (info) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
// 添加全局遮罩
|
||||||
|
this.$store.commit('SET_IS_IMPORTING', true)
|
||||||
if (info.file.status !== 'uploading') {
|
if (info.file.status !== 'uploading') {
|
||||||
console.log(info.file, info.fileList)
|
console.log(info.file, info.fileList)
|
||||||
}
|
}
|
||||||
if (info.file.status === 'done') {
|
if (info.file.status === 'done') {
|
||||||
|
// 去掉全局遮罩
|
||||||
|
this.$store.commit('SET_IS_IMPORTING', false)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
if (info.file.response.success) {
|
if (info.file.response.success) {
|
||||||
// this.$message.success(`${info.file.name} 文件上传成功`);
|
// this.$message.success(`${info.file.name} 文件上传成功`);
|
||||||
@@ -319,6 +328,8 @@ export const JeroListMixin = {
|
|||||||
this.$message.error(`${info.file.name} ${info.file.response.message}.`)
|
this.$message.error(`${info.file.name} ${info.file.response.message}.`)
|
||||||
}
|
}
|
||||||
} else if (info.file.status === 'error') {
|
} else if (info.file.status === 'error') {
|
||||||
|
// 去掉全局遮罩
|
||||||
|
this.$store.commit('SET_IS_IMPORTING', false)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
if (info.file.response.status === 500) {
|
if (info.file.response.status === 500) {
|
||||||
const data = info.file.response
|
const data = info.file.response
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ const app = {
|
|||||||
autoHideHeader: false,
|
autoHideHeader: false,
|
||||||
color: null,
|
color: null,
|
||||||
weak: false,
|
weak: false,
|
||||||
multipage: true // 默认多页签模式
|
multipage: true, // 默认多页签模式
|
||||||
|
isImporting: false, // 是否正在导入
|
||||||
|
isExporting: false // 是否正在导出
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_SIDEBAR_TYPE: (state, type) => {
|
SET_SIDEBAR_TYPE: (state, type) => {
|
||||||
@@ -78,6 +80,12 @@ const app = {
|
|||||||
SET_MULTI_PAGE (state, multipageFlag) {
|
SET_MULTI_PAGE (state, multipageFlag) {
|
||||||
Vue.ls.set(DEFAULT_MULTI_PAGE, multipageFlag)
|
Vue.ls.set(DEFAULT_MULTI_PAGE, multipageFlag)
|
||||||
state.multipage = multipageFlag
|
state.multipage = multipageFlag
|
||||||
|
},
|
||||||
|
SET_IS_IMPORTING (state, isImporting) {
|
||||||
|
state.isImporting = isImporting
|
||||||
|
},
|
||||||
|
SET_IS_EXPORTING (state, isExporting) {
|
||||||
|
state.isExporting = isExporting
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user