device.api.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { defHttp } from '/@/utils/http/axios';
  2. import { Modal } from 'ant-design-vue';
  3. enum Api {
  4. list = '/safety/configurationData/getConfigurationDataList',
  5. save = '/safety/configurationData/addConfigurationData',
  6. edit = '/safety/configurationData/updateConfigurationData',
  7. deleteById = '/safety/configurationData/deleteConfigurationData',
  8. }
  9. /**
  10. * 列表接口
  11. * @param params
  12. */
  13. export const list = (params) => defHttp.get({ url: Api.list, params });
  14. /**
  15. * 删除配置项
  16. */
  17. export const deleteById = (params, handleSuccess) => {
  18. return defHttp.get({ url: Api.deleteById, params }, { joinParamsToUrl: true }).then(() => {
  19. handleSuccess();
  20. });
  21. };
  22. /**
  23. * 批量删除配置项
  24. * @param params
  25. */
  26. export const batchDeleteById = (params, handleSuccess) => {
  27. Modal.confirm({
  28. title: '确认删除',
  29. content: '是否删除选中数据',
  30. okText: '确认',
  31. cancelText: '取消',
  32. onOk: () => {
  33. return defHttp.get({ url: Api.deleteById, data: params }, { joinParamsToUrl: true }).then(() => {
  34. handleSuccess();
  35. });
  36. },
  37. });
  38. };
  39. /**
  40. * 保存或者更新用户
  41. * @param params
  42. */
  43. export const saveOrUpdate = (params, isUpdate) => {
  44. const url = isUpdate ? Api.edit : Api.save;
  45. return isUpdate ? defHttp.post({ url: url, params }) : defHttp.post({ url: url, params });
  46. };