update 文档拆分-编辑-导出

This commit is contained in:
赵霄
2023-10-23 14:46:34 +08:00
parent cf14e50e80
commit 64b26a4ea8
3 changed files with 56 additions and 6 deletions
@@ -89,7 +89,7 @@
type="primary"
ghost
v-has="'split:sarFileSplitItems:export'"
@click="handleExportXls($t('standardRegulationLibrary.domesticStandard.exportFileName'), 'zip')">
@click="handleExportXls($t('standardRegulationLibrary.domesticStandard.exportFileName'), '.zip')">
{{ $t('export') }}
</a-button>
<!--批量删除-->
@@ -195,7 +195,7 @@ import {
import Search from '../../../components/customField/Search.vue'
import { isHasPermission } from '../../../utils/hasPermission.js'
import SplitDetailBatchEditDrawer from './modules/SplitDetailBatchEditDrawer.vue'
import { postAction } from '../../../api/manage'
import { downFile, postAction } from '../../../api/manage'
export default {
name: 'DocumentSplitDetail',
@@ -564,7 +564,56 @@ export default {
})
}
})
}
},
/**
* 导出
* @param fileName
* @param fileSuffix
*/
handleExportXls (fileName, fileSuffix = '.xls') {
if (!fileName || typeof fileName !== 'string') {
fileName = '导出文件'
}
const param = this.getQueryParams()
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
param.idList = this.selectedRowKeys.join(',')
}
param.exportName = fileName + fileSuffix
param.parameter = this.infoId
// 加一个大的提示
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()
})
},
}
}
</script>