提交 141b22c0 authored 作者: 钟是志's avatar 钟是志

getFileName

上级 6ac77294
...@@ -14,9 +14,13 @@ import SelectModal from '@/webPublic/one_stop_public/App/ExportCurrentInfo/Selec ...@@ -14,9 +14,13 @@ import SelectModal from '@/webPublic/one_stop_public/App/ExportCurrentInfo/Selec
import { getHeaders } from '@/webPublic/zyd_public/utils/utils'; import { getHeaders } from '@/webPublic/zyd_public/utils/utils';
import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform'; import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
const getFileName = (fileName = '导出文件', ext = 'xlsx') => { const getFileName = (fileName = '导出文件', ext = 'xlsx', templatePath = '') => {
fileName = fileName.replaceAll('.', ''); fileName = fileName.replaceAll('.', '');
ext = ext.replaceAll('.', ''); ext = ext.replaceAll('.', '');
if(templatePath && templatePath.includes('.')){
let l = templatePath.split('.');
ext = l[l.length - 1];
}
return fileName + '.' + ext; return fileName + '.' + ext;
} }
...@@ -102,7 +106,7 @@ export default class ExportCurrentInfo extends React.Component { ...@@ -102,7 +106,7 @@ export default class ExportCurrentInfo extends React.Component {
if (data instanceof Blob) { if (data instanceof Blob) {
let a = document.createElement('a'); let a = document.createElement('a');
let url = window.URL.createObjectURL(data); let url = window.URL.createObjectURL(data);
let filename = getFileName(this.props.fileName, this.props.ext); let filename = getFileName(this.props.fileName, this.props.ext, this.props.templatePath);
a.href = url; a.href = url;
a.download = filename; a.download = filename;
a.click(); a.click();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论