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

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

/** 批量删除 */
export const delRepScheduleJobListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      pId: v.pId,
      sId: v.sId,
      jId: v.jId,
    };
  });
  return request.postJson({
    url: '/job/spi/job/RepScheduleJob/RepScheduleJobBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delRepScheduleJobApi = (pId?: string, sId?: string, jId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/job/spi/job/RepScheduleJob/RepScheduleJobDelete', data: { pId, sId, jId } });
};

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

/** 查询单条数据 */
export const queryRepScheduleJobApi = (pId?: string, sId?: string, jId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/job/spi/job/RepScheduleJob/RepScheduleJobQueryOne', data: { pId, sId, jId } });
};

/** 同步导入 */
export const importExcelApiUrl = '/job/sui/job/RepScheduleJob/RepScheduleJobImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/job/sui/job/RepScheduleJob/RepScheduleJobImportAsyncExcel';

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

/** 获取某个字典 */
export const getCsckCheckType = ({ paramName, systemCode }): Promise<IResponse> => {
  return request.postJson({
    url: '/param/spi/param/systemparam',
    data: {
      paramName: paramName,
      systemCode: systemCode,
    },
  });
};

