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

/** 获取表格数据 */
export const getSysJobListApi = (data: any) => {
  return request.postJson({ url: '/system/spi/system/SysJob/SysJobQueryPage', data });
};

/** 批量删除 */
export const delSysJobListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      jId: v,
    };
  });
  return request.postJson({
    url: '/system/spi/system/SysJob/SysJobBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delSysJobApi = (jId: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysJob/SysJobDelete', data: { jId } });
};

/** 保存 */
export const saveSysJobApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysJob/SysJobSave', data });
};

/** 查询单条数据 */
export const querySysJobApi = (jId: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysJob/SysJobQueryOne', data: { jId } });
};

/** 导入 */
export const importExcelApiUrl = '/system/sui/system/SysJob/SysJobImpFileLoop';

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