Fix download filename

This commit is contained in:
Viet Anh Nguyen 2024-02-06 10:09:02 +07:00
parent 2806af6403
commit cc7891b178
2 changed files with 9 additions and 5 deletions

View File

@ -133,7 +133,7 @@ const columns: TableColumnsType<DataType> = [
key: 'snImeiAAR', key: 'snImeiAAR',
width: '130px', width: '130px',
render: (_, record) => { render: (_, record) => {
const isAbnormal = record.snImeiAAR * 100 < 98; const isAbnormal = record.snImeiAAR * 100 < 95;
return ( return (
<span style={{ color: isAbnormal ? 'red' : '' }}> <span style={{ color: isAbnormal ? 'red' : '' }}>
{(record.snImeiAAR * 100)?.toFixed(2)} {(record.snImeiAAR * 100)?.toFixed(2)}

View File

@ -94,8 +94,10 @@ export async function downloadReport(report_id: string) {
let filename = "report.xlsx"; let filename = "report.xlsx";
try { try {
let basename = response.headers['content-disposition'].split('filename=')[1].split('.')[0]; let basename = response.headers['content-disposition'].split('filename=')[1].split('.')[0];
let extension = response.headers['content-disposition'].split('.')[1].split(';')[0]; if (basename[0] == '_') {
filename = `${basename}.${extension}` basename = basename.substring(1);
}
filename = `${basename}.xlsx`
} catch(err) { } catch(err) {
console.log(err); console.log(err);
} }
@ -123,8 +125,10 @@ export async function downloadDashboardReport(duration='30d', subsidiary='ALL')
let filename = "report.xlsx"; let filename = "report.xlsx";
try { try {
let basename = response.headers['content-disposition'].split('filename=')[1].split('.')[0]; let basename = response.headers['content-disposition'].split('filename=')[1].split('.')[0];
let extension = response.headers['content-disposition'].split('.')[1].split(';')[0]; if (basename[0] == '_') {
filename = `${basename}.${extension}` basename = basename.substring(1);
}
filename = `${basename}.xlsx`
} catch(err) { } catch(err) {
console.log(err); console.log(err);
} }