import request from '@/utils/request'

// 创建部门业绩目标设置
export function createDeptTarget(data) {
  return request({
    url: '/sale/dept-target/create',
    method: 'post',
    data: data
  })
}

// 我的部门业绩
export function myDeptAchievementByPage(data) {
  return request({
    url: '/sale/dept-target/myDeptAchievementByPage',
    method: 'post',
    data: data
  })
}
// 我的业绩
export function myAchievementByPage(data) {
  return request({
    url: '/sale/dept-target/myAchievementByPage',
    method: 'post',
    data: data
  })
}

// 全部业绩
export function allAchievementByPage(data) {
  return request({
    url: '/sale/dept-target/allAchievementByPage',
    method: 'post',
    data: data
  })
}

// 更新部门业绩目标设置
export function updateDeptTarget(data) {
  return request({
    url: '/sale/dept-target/update',
    method: 'put',
    data: data
  })
}

// 删除部门业绩目标设置
export function deleteDeptTarget(id) {
  return request({
    url: '/sale/dept-target/delete?id=' + id,
    method: 'delete'
  })
}

export function getCreateInitData() {
  return request({
    url: '/sale/dept-target/getCreateInitData',
    method: 'get'
  })
}

// 获得部门业绩目标设置
export function getDeptTarget(id) {
  return request({
    url: '/sale/dept-target/get?id=' + id,
    method: 'get'
  })
}

// 获得部门业绩目标设置分页
export function getDeptTargetPage(query) {
  return request({
    url: '/sale/dept-target/statistics/page',
    method: 'get',
    params: query
  })
}

// 获得我的部门及以下业绩目标设置分页
export function getMyDeptTargetPage(query) {
  return request({
    url: '/sale/dept-target/deptStatistics/page',
    method: 'get',
    params: query
  })
}

// 获得个人目标进度分页
export function getPersonTargetPage(query) {
  return request({
    url: '/sale/dept-target/personal/page',
    method: 'get',
    params: query
  })
}

// 导出部门业绩目标设置 Excel
export function exportDeptTargetExcel(query) {
  return request({
    url: '/sale/dept-target/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 导出部门业绩目标设置 Excel
export function exportDetailExcel(query) {
  return request({
    url: '/sale/dept-target/exportDetailExcel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 导出部门业绩目标设置 Excel
export function exportStatisticsExcel(query) {
  return request({
    url: '/sale/dept-target/exportStatisticsExcel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
