quartz.api.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. import { defHttp } from '/@/utils/http/axios';
  2. import { Modal } from 'ant-design-vue';
  3. enum Api {
  4. list = '/ventanaly/quartzJob/list',
  5. save = '/ventanaly/quartzJob/add',
  6. edit = '/ventanaly/quartzJob/edit',
  7. get = '/ventanaly/quartzJob/queryById',
  8. pause = '/ventanaly/quartzJob/pause',
  9. resume = '/ventanaly/quartzJob/resume',
  10. delete = '/ventanaly/quartzJob/delete',
  11. dataCenterDelete = '/ventanaly-collect/collect/quartzJob/delete',
  12. exportXlsUrl = '/ventanaly/quartzJob/exportXls',
  13. importExcelUrl = '/ventanaly/quartzJob/importExcel',
  14. execute = '/ventanaly/quartzJob/execute',
  15. deleteBatch = '/ventanaly-collect/collect/quartzJob/deleteBatch',
  16. //数据中心
  17. dataCenterList = '/dataCenter/ventanaly-collect/collect/quartzJob/list',
  18. // dataCentersave = '/dataCenter/ventanaly/quartzJob/add',
  19. // dataCenteredit = '/dataCenter/ventanaly/quartzJob/edit',
  20. }
  21. /**
  22. * 导出api
  23. */
  24. export const getExportUrl = Api.exportXlsUrl;
  25. /**
  26. * 导入api
  27. */
  28. export const getImportUrl = Api.importExcelUrl;
  29. /**
  30. * 查询任务列表
  31. * @param params
  32. */
  33. export const getQuartzList = (params) => {
  34. return defHttp.get({ url: Api.list, params });
  35. };
  36. /**
  37. * 保存或者更新任务
  38. * @param params
  39. */
  40. export const saveOrUpdateQuartz = (params, isUpdate) => {
  41. let url = isUpdate ? Api.edit : Api.save;
  42. return defHttp.post({ url: url, params });
  43. };
  44. /**
  45. * 查询任务详情
  46. * @param params
  47. */
  48. export const getQuartzById = (params) => {
  49. return defHttp.get({ url: Api.get, params });
  50. };
  51. /**
  52. * 删除任务
  53. * @param params
  54. */
  55. export const deleteQuartz = (params, handleSuccess) => {
  56. return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => {
  57. handleSuccess();
  58. });
  59. };
  60. /**
  61. * 启动
  62. * @param params
  63. */
  64. export const resumeJob = (params, handleSuccess) => {
  65. return defHttp.get({ url: Api.resume, params }).then(() => {
  66. handleSuccess();
  67. });
  68. };
  69. /**
  70. * 暂停
  71. * @param params
  72. */
  73. export const pauseJob = (params, handleSuccess) => {
  74. return defHttp.get({ url: Api.pause, params }).then(() => {
  75. handleSuccess();
  76. });
  77. };
  78. /**
  79. * 立即执行
  80. * @param params
  81. */
  82. export const executeImmediately = (params, handleSuccess) => {
  83. return defHttp.get({ url: Api.execute, params }).then(() => {
  84. handleSuccess();
  85. });
  86. };
  87. /**
  88. * 批量删除任务
  89. * @param params
  90. */
  91. export const batchDeleteQuartz = (params, handleSuccess) => {
  92. Modal.confirm({
  93. title: '确认删除',
  94. content: '是否删除选中数据',
  95. okText: '确认',
  96. cancelText: '取消',
  97. onOk: () => {
  98. return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
  99. handleSuccess();
  100. });
  101. },
  102. });
  103. };
  104. /**
  105. * 数据中心---获取定时任务列表
  106. * @param params
  107. */
  108. export const getDataCenterList = (params) =>
  109. defHttp.get({
  110. url: Api.dataCenterList,
  111. params,
  112. });
  113. /**
  114. * 查询任务详情
  115. * @param params
  116. */
  117. export const getDataCenterQuartzById = (params) => {
  118. return defHttp.get({
  119. url: Api.get,
  120. params,
  121. });
  122. };
  123. /**
  124. * 删除任务
  125. * @param params
  126. */
  127. export const deleteDataCenterQuartz = (params, handleSuccess) => {
  128. return defHttp
  129. .delete(
  130. {
  131. url: Api.dataCenterDelete,
  132. data: params,
  133. },
  134. { joinParamsToUrl: true }
  135. )
  136. .then(() => {
  137. handleSuccess();
  138. });
  139. };
  140. /**
  141. * 批量删除任务
  142. * @param params
  143. */
  144. export const batchDataCenterDeleteQuartz = (params, handleSuccess) => {
  145. Modal.confirm({
  146. title: '确认删除',
  147. content: '是否删除选中数据',
  148. okText: '确认',
  149. cancelText: '取消',
  150. onOk: () => {
  151. return defHttp
  152. .delete(
  153. {
  154. url: Api.deleteBatch,
  155. data: params,
  156. },
  157. { joinParamsToUrl: true }
  158. )
  159. .then(() => {
  160. handleSuccess();
  161. });
  162. },
  163. });
  164. };
  165. // // 定义可配置的控制接口
  166. function generateApiPath(moduleType, operation) {
  167. return `/dataCenter/${moduleType}/quartzJob/${operation}`;
  168. }
  169. // 启动作业接口
  170. export const resumeDataCenterJob = (params: any, sysType: string, operation: string, handleSuccess: () => void) => {
  171. const currentModule = sysType;
  172. const apiPath = generateApiPath(currentModule, operation);
  173. return defHttp
  174. .get({
  175. url: apiPath,
  176. params,
  177. })
  178. .then(() => {
  179. handleSuccess();
  180. });
  181. };
  182. // 停止作业接口
  183. export const pauseDataCenterJob = (params: any, sysType: String, operation: String, handleSuccess: () => void) => {
  184. const currentModule = sysType;
  185. const apiPath = generateApiPath(currentModule, operation);
  186. return defHttp
  187. .get({
  188. url: apiPath,
  189. params,
  190. })
  191. .then(() => {
  192. handleSuccess();
  193. });
  194. };
  195. // 立即执行作业接口
  196. export const excuteDataCenterJob = (params: any, sysType: String, operation: String, handleSuccess: () => void) => {
  197. const currentModule = sysType;
  198. const apiPath = generateApiPath(currentModule, operation);
  199. return defHttp
  200. .get({
  201. url: apiPath,
  202. params,
  203. })
  204. .then(() => {
  205. handleSuccess();
  206. });
  207. };
  208. /**
  209. * 保存或者更新任务
  210. * @param params
  211. */
  212. export const dataCenterUpdateQuartz = (params, sysType: String, operation: String) => {
  213. const currentModule = sysType;
  214. const apiPath = generateApiPath(currentModule, operation);
  215. return defHttp.post({
  216. url: apiPath,
  217. params,
  218. });
  219. };
  220. export const dataCenterSaveQuartz = (params, sysType: String, operation: String) => {
  221. const currentModule = sysType;
  222. const apiPath = generateApiPath(currentModule, operation);
  223. return defHttp.post({
  224. url: apiPath,
  225. params,
  226. });
  227. };