封装导出工具类
This commit is contained in:
@ -22,6 +22,7 @@ import { SupplierTypeText } from '@/dicts/dataStatistics';
|
||||
import { getSupplierQualificationExpire, exportSupplierQualificationExpire } from '@/servers/api/dataStatistics';
|
||||
import moment from 'moment';
|
||||
import './supplierQualificationWarningStatistics.less';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
|
||||
const { Option } = Select;
|
||||
const { RangePicker } = DatePicker;
|
||||
@ -230,21 +231,7 @@ const SupplierQualificationWarningStatistics: React.FC = () => {
|
||||
];
|
||||
}
|
||||
|
||||
exportSupplierQualificationExpire(exportParams)
|
||||
.then(response => {
|
||||
// 创建a标签进行下载
|
||||
const url = window.URL.createObjectURL(new Blob([response]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', `供应商资质预警统计_${new Date().getTime()}.xlsx`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('导出失败:', error);
|
||||
message.error('导出失败');
|
||||
});
|
||||
downloadFile('/dataStatistics/exportSupplierQualificationExpire', 'GET', exportParams);
|
||||
};
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user