import request from '@/config/axios';
import type { TableData } from './types';

/** 获取表格数据 */
export const getRepTaskListApi = (data: any) => {
  return request.postJson({ url: '/job/spi/job/RepTask/RepTaskQueryPage', data });
};

/** 获取子任务表格数据 */
export const getSubTaskListApi = (data: any) => {
  return request.postJson({ url: '/job/spi/job/RepTask/RepSubTaskQuery', data });
};

/** 批量删除 */
export const delRepTaskListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      id: v,
    };
  });
  return request.postJson({
    url: '/job/spi/job/RepTask/RepTaskBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delRepTaskApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/job/spi/job/RepTask/RepTaskDelete', data: { id } });
};

/** 保存 */
export const saveRepTaskApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/job/spi/job/RepTask/RepTaskSave', data });
};

/** 查询单条数据 */
export const queryRepTaskApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/job/spi/job/RepTask/RepTaskQueryOne', data: { id } });
};

/** 导入 */
export const importExcelApiUrl = '/job/sui/job/RepTask/RepTaskImportExcel';

/** 导出 */
export const exportExcelApi = (params: any) => {
  return request.doExport({ url: '/job/sdi/job/RepTask/RepTaskExportXls', params });
};

/** 重新执行作业 */
export const ReRunTaskApi = (params:any) => {
  return request.postJson({ url: '/job/spi/job/RepTask/ReRunTask', params });
}

/* 刷新任务 */
export const RefreshTask = (params:any) => {
  return request.postJson({ url: '/job/spi/job/RepTask/RefreshTask', params });
}

/** 下载任务的错误日志 **/
export const RepTaskErrorMessageDownload = (params:any) => {
  return request.doExport({ url: '/job/sdi/job/RepTask/RepTaskErrorMessageDownload', params });
}
/** 下载完成执行的任务文件 **/
export const RepTaskFileDownload = (params:any) => {
  return request.doExport({ url: '/job/sdi/job/RepTask/RepTaskFileDownload', params });
}

