history.api.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { PaginationProps } from '/@/components/Table';
  2. import { defHttp } from '/@/utils/http/axios';
  3. enum Api {
  4. listdays = '/safety/ventanalyMonitorData/listdays',
  5. getDeviceList = '/ventanaly-device/monitor/device',
  6. getHistoryData = '/ventanaly-device/history/getHistoryData',
  7. }
  8. /**
  9. * 列表接口
  10. * @param params
  11. */
  12. export const list = (deviceCode: string, deviceInfo: any, formData: any, pagination: PaginationProps) => {
  13. if (deviceInfo.stationType === 'redis') {
  14. return defHttp.post({
  15. url: Api.getHistoryData,
  16. params: {
  17. pageNum: pagination.current,
  18. pageSize: pagination.pageSize,
  19. column: 'createTime',
  20. startTime: formData.ttime_begin,
  21. endTime: formData.ttime_end,
  22. deviceId: formData.gdeviceid,
  23. strtype: deviceCode + '*',
  24. interval: formData.skip || '1h',
  25. isEmployee: deviceCode.startsWith('vehicle') ? false : true,
  26. },
  27. });
  28. } else {
  29. return defHttp
  30. .get({
  31. url: Api.listdays,
  32. params: {
  33. pageNo: pagination.current,
  34. pageSize: pagination.pageSize,
  35. column: 'createTime',
  36. strtype: deviceInfo.strtype || deviceCode.concat('*'),
  37. ...formData,
  38. },
  39. })
  40. .then((r) => {
  41. if (r.datalist) return r.datalist;
  42. return { total: 0, records: [] };
  43. });
  44. }
  45. };
  46. /**
  47. * 根据设备编码获取设备列表
  48. * @param params
  49. */
  50. export const getDeviceList = (params) =>
  51. defHttp.post({ url: Api.getDeviceList, params }).then((r) => {
  52. if (r.records && r.records.length) {
  53. return r.records;
  54. }
  55. if (r.msgTxt && r.msgTxt.length) {
  56. return r.msgTxt[0].datalist;
  57. }
  58. return [];
  59. });