import request from '@/utils/request'
//客户
export function getCustomerList(query) {
  return request({
    url: '/sam/customer/',
    method: 'get',
    params: query
  })
}
export function createCustomer(data) {
  return request({
    url: '/sam/customer/',
    method: 'post',
    data
  })
}
export function updateCustomer(id, data) {
  return request({
    url: `/sam/customer/${id}/`,
    method: 'put',
    data
  })
}
export function deleteCustomer(id, data) {
  return request({
    url: `/sam/customer/${id}/`,
    method: 'delete',
    data
  })
}
//合同
export function getContractList(query) {
  return request({
    url: '/sam/contract/',
    method: 'get',
    params: query
  })
}
export function createContract(data) {
  return request({
    url: '/sam/contract/',
    method: 'post',
    data
  })
}
export function updateContract(id, data) {
  return request({
    url: `/sam/contract/${id}/`,
    method: 'put',
    data
  })
}
export function deleteContract(id, data) {
  return request({
    url: `/sam/contract/${id}/`,
    method: 'delete',
    data
  })
}
//订单
//合同
export function getOrderList(query) {
  return request({
    url: '/sam/order/',
    method: 'get',
    params: query
  })
}
export function createOrder(data) {
  return request({
    url: '/sam/order/',
    method: 'post',
    data
  })
}
export function getOrder(id) {
  return request({
    url: `/sam/order/${id}/`,
    method: 'get'
  })
}

export function updateOrder(id, data) {
  return request({
    url: `/sam/order/${id}/`,
    method: 'put',
    data
  })
}
export function deleteOrder(id, data) {
  return request({
    url: `/sam/order/${id}/`,
    method: 'delete',
    data
  })
}

export function getordertoplan() {
  return request({
    url: '/sam/order/toplan/',
    method: 'get',
  })
}
//销售记录列表
export function getSaleList(query) {
  return request({
    url: '/sam/sale/',
    method: 'get',
    params: query
  })
}

//销售记录创建
export function createSale(data) {
  return request({
    url: '/sam/sale/',
    method: 'post',
    data
  })
}


export function deleteSale(id, data) {
  return request({
    url: `/sam/sale/${id}/`,
    method: 'delete',
    data
  })
}


export function getSale(id) {
  return request({
    url: `/sam/sale/${id}/`,
    method: 'get'
  })
}

//销售记录列表
export function getSaleproductList(query) {
  return request({
    url: '/sam/sale_product/',
    method: 'get',
    params: query
  })
}

//删除销售记录关联产品
export function deleteSaleproduct(id, data) {
  return request({
    url: `/sam/sale_product/${id}/`,
    method: 'delete',
    data
  })
}


//审核
export function saleAudit(id) {
  return request({
    url: `/sam/sale/${id}/audit/`,
    method: 'POST',
  
  })
}


