封装导出工具类
This commit is contained in:
@ -2,13 +2,11 @@ import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Table,
|
||||
Space,
|
||||
Input,
|
||||
Select,
|
||||
Form,
|
||||
Tooltip,
|
||||
Tag,
|
||||
DatePicker,
|
||||
message
|
||||
} from 'antd';
|
||||
import type { TablePaginationConfig } from 'antd';
|
||||
@ -17,10 +15,10 @@ import {
|
||||
DeleteOutlined,
|
||||
ExportOutlined
|
||||
} from '@ant-design/icons';
|
||||
import CategorySelector from '@/components/CategorySelector/CategorySelector';
|
||||
import { AnnualReviewYears, AnnualReviewResultText, AnnualReviewResultColor, SupplierTypeText } from '@/dicts/dataStatistics';
|
||||
import { getSupplierAnnualReviewStatistics, exportSupplierAnnualReviewStatistics } from '@/servers/api/dataStatistics';
|
||||
import { AnnualReviewYears, AnnualReviewResultText, AnnualReviewResultColor } from '@/dicts/dataStatistics';
|
||||
import { getSupplierAnnualReviewStatistics } from '@/servers/api/dataStatistics';
|
||||
import './supplierAnnualStatistics.less';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
|
||||
const { Option } = Select;
|
||||
|
||||
@ -190,21 +188,7 @@ const SupplierAnnualStatistics: React.FC = () => {
|
||||
// 导出功能
|
||||
const handleExport = () => {
|
||||
const values = form.getFieldsValue();
|
||||
exportSupplierAnnualReviewStatistics(values)
|
||||
.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/exportSupplierAnnualReviewStatistics', 'GET', values);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -23,6 +23,7 @@ import { getSupplierEvaluateStatistics, exportSupplierEvaluateStatistics } from
|
||||
import { getAllEvaluateRules } from '@/servers/api/supplierEvaluate';
|
||||
import type { EvaluateRuleItem } from '@/servers/dao/supplierEvaluateTask';
|
||||
import './supplierEvaluateStatistics.less';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
|
||||
const { Option } = Select;
|
||||
const { RangePicker } = DatePicker;
|
||||
@ -209,21 +210,7 @@ const SupplierEvaluateStatistics: React.FC = () => {
|
||||
// 更新handleExport方法实现真实导出功能
|
||||
const handleExport = () => {
|
||||
const values = form.getFieldsValue();
|
||||
exportSupplierEvaluateStatistics(values)
|
||||
.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/exportSupplierEvaluateStatistics', 'GET', values);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -22,6 +22,7 @@ import { SupplierTypeText } from '@/dicts/dataStatistics';
|
||||
import { getSupplierExitStatistics, exportSupplierExitStatistics } from '@/servers/api/dataStatistics';
|
||||
import moment from 'moment';
|
||||
import './supplierExitStatistics.less';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
|
||||
const { Option } = Select;
|
||||
const { RangePicker } = DatePicker;
|
||||
@ -199,21 +200,7 @@ const SupplierExitStatistics: React.FC = () => {
|
||||
// 导出功能
|
||||
const handleExport = () => {
|
||||
const values = form.getFieldsValue();
|
||||
exportSupplierExitStatistics(values)
|
||||
.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/exportSupplierExitStatistics', 'GET', values);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -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