import { defHttp } from '/@/utils/http/axios'; import { Modal } from 'ant-design-vue'; enum Api { list = '/ventanaly/quartzJob/list', save = '/ventanaly/quartzJob/add', edit = '/ventanaly/quartzJob/edit', get = '/ventanaly/quartzJob/queryById', pause = '/ventanaly/quartzJob/pause', resume = '/ventanaly/quartzJob/resume', delete = '/ventanaly/quartzJob/delete', dataCenterDelete = '/ventanaly-collect/collect/quartzJob/delete', exportXlsUrl = '/ventanaly/quartzJob/exportXls', importExcelUrl = '/ventanaly/quartzJob/importExcel', execute = '/ventanaly/quartzJob/execute', deleteBatch = '/ventanaly-collect/collect/quartzJob/deleteBatch', //数据中心 dataCenterList = '/dataCenter/ventanaly-collect/collect/quartzJob/list', // dataCentersave = '/dataCenter/ventanaly/quartzJob/add', // dataCenteredit = '/dataCenter/ventanaly/quartzJob/edit', } /** * 导出api */ export const getExportUrl = Api.exportXlsUrl; /** * 导入api */ export const getImportUrl = Api.importExcelUrl; /** * 查询任务列表 * @param params */ export const getQuartzList = (params) => { return defHttp.get({ url: Api.list, params }); }; /** * 保存或者更新任务 * @param params */ export const saveOrUpdateQuartz = (params, isUpdate) => { let url = isUpdate ? Api.edit : Api.save; return defHttp.post({ url: url, params }); }; /** * 查询任务详情 * @param params */ export const getQuartzById = (params) => { return defHttp.get({ url: Api.get, params }); }; /** * 删除任务 * @param params */ export const deleteQuartz = (params, handleSuccess) => { return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => { handleSuccess(); }); }; /** * 启动 * @param params */ export const resumeJob = (params, handleSuccess) => { return defHttp.get({ url: Api.resume, params }).then(() => { handleSuccess(); }); }; /** * 暂停 * @param params */ export const pauseJob = (params, handleSuccess) => { return defHttp.get({ url: Api.pause, params }).then(() => { handleSuccess(); }); }; /** * 立即执行 * @param params */ export const executeImmediately = (params, handleSuccess) => { return defHttp.get({ url: Api.execute, params }).then(() => { handleSuccess(); }); }; /** * 批量删除任务 * @param params */ export const batchDeleteQuartz = (params, handleSuccess) => { Modal.confirm({ title: '确认删除', content: '是否删除选中数据', okText: '确认', cancelText: '取消', onOk: () => { return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { handleSuccess(); }); }, }); }; /** * 数据中心---获取定时任务列表 * @param params */ export const getDataCenterList = (params) => defHttp.get({ url: Api.dataCenterList, params, }); /** * 查询任务详情 * @param params */ export const getDataCenterQuartzById = (params) => { return defHttp.get({ url: Api.get, params, }); }; /** * 删除任务 * @param params */ export const deleteDataCenterQuartz = (params, handleSuccess) => { return defHttp .delete( { url: Api.dataCenterDelete, data: params, }, { joinParamsToUrl: true } ) .then(() => { handleSuccess(); }); }; /** * 批量删除任务 * @param params */ export const batchDataCenterDeleteQuartz = (params, handleSuccess) => { Modal.confirm({ title: '确认删除', content: '是否删除选中数据', okText: '确认', cancelText: '取消', onOk: () => { return defHttp .delete( { url: Api.deleteBatch, data: params, }, { joinParamsToUrl: true } ) .then(() => { handleSuccess(); }); }, }); }; // // 定义可配置的控制接口 function generateApiPath(moduleType, operation) { return `/dataCenter/${moduleType}/quartzJob/${operation}`; } // 启动作业接口 export const resumeDataCenterJob = (params: any, sysType: string, operation: string, handleSuccess: () => void) => { const currentModule = sysType; const apiPath = generateApiPath(currentModule, operation); return defHttp .get({ url: apiPath, params, }) .then(() => { handleSuccess(); }); }; // 停止作业接口 export const pauseDataCenterJob = (params: any, sysType: String, operation: String, handleSuccess: () => void) => { const currentModule = sysType; const apiPath = generateApiPath(currentModule, operation); return defHttp .get({ url: apiPath, params, }) .then(() => { handleSuccess(); }); }; // 立即执行作业接口 export const excuteDataCenterJob = (params: any, sysType: String, operation: String, handleSuccess: () => void) => { const currentModule = sysType; const apiPath = generateApiPath(currentModule, operation); return defHttp .get({ url: apiPath, params, }) .then(() => { handleSuccess(); }); }; /** * 保存或者更新任务 * @param params */ export const dataCenterUpdateQuartz = (params, sysType: String, operation: String) => { const currentModule = sysType; const apiPath = generateApiPath(currentModule, operation); return defHttp.post({ url: apiPath, params, }); }; export const dataCenterSaveQuartz = (params, sysType: String, operation: String) => { const currentModule = sysType; const apiPath = generateApiPath(currentModule, operation); return defHttp.post({ url: apiPath, params, }); };