api.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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().month(0).format('YYYY-MM-DD HH:mm:ss'),
  62. end_time: dayjs().month(2).endOf('month').format('YYYY-MM-DD HH:mm:ss')
  63. },
  64. {
  65. name: '上季度',
  66. start_time: dayjs().add(-1, 'year').month(9).format('YYYY-MM-DD HH:mm:ss'),
  67. end_time: dayjs().add(-1, 'year').month(11).endOf('month').format('YYYY-MM-DD HH:mm:ss')
  68. }
  69. ];