diff --git a/src/views/system/internalWorkGroup/WorkingGroupList.vue b/src/views/system/internalWorkGroup/WorkingGroupList.vue index 887d8ad5..b1120d53 100644 --- a/src/views/system/internalWorkGroup/WorkingGroupList.vue +++ b/src/views/system/internalWorkGroup/WorkingGroupList.vue @@ -155,7 +155,7 @@ import '@assets/less/common.less' import JTable from '@/components/jero/JTable' import { JeroListMixin } from '@/mixins/JeroListMixin' import TreeNodeModal from './modules/TreeNodeModal' -import { postAction } from '@/api/manage' +import { postAction, downFile } from '@/api/manage' import WorkingGroupModal from './modules/WorkingGroupModal' import { getWorkGroupTreeList } from '@/api/api' @@ -330,6 +330,7 @@ export default { this.initTreeData() this.loadData(1) }, + // 导入,必须选中左侧节点 handleImport (e) { if (!this.currentTreeNode || this.currentTreeNode.length <= 0) { this.$message.warning(this.$t('system.internalWorkGroup.pleaseSelectASystem')) @@ -337,6 +338,54 @@ export default { } else { this.importData = { workingGroupId: this.currentTreeNode[0] } } + }, + // 导出左侧必选 + handleExportXls (fileName) { + if (!this.currentTreeNode || this.currentTreeNode.length <= 0) { + this.$message.warning(this.$t('system.internalWorkGroup.pleaseSelectASystem')) + return + } + if (!fileName || typeof fileName !== 'string') { + fileName = '导出文件' + } + const param = this.getQueryParams() + if (this.selectedRowKeys && this.selectedRowKeys.length > 0) { + param.selections = this.selectedRowKeys.join(',') + } + param.workingGroupId = this.currentTreeNode[0] + console.log('导出参数', param) + // 加一个大的提示 + const modalLoading = this.$info({ + title: '提示', + content: 正在导出,请稍候 , + 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('文件下载失败') + return + } + if (typeof window.navigator.msSaveBlob !== 'undefined') { + window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xlsx') + } 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 + '.xlsx') + document.body.appendChild(link) + link.click() + document.body.removeChild(link) // 下载完成移除元素 + window.URL.revokeObjectURL(url) // 释放掉blob对象 + } + }).finally(() => { + // 销毁这个提示 + modalLoading.destroy() + }) } }