[fix 87251] 部门管理-勾选导出

This commit is contained in:
danshihao
2024-07-29 17:20:19 +08:00
parent 6ae8341917
commit 5cc3bda70f
+45 -2
View File
@@ -15,7 +15,7 @@
<!--<a-button @click="refresh" type="default" icon="reload" :loading="loading">刷新</a-button>-->
</a-row>
<div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
<a-input-search @search="onSearch" style="width:100%;margin-top: 10px" :placeholder="$t('depart.enterDepartmentName')" />
<a-input-search @search="onSearch" v-model="queryParam.keyWord" style="width:100%;margin-top: 10px" :placeholder="$t('depart.enterDepartmentName')" />
<!-- -->
<a-col :md="10" :sm="24" class="dropdown-tree">
<template>
@@ -141,7 +141,7 @@
<script>
import DepartModal from './modules/DepartModal'
import { queryDepartTreeList, searchByKeywords, deleteByDepartId } from '@/api/api'
import { httpAction, postAction } from '@/api/manage'
import { downFile, httpAction, postAction } from '@/api/manage'
import { JeroListMixin } from '@/mixins/JeroListMixin'
// import DepartAuthModal from './modules/DepartAuthModal'
// 表头
@@ -250,6 +250,49 @@ export default {
}
},
methods: {
// 数结构导出
handleExportXls (fileName, fileSuffix = '.xls') {
if (!fileName || typeof fileName !== 'string') {
fileName = this.$t('exportFile')
}
const param = Object.assign({}, this.queryParam)
if (this.checkedKeys && this.checkedKeys.length > 0) {
param.selections = this.checkedKeys.join(',')
}
console.log('导出参数', param)
// 加一个大的提示
const modalLoading = this.$info({
title: this.$t('tips'),
content: <span>{this.$t('exportTip')} <a-spin size="small" /></span>,
keyboard: false
})
// 把知道了这个按钮去掉
this.$nextTick(() => {
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none'
})
downFile(this.url.exportXlsUrl, param).then((data) => {
if (!data) {
this.$message.warning(this.$t('fileDownloadFail'))
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + fileSuffix)
} else {
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName + fileSuffix)
document.body.appendChild(link)
link.click()
document.body.removeChild(link) // 下载完成移除元素
window.URL.revokeObjectURL(url) // 释放掉blob对象
}
}).finally(() => {
// 销毁这个提示
modalLoading.destroy()
})
},
loadData () {
this.refresh()
},