[update] 修改企标导出

This commit is contained in:
lideqin
2023-09-22 14:12:47 +08:00
parent f05229c835
commit ae787e9cff
3 changed files with 24 additions and 32 deletions
@@ -8,6 +8,8 @@ module.exports = {
temporaryPermissionSet: 'Temporary Permission Setting',
collection: 'Collect',
cancelCollection: 'Cancel Collection',
exportExcelFile: 'Enterprise Standard Table',
exportZipFile: 'Enterprise Standard Document',
templateExport: 'Enterprise Standard Template',
pleaseSelectLeastOneNode: 'Please select Level 2 and below system first',
authorizationDepart: '授权部门',
@@ -8,6 +8,8 @@ module.exports = {
temporaryPermissionSet: '临时权限设置',
collection: '收藏',
cancelCollection: '取消收藏',
exportExcelFile: '企业标准表',
exportZipFile: '企业标准文件',
templateExport: '企业标准模板',
pleaseSelectLeastOneNode: '请先选择企业标准下体系',
authorizationDepart: '授权部门',
@@ -14,13 +14,12 @@
:tree-data="treeData"
:selectedKeys="currentTreeNode"
:default-expand-all="defaultExpandAll">
<a-icon type="folder" slot="folder" class="tree-icon" />
<a-icon type="file" slot="file" class="tree-icon" />
<template #custom="record">
<template #title="record">
<div class="tree-operate-node"
@mouseenter="handleTreeMouseover(record.key)"
@mouseleave="handleTreeMouseout(record.key)"
@click="treeSelect(record)">
<a-icon class="parent-node-icon" type="folder" v-if="record.dataRef.children && record.dataRef.children.length > 0" />
<a-tooltip>
<template #title>
{{ record.title }}
@@ -64,8 +63,8 @@
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button icon="upload" type="primary" ghost v-has="'enterpriseStandard:upload'">{{ $t('import') }}</a-button>
</a-upload>
<a-button icon="export" type="primary" ghost @click="handleExportXls" v-has="'enterpriseStandard:export'">{{ $t('export') }}</a-button>
<a-button icon="mail" type="primary" ghost @click="handleFileExport" v-has="'enterpriseStandard:fileExport'">{{ $t('exportWithFile') }}</a-button>
<a-button icon="export" type="primary" ghost @click="handleExportXls($t('enterpriseStandardLibrary.standard.exportExcelFile'))" v-has="'enterpriseStandard:export'">{{ $t('export') }}</a-button>
<a-button icon="mail" type="primary" ghost @click="handleFileExport($t('enterpriseStandardLibrary.standard.exportZipFile'))" v-has="'enterpriseStandard:fileExport'">{{ $t('exportWithFile') }}</a-button>
<a-button icon="download" type="primary" ghost @click="downTemplate($t('enterpriseStandardLibrary.standard.templateExport'))" v-has="'enterpriseStandard:templateDownload'">{{ $t('templateDownload') }}</a-button>
<a-button icon="delete" type="primary" ghost @click="batchDel" v-has="'enterpriseStandard:batchDel'">{{ $t('batchDelete') }}</a-button>
<a-button icon="setting" type="primary" ghost @click="handleAllocationStandard" v-has="'enterpriseStandard:allocationStandard'">{{ $t('enterpriseStandardLibrary.standard.allocationStandard') }}</a-button>
@@ -172,6 +171,7 @@ import UserSelectModal from '../../../components/selection/UserSelectModal'
// 配置标准弹框
import AllocationStandardDrawer from './modules/AllocationStandardDrawer'
import { postDownFile } from '@/api/manage'
import Vue from 'vue'
export default {
name: 'EnterpriseStandardList',
@@ -239,7 +239,7 @@ export default {
this.treeLoading = true
getTreeList(params).then(res => {
if (res.success) {
this.treeData = this.dealTreeData(res.result)
this.treeData = res.result || []
} else {
this.treeData = []
}
@@ -250,20 +250,6 @@ export default {
this.treeLoading = false
})
},
// 处理左侧树数据结构
dealTreeData (treeData) {
return treeData.map(item => {
if (item.children && item.children.length > 0) {
item.scopedSlots = { icon: 'folder', title: 'custom' }
item.children = this.dealTreeData(item.children)
} else if (item.nodeType === StandardSystemTreeNodeType.ROOT_NODE.value) {
item.scopedSlots = { icon: 'folder', title: 'custom' }
} else {
item.scopedSlots = { icon: 'file', title: 'custom' }
}
return item
})
},
// 左侧树搜索
handleTreeSearch () {
this.treeData = []
@@ -351,18 +337,18 @@ export default {
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none'
})
postDownFile(this.url.exportXlsUrl, param).then((data) => {
if (!data) {
this.$message.warning('文件下载失败')
if (!data || data.size === 0) {
Vue.prototype.$message.warning('文件下载失败')
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xlsx')
window.navigator.msSaveBlob(new Blob([data]), fileName + '.zip')
} else {
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
const url = window.URL.createObjectURL(new Blob([data]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName + '.xlsx')
link.setAttribute('download', fileName + '.zip')
document.body.appendChild(link)
link.click()
document.body.removeChild(link) // 下载完成移除元素
@@ -396,21 +382,21 @@ export default {
postDownFile(this.url.exportZipUrl, 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')
window.navigator.msSaveBlob(new Blob([data]), fileName + '.zip')
} else {
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
const url = window.URL.createObjectURL(new Blob([data]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName + '.xlsx')
link.setAttribute('download', fileName + '.zip')
document.body.appendChild(link)
link.click()
document.body.removeChild(link) // 下载完成移除元素
window.URL.revokeObjectURL(url) // 释放掉blob对象
}
// }
}).finally(() => {
// 销毁这个提示
modalLoading.destroy()
@@ -562,11 +548,13 @@ export default {
</script>
<style scoped lang="less">
.tree-icon {
/deep/ .ant-tree li span.ant-tree-switcher.ant-tree-switcher-noop {
color: #1D2129;
}
/deep/ .ant-tree li span.ant-tree-switcher.ant-tree-switcher-noop {
display: none;
.parent-node-icon {
color: #1D2129;
font-size: 16px;
margin-right: 10px;
}
</style>