index.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { defHttp } from '/@/utils/http/axios';
  2. import { useGlobSetting } from '/@/hooks/setting';
  3. const globSetting = useGlobSetting();
  4. import { downloadByUrl } from '/@/utils/file/download';
  5. import { UploadFileParams } from '/#/axios';
  6. enum Api {
  7. listDictModel = '/sys/dictItem/query/list',
  8. listDictModelBatch = '/sys/dictItem/query/batch/list',
  9. getConfigValue = '/system/sysConfig/getConfigValue',
  10. getSystemTime = '/system/sysConfig/getTime',
  11. getDownloadUrl = '/sys/storage/file/download/',
  12. getPreviewUrl = '/sys/storage/file/preview/',
  13. excelSheetDetail = '/excel/sheet/detail',
  14. tempDownload = '/archives/patientBasic/export',
  15. postFileRemoveByIds = '/sys/storage/file/removeByIds',
  16. }
  17. export function listDictModel(params?: object) {
  18. return defHttp.post({ url: Api.listDictModel, params: params });
  19. }
  20. export function listDictModelBatch(params?: Array<string>) {
  21. return defHttp.post({ url: Api.listDictModelBatch, params: params });
  22. }
  23. export function getConfigValue(params?: object) {
  24. return defHttp.get({ url: Api.getConfigValue, params: params });
  25. }
  26. export function downloadFile(filepath: string) {
  27. downloadByUrl({
  28. url: globSetting.apiUrl + '/common/download?filepath=' + filepath,
  29. target: '_self',
  30. });
  31. }
  32. export function uploadApi(
  33. params: UploadFileParams,
  34. onUploadProgress: (progressEvent: ProgressEvent) => void,
  35. ) {
  36. return defHttp.uploadFile(
  37. {
  38. url: globSetting.apiUrl + '/sys/storage/file/upload',
  39. onUploadProgress,
  40. },
  41. params,
  42. );
  43. }
  44. export function postFileRemoveByIds(params) {
  45. return defHttp.post({ url: Api.postFileRemoveByIds, params: params });
  46. }
  47. export function getSystemTime() {
  48. return defHttp.get({ url: Api.getSystemTime });
  49. }
  50. export function getDownloadUrl(id) {
  51. return defHttp.get({ url: Api.getDownloadUrl + id });
  52. }
  53. export function getPreviewUrl(id) {
  54. return defHttp.get({ url: Api.getPreviewUrl + id });
  55. }
  56. // 导入数据
  57. export const excelSheetDetail = (id: string) => {
  58. return defHttp.get({ url: Api.excelSheetDetail + '/' + id });
  59. };
  60. // 下载模板
  61. export const tempDownload = (params?: Array<string | number>) => {
  62. return defHttp.post({ url: Api.tempDownload, params: params });
  63. };