category.api.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { defHttp } from '/@/utils/http/axios';
  2. import { Modal } from 'ant-design-vue';
  3. enum Api {
  4. list = '/sys/category/rootList',
  5. save = '/sys/category/add',
  6. edit = '/sys/category/edit',
  7. deleteCategory = '/sys/category/delete',
  8. deleteBatch = '/sys/category/deleteBatch',
  9. importExcel = '/sys/category/importExcel',
  10. exportXls = '/sys/category/exportXls',
  11. loadTreeData = '/sys/category/loadTreeRoot',
  12. getChildList = '/sys/category/childList',
  13. getChildListBatch = '/sys/category/getChildListBatch',
  14. }
  15. /**
  16. * 导出api
  17. * @param params
  18. */
  19. export const getExportUrl = Api.exportXls;
  20. /**
  21. * 导入api
  22. * @param params
  23. */
  24. export const getImportUrl = Api.importExcel;
  25. /**
  26. * 列表接口
  27. * @param params
  28. */
  29. export const list = (params) => defHttp.get({ url: Api.list, params });
  30. /**
  31. * 删除
  32. */
  33. export const deleteCategory = (params, handleSuccess) => {
  34. return defHttp.delete({ url: Api.deleteCategory, params }, { joinParamsToUrl: true }).then(() => {
  35. handleSuccess();
  36. });
  37. };
  38. /**
  39. * 批量删除
  40. * @param params
  41. */
  42. export const batchDeleteCategory = (params, handleSuccess) => {
  43. Modal.confirm({
  44. title: '确认删除',
  45. content: '是否删除选中数据',
  46. okText: '确认',
  47. cancelText: '取消',
  48. onOk: () => {
  49. return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
  50. handleSuccess();
  51. });
  52. },
  53. });
  54. };
  55. /**
  56. * 保存或者更新
  57. * @param params
  58. */
  59. export const saveOrUpdateDict = (params, isUpdate) => {
  60. let url = isUpdate ? Api.edit : Api.save;
  61. return defHttp.post({ url: url, params });
  62. };
  63. /**
  64. * 查询全部树形节点数据
  65. * @param params
  66. */
  67. export const loadTreeData = (params) => defHttp.get({ url: Api.loadTreeData, params });
  68. /**
  69. * 查询子节点数据
  70. * @param params
  71. */
  72. export const getChildList = (params) => defHttp.get({ url: Api.getChildList, params });
  73. /**
  74. * 批量查询子节点数据
  75. * @param params
  76. */
  77. export const getChildListBatch = (params) => defHttp.get({ url: Api.getChildListBatch, params }, { isTransformResponse: false });