import { post, get } from '@/utils/request'; import { dayjs } from 'element-plus'; export type RequestProps = { startDate?: string; endDate?: string; exportType?: 0 | 1; userId?: number; departmentId?: number; }; export async function getOverallData(payload?: RequestProps): Promise { return await post('/report/getCustomerTotalCount', payload); } export async function getConversionData(payload?: RequestProps): Promise { return await post('/report/getCustomerTransferRate', payload); } export async function getDepartmentData(): Promise { return await get('/department/normalList'); } export async function getStaffData(): Promise { return await get('/user/getSimpleActiveUserList'); } export async function exportFile(payload: RequestProps, type: number): Promise { return await post( type === 0 ? '/report/exportCustomerTotalCount' : '/report/exportCustomerTransferRate', payload ); } export const dateCollections = [ { name: '当日', start_time: dayjs().startOf('date').format('YYYY-MM-DD HH:mm:ss'), end_time: dayjs().endOf('date').format('YYYY-MM-DD HH:mm:ss') }, { name: '昨日', start_time: dayjs().startOf('date').subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), end_time: dayjs().endOf('date').subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss') }, { name: '本周', start_time: dayjs().startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'), end_time: dayjs().endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss') }, { name: '上周', start_time: dayjs().add(-1, 'week').startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'), end_time: dayjs().add(-1, 'week').endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss') }, { name: '本月', start_time: dayjs().startOf('month').format('YYYY-MM-DD HH:mm:ss'), end_time: dayjs().endOf('month').format('YYYY-MM-DD HH:mm:ss') }, { name: '上月', start_time: dayjs().add(-1, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss'), end_time: dayjs().add(-1, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss') }, { name: "本季度", start_time: dayjs() .month(Math.floor(dayjs().month() / 3) * 3) // 当前季度的起始月份 .startOf("month") .format("YYYY-MM-DD HH:mm:ss"), end_time: dayjs() .month(Math.floor(dayjs().month() / 3) * 3 + 2) // 当前季度的结束月份 .endOf("month") .format("YYYY-MM-DD HH:mm:ss"), }, { name: "上季度", start_time: dayjs() .subtract(1, "quarter") .month(Math.floor(dayjs().subtract(1, "quarter").month() / 3) * 3) .startOf("month") .format("YYYY-MM-DD HH:mm:ss"), end_time: dayjs() .subtract(1, "quarter") .month(Math.floor(dayjs().subtract(1, "quarter").month() / 3) * 3 + 2) .endOf("month") .format("YYYY-MM-DD HH:mm:ss"), }, ];