tableReport.api.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { defHttp } from '/@/utils/http/axios';
  2. import { Modal } from 'ant-design-vue';
  3. enum Api {
  4. list = '/safety/reportDataSyn/list',
  5. save = '/safety/reportDataSyn/add',
  6. edit = '/safety/reportDataSyn/edit',
  7. deleteById = '/safety/reportDataSyn/delete',
  8. readReportData= '/safety/reportDataSyn/readReportData',//手动从报表里提取数据
  9. importData = '/safety/reportDataSyn/importData',//导入
  10. exportData='/safety/reportDataSyn/exportData'//导出
  11. }
  12. /**
  13. * 导出
  14. * @param params
  15. */
  16. export const getExportUrl = (params) => defHttp.get({ url: Api.exportData, params, responseType: 'blob' });
  17. /**
  18. * 导入api
  19. */
  20. export const getImportUrl = (params, handleSuccess) => {
  21. return defHttp.post({ headers: { 'Content-Type': 'multipart/form-data' }, url: Api.importData, params }).then(() => {
  22. handleSuccess();
  23. });
  24. };
  25. /**
  26. * 手动从报表里提取数据
  27. * @param params
  28. */
  29. export const readReportData = (params) => {
  30. return defHttp.get({ url: Api.readReportData, params }, { joinParamsToUrl: true })
  31. };
  32. /**
  33. * 列表接口
  34. * @param params
  35. */
  36. export const list = (params) => defHttp.get({ url: Api.list, params });
  37. /**
  38. * 删除用户
  39. */
  40. export const deleteById = (params, handleSuccess) => {
  41. return defHttp.delete({ url: Api.deleteById, params }, { joinParamsToUrl: true }).then(() => {
  42. handleSuccess();
  43. });
  44. };
  45. /**
  46. * 批量删除用户
  47. * @param params
  48. */
  49. export const batchDeleteById = (params, handleSuccess) => {
  50. Modal.confirm({
  51. title: '确认删除',
  52. content: '是否删除选中数据',
  53. okText: '确认',
  54. cancelText: '取消',
  55. onOk: () => {
  56. return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
  57. handleSuccess();
  58. });
  59. },
  60. });
  61. };
  62. /**
  63. * 保存或者更新用户
  64. * @param params
  65. */
  66. export const saveOrUpdate = (params, isUpdate) => {
  67. const url = isUpdate ? Api.edit : Api.save;
  68. return defHttp.post({ url: url, params });
  69. };