FocusPersonnel.api.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { defHttp } from '/@/utils/http/axios';
  2. import { useMessage } from '/@/hooks/web/useMessage';
  3. const { createConfirm } = useMessage();
  4. enum Api {
  5. list = '/focusPersonnel/list',
  6. save = '/focusPersonnel/add',
  7. edit = '/focusPersonnel/edit',
  8. deleteOne = '/focusPersonnel/delete',
  9. deleteBatch = '/focusPersonnel/deleteBatch',
  10. importExcel = '/focusPersonnel/importExcel',
  11. exportXls = '/focusPersonnel/exportXls',
  12. queryDetailById = '/focusPersonnel/queryDetailById',
  13. }
  14. /**
  15. * 导出api
  16. * @param params
  17. */
  18. export const getExportUrl = Api.exportXls;
  19. /**
  20. * 导入api
  21. */
  22. export const getImportUrl = Api.importExcel;
  23. /**
  24. * 列表接口
  25. * @param params
  26. */
  27. export const list = (params) => defHttp.get({ url: Api.list, params });
  28. /**
  29. * 删除单个
  30. * @param params
  31. * @param handleSuccess
  32. */
  33. export const deleteOne = (params, handleSuccess) => {
  34. return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
  35. handleSuccess();
  36. });
  37. };
  38. /**
  39. * 批量删除
  40. * @param params
  41. * @param handleSuccess
  42. */
  43. export const batchDelete = (params, handleSuccess) => {
  44. createConfirm({
  45. iconType: 'warning',
  46. title: '确认删除',
  47. content: '是否删除选中数据',
  48. okText: '确认',
  49. cancelText: '取消',
  50. onOk: () => {
  51. return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
  52. handleSuccess();
  53. });
  54. },
  55. });
  56. };
  57. /**
  58. * 保存或者更新
  59. * @param params
  60. * @param isUpdate
  61. */
  62. export const saveOrUpdate = (params, isUpdate) => {
  63. const url = isUpdate ? Api.edit : Api.save;
  64. return defHttp.post({ url: url, params }, { isTransformResponse: false });
  65. };
  66. /**
  67. * 查询详情(含个人信息全部字段)
  68. * @param params
  69. */
  70. export const queryDetailById = (params) => {
  71. return defHttp.get({ url: Api.queryDetailById, params });
  72. };