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

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

/** 批量删除 */
export const delRepJobListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      jPid: v.jPid,
      jName: v.jName,
      jId : v.jId
    };
  });
  return request.postJson({
    url: '/job/spi/job/RepJob/RepJobBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delRepJobApi = (jPid: string | number, jName: string, jId: string): Promise<IResponse> => {
  return request.postJson({ url: '/job/spi/job/RepJob/RepJobDelete', data: { jPid, jName, jId } });
};

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

/** 查询单条数据 */
export const queryRepJobApi = (jPid: string | number, jName: string): Promise<IResponse> => {
  return request.postJson({ url: '/job/spi/job/RepJob/RepJobQueryOne', data: { jPid, jName } });
};

/** 导入 */
export const importExcelApiUrl = '/job/sui/job/RepJob/RepJobImportExcel';

/** 导出 */
export const exportExcelApi = (params: any) => {
  return request.doExport({ url: '/job/sdi/job/RepJob/RepJobExportXls', params });
};
/*根据选中的规则，获取运行的弹框*/
export const getDistinctParams = (params:any)=>{
  return request.postJson({url:"/report/targetRule/params/getDistinctParams",params})
}

/** 运行(不带依赖执行) */
export const runData = data => {
  return request.post({ url: '/job/spi/job/RepJob/RunJob', data });
};

/** 运行(带依赖执行) */
export const runRelyOnData = data => {
  return request.post({ url:'/job/spi/job/RepJob/RunJobs',data});
}

/* 定时器 */
export const ScheduleJobAdd = data=>{
  return request.post({url:'/job/spi/job/RepScheduleJob/RepScheduleJobAdd',data})
}

//关闭定时器
export const RepScheduleJobStop = data=>{
  return request.post({url:'/job/spi/job/RepScheduleJob/RepScheduleJobStop',data})
}


