import { request } from '/@/utils/service';

// 卡片日数据
export function getCardDayData(query) {
  return request({
    url: '/api/report_manage/data-day/sum/',
    method: 'GET',
    params: query,
  });
}

export function getCardWeekData(query) {
  return request({
    url: '/api/report_manage/data-week/sum/',
    method: 'GET',
    params: query,
  });
}

export function getCardMonthData(query) {
  return request({
    url: '/api/report_manage/data-month/sum/',
    method: 'GET',
    params: query,
  });
}

// 条形图日数据
export function getLineForDay(query) {
  return request({
    url: '/api/report_manage/data-day/daily/',
    method: 'GET',
    params: query,
  });
}

export function getLineForWeek(query) {
  return request({
    url: '/api/report_manage/data-week/weekly/',
    method: 'GET',
    params: query,
  });
}

export function getLineForMonth(query) {
  return request({
    url: '/api/report_manage/data-month/monthly/',
    method: 'GET',
    params: query,
  });
}

// 合并展示月对比数据
export function getLineData(query) {
  return request({
    url: '/api/report_manage/data-month/compare/plan/',
    method: 'GET',
    params: query,
  });
}

// 日数据列表展示
export function getDayData(query) {
  return request({
    url: `/api/report_manage/data-day/list/`,
    method: 'GET',
    params: query,
  });
}

export function getWeekData(query) {
  return request({
    url: `/api/report_manage/data-week/list/`,
    method: 'GET',
    params: query,
  });
}

export function getMonthData(query) {
  return request({
    url: `/api/report_manage/data-month/list/`,
    method: 'GET',
    params: query,
  });
}

// 普通展示表格数据汇总
export function getDayTotalData(query) {
  return request({
    url: `/api/report_manage/data-day/list/sum/`,
    method: 'GET',
    params: query,
  });
}

export function getWeekTotalData(query) {
  return request({
    url: `/api/report_manage/data-week/list/sum/`,
    method: 'GET',
    params: query,
  });
}

export function getMonthTotalData(query) {
  return request({
    url: `/api/report_manage/data-month/list/sum/`,
    method: 'GET',
    params: query,
  });
}

// 日数据插入
export function postCreateDayData(body) {
  return request({
    url: `/api/report_manage/data-day/`,
    method: 'POST',
    data: body,
  });
}

export function postCreateWeekData(body) {
  return request({
    url: `/api/report_manage/data-week/`,
    method: 'POST',
    data: body,
  });
}

export function postCreateMonthData(body) {
  return request({
    url: `/api/report_manage/data-month/`,
    method: 'POST',
    data: body,
  });
}

// 数据录入页面展示
export function getDayTaskData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/day/',
    method: 'GET',
    params: query,
  });
}

export function getWeekTaskData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/week/',
    method: 'GET',
    params: query,
  });
}

export function getMonthTaskData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/month/',
    method: 'GET',
    params: query,
  });
}

// 日数据更新
export function postUpdateDayData(body) {
  return request({
    url: `/api/report_manage/data-day/${ body.id }/`,
    method: 'POST',
    data: body,
  });
}

export function postUpdateWeekData(body) {
  return request({
    url: `/api/report_manage/data-week/${ body.id }/`,
    method: 'POST',
    data: body,
  });
}

export function postUpdateMonthData(body) {
  return request({
    url: `/api/report_manage/data-month/${ body.id }/`,
    method: 'POST',
    data: body,
  });
}

// 日数据前一天数据获取
export function getDayBeforeData(query) {
  return request({
    url: '/api/report_manage/data-day/one/',
    method: 'GET',
    params: query,
  });
}

export function getWeekBeforeData(query) {
  return request({
    url: '/api/report_manage/data-week/one/',
    method: 'GET',
    params: query,
  });
}

export function getMonthBeforeData(query) {
  return request({
    url: '/api/report_manage/data-month/one/',
    method: 'GET',
    params: query,
  });
}

// 主数据获取
export function getMainData(query) {
  return request({
    url: '/api/report_manage/data-all/',
    method: 'GET',
    params: query,
  });
}

export function getMonthlyData(query) {
  return request({
    url: '/api/report_manage/data-month/compare/',
    method: 'GET',
    params: query,
  });
}

// 导出
export function exportData(query) {
  return request({
    url: '/api/report_manage/data-all/download/',
    method: 'GET',
    params: query,
    responseType: 'blob'
  });
}

// 日周月数据导出
export function exportDayData(query) {
  return request({
    url: '/api/report_manage/data-day/download/',
    method: 'GET',
    params: query,
    responseType: 'blob'
  });
}

export function exportWeekData(query) {
  return request({
    url: '/api/report_manage/data-week/download/',
    method: 'GET',
    params: query,
    responseType: 'blob'
  });
}

export function exportMonthData(query) {
  return request({
    url: '/api/report_manage/data-month/download/',
    method: 'GET',
    params: query,
    responseType: 'blob'
  });
}

// 计划销售额
export function getPlanSalesData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/plan/',
    method: 'GET',
    params: query,
  });
}

// 创建
export function postCreatePlanSalesData(body) {
  return request({
    url: '/api/report_manage/plan/create/many/',
    method: 'POST',
    data: body,
  });
}

// 更新
export function postUpdatePlanSalesData(body) {
  return request({
    url: `/api/report_manage/plan/update/many/`,
    method: 'POST',
    data: body,
  });
}

// 导出接口
export function exportPlanSalesData(query) {
  return request({
    url: '/api/report_manage/plan/download/',
    method: 'GET',
    params: query,
    responseType: 'blob'
  });
}

// 计划销售额汇总
export function getPlanSalesTotalData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/plan/all/sum/',
    method: 'GET',
    params: query,
  });
}