Commit 733ca381 authored by shen_yan_pu's avatar shen_yan_pu

完善

parent cc0c3990
......@@ -83,6 +83,7 @@ export function exportRole(query) {
return request({
url: '/system/role/export',
method: 'get',
params: query
params: query,
responseType: 'blob'
})
}
......@@ -637,17 +637,24 @@ export default {
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams
exportRole(queryParams).then(response => {
this.download(response.msg)
}).catch(function() {
this.$confirm('是否确认导出所有用户信息?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return exportRole(queryParams).then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '角色信息' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
})
// this.$confirm('是否确认导出所有角色数据项?', '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(function() {
// return
// }
}
}
}
......
......@@ -317,7 +317,7 @@
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="upload.open = false">取 消</el-button>
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm">确 定</el-button>
</div>
</el-dialog>
<el-dialog
......@@ -366,6 +366,8 @@ import {
exportUser,
resetUserPwd,
changeUserStatus,
importExcel,
uploadFalseFile,
importTemplate
// userLoginManage
} from '@/api/system/user'
......@@ -446,6 +448,7 @@ export default {
deptName: undefined,
// 默认密码
initPassword: undefined,
importLoading: false,
// // 时间范围
// dateRange: ['', ''],
// 状态数据字典
......@@ -499,7 +502,7 @@ export default {
// 设置上传的请求头部
headers: { Authorization: 'Bearer ' + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + '/system/user/importData'
url: process.env.VUE_APP_BASE_API + '/system/user/importExcel'
},
// 查询参数
queryParams: {
......@@ -854,7 +857,49 @@ export default {
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit()
// this.$refs.upload.submit()
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.code === 200) {
if (res.data.filename === null) {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
// 导入成功后刷新页面
this.getList()
} else {
uploadFalseFile({ filename: res.data.filename }).then(res => {
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) // 创建下载的链接
downloadElement.href = href
downloadElement.download = '模板错误提示' + '.txt' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click() // 点击下载
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
})
}
this.importLoading = false
} else if (res.code === 41020) {
this.$message.info('上传超时,请重新上传')
this.importLoading = false
}
}).catch(err => {
this.$message.success(err.message)
this.importLoading = false
})
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment