mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-26 00:05:45 +00:00
feat: add Excel export to BalanceMonitoringTab
Add exportBalanceMonitoringToExcel to FinanceApiService (server-side blob download hitting reports/balance-monitoring?export=excel). Wire it into BalanceMonitoringTab via a Dropdown export button in the tab actions. Wrap the handler in useCallback to prevent an infinite setTabActions loop caused by a new function reference on every render. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,40 @@ export class FinanceApiService extends BaseApiService<
|
||||
link.remove();
|
||||
}
|
||||
|
||||
async exportBalanceMonitoringToExcel(
|
||||
customer_ids?: string,
|
||||
sales_ids?: string,
|
||||
filter_by?: string,
|
||||
start_date?: string,
|
||||
end_date?: string
|
||||
) {
|
||||
const params = new URLSearchParams();
|
||||
if (customer_ids) params.set('customer_ids', customer_ids);
|
||||
if (sales_ids) params.set('sales_ids', sales_ids);
|
||||
if (filter_by) params.set('filter_by', filter_by);
|
||||
if (start_date) params.set('start_date', start_date);
|
||||
if (end_date) params.set('end_date', end_date);
|
||||
params.set('export', 'excel');
|
||||
params.set('page', '1');
|
||||
params.set('limit', '9999999999');
|
||||
|
||||
const res = await httpClient<Blob>(
|
||||
`${this.basePath}/balance-monitoring?${params.toString()}`,
|
||||
{ method: 'GET', responseType: 'blob' }
|
||||
);
|
||||
|
||||
const url = window.URL.createObjectURL(new Blob([res]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute(
|
||||
'download',
|
||||
`laporan-balance-monitoring-${formatDate(Date.now(), 'DD-MM-YYYY')}.xlsx`
|
||||
);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
}
|
||||
|
||||
async getBalanceMonitoringReport(params: {
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
|
||||
Reference in New Issue
Block a user