publicBlackIP.api.ts 1.6 KB

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