api.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { post, get } from '@/utils/request';
  2. import { dayjs } from 'element-plus';
  3. export type RequestProps = {
  4. startDate?: string;
  5. endDate?: string;
  6. exportType?: 0 | 1;
  7. userId?: number;
  8. departmentId?: number;
  9. };
  10. export async function getOverallData(payload?: RequestProps): Promise<any> {
  11. return await post('/report/getCustomerTotalCount', payload);
  12. }
  13. export async function getConversionData(payload?: RequestProps): Promise<any> {
  14. return await post('/report/getCustomerTransferRate', payload);
  15. }
  16. export async function getDepartmentData(): Promise<any> {
  17. return await get('/department/normalList');
  18. }
  19. export async function getStaffData(): Promise<any> {
  20. return await get('/user/getSimpleActiveUserList');
  21. }
  22. export async function exportFile(payload: RequestProps, type: number): Promise<any> {
  23. return await post(
  24. type === 0 ? '/report/exportCustomerTotalCount' : '/report/exportCustomerTransferRate',
  25. payload
  26. );
  27. }
  28. export const dateCollections = [
  29. {
  30. name: '当日',
  31. start_time: dayjs().startOf('date').format('YYYY-MM-DD HH:mm:ss'),
  32. end_time: dayjs().endOf('date').format('YYYY-MM-DD HH:mm:ss')
  33. },
  34. {
  35. name: '昨日',
  36. start_time: dayjs().startOf('date').subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'),
  37. end_time: dayjs().endOf('date').subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
  38. },
  39. {
  40. name: '本周',
  41. start_time: dayjs().startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'),
  42. end_time: dayjs().endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss')
  43. },
  44. {
  45. name: '上周',
  46. start_time: dayjs().add(-1, 'week').startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'),
  47. end_time: dayjs().add(-1, 'week').endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss')
  48. },
  49. {
  50. name: '本月',
  51. start_time: dayjs().startOf('month').format('YYYY-MM-DD HH:mm:ss'),
  52. end_time: dayjs().endOf('month').format('YYYY-MM-DD HH:mm:ss')
  53. },
  54. {
  55. name: '上月',
  56. start_time: dayjs().add(-1, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss'),
  57. end_time: dayjs().add(-1, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss')
  58. },
  59. {
  60. name: "本季度",
  61. start_time: dayjs()
  62. .month(Math.floor(dayjs().month() / 3) * 3) // 当前季度的起始月份
  63. .startOf("month")
  64. .format("YYYY-MM-DD HH:mm:ss"),
  65. end_time: dayjs()
  66. .month(Math.floor(dayjs().month() / 3) * 3 + 2) // 当前季度的结束月份
  67. .endOf("month")
  68. .format("YYYY-MM-DD HH:mm:ss"),
  69. },
  70. {
  71. name: "上季度",
  72. start_time: dayjs()
  73. .subtract(1, "quarter")
  74. .month(Math.floor(dayjs().subtract(1, "quarter").month() / 3) * 3)
  75. .startOf("month")
  76. .format("YYYY-MM-DD HH:mm:ss"),
  77. end_time: dayjs()
  78. .subtract(1, "quarter")
  79. .month(Math.floor(dayjs().subtract(1, "quarter").month() / 3) * 3 + 2)
  80. .endOf("month")
  81. .format("YYYY-MM-DD HH:mm:ss"),
  82. },
  83. ];