// @ts-ignore
/* eslint-disable */

// 该文件自动生成，请勿手动修改！

// --------------------------------------------------------------------------
// 统计报表之分数段报表服务
// --------------------------------------------------------------------------

import { request, RequestOptions } from '@umijs/max';
import contentDisposition from 'content-disposition';

/** 导出全区表格 POST /api/exam/reporting/avg/range/export-total */
export async function exportTotal(
    params: {
        /** 监测计划ID */
        examplanid: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/reporting/avg/range/export-total';
    const config = {
        method: 'POST',
        params,
        ...(options || {}),
        responseType: 'blob',
        getResponse: true,
    } as RequestOptions;
    const res = await request(url, config);
    const hcd = res.request.getResponseHeader('Content-Disposition');
    if (!hcd) {
        return null;
    }
    let fileName = '';
    const cd = contentDisposition.parse(hcd);
    if (cd?.parameters?.filename) {
        fileName = cd?.parameters?.filename;
    }
    return { fileName, data: res.data as Blob } as API.FileResponse;
}

/** 导出各校分数段统计表 POST /api/exam/reporting/avg/range/export-org */
export async function exportOrg(
    params: {
        /** 监测计划ID */
        examplanid: number;
    },
    options?: { [key: string]: any },
) {
    const url = '/api/exam/reporting/avg/range/export-org';
    const config = {
        method: 'POST',
        params,
        ...(options || {}),
        responseType: 'blob',
        getResponse: true,
    } as RequestOptions;
    const res = await request(url, config);
    const hcd = res.request.getResponseHeader('Content-Disposition');
    if (!hcd) {
        return null;
    }
    let fileName = '';
    const cd = contentDisposition.parse(hcd);
    if (cd?.parameters?.filename) {
        fileName = cd?.parameters?.filename;
    }
    return { fileName, data: res.data as Blob } as API.FileResponse;
}

export default {
    /** 导出全区表格 POST /api/exam/reporting/avg/range/export-total */
    exportTotal,
    /** 导出各校分数段统计表 POST /api/exam/reporting/avg/range/export-org */
    exportOrg,
};
