import request from '@/utils/request'
import query from "@/views/ecw/customer/query";
import * as url from "url";
import {methods} from "vue2-ace-editor";

// 创建客户
export function createCustomer(data) {
  return request({
    url: '/ecw/customer/create',
    method: 'post',
    data: data
  })
}
//完善客户
export function fillupCustomeInfo(data){
  return request({
    url:'/ecw/customer/fillup-customer-info',
    method:'put',
    data
  })
}
// 更新客户
export function updateCustomer(data) {
  return request({
    url: '/ecw/customer/update',
    method: 'put',
    data: data
  })
}
// 新建潜在客户
export function createPotential(data){
  return request({
    url:'/ecw/customer/create-potential',
    method:'post',
    data
  })
}
// 删除客户
export function deleteCustomer(id) {
  return request({
    url: '/ecw/customer/delete?id=' + id,
    method: 'delete'
  })
}

// 获得客户
export function getCustomer(id) {
  return request({
    url: '/ecw/customer/get?id=' + id,
    method: 'get'
  })
}

// 获得客户分页
export function getCustomerPage(query) {
  return request({
    url: '/ecw/customer/page',
    method: 'get',
    params: query,
    timeout: 60000

  })
}
/**
 * 获得部门客户
 * */
export function getCustomerDeptPage(query){
  return request({
    url:'/ecw/customer/deptPage',
    method:'get',
    params:query
  })
}

// 获得客户下拉
export function getCustomerSelect(query) {
  return request({
    url: '/ecw/customer/select',
    method: 'get',
    params: query
  })
}
// 潜在客户
export function getPotential(query){
  return request({
    url:'/ecw/customer/get-potential',
    method:'get',
    params:query
  })
}

// 根据客户id集合获得客户详情列表
export function getCustomerList(query) {
  return request({
    url: '/ecw/customer/list',
    method: 'get',
    params: query
  })
}

// 导出客户 Excel 全部
export function exportCustomerExcel(query) {
  return request({
    url: '/ecw/customer/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
// 我的客户导出
export function mineExporteExcel(query) {
  return request({
    url: '/ecw/customer/mine-export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
// 我的待接收客户列表导出
export function waiteConfirmExportExcel(query) {
  return request({
    url: '/ecw/customer/waite-confirm-export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

/**
 *  // 待分配客户列表导出
 * @param query
 * @return {*}
 */
// export function waitDistributionExportExcel(query) {
//   return request({
//     url: '/ecw/customer/wait-distribution-export-excel',
//     method: 'get',
//     params: query,
//     responseType: 'blob'
//   })
// }
// 公海池客户列表导出
// export function publicExportExcel(query) {
//   return request({
//     url: '/ecw/customer/public-export-excel',
//     method: 'get',
//     params: query,
//     responseType: 'blob'
//   })
// }
export function indirectCustomerExportExcel(query) {
  return request({
    url: '/ecw/indirect-customer/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
// 待接收客户列表
export function getWaitForConfirmList(query) {
  return request({
    url: '/ecw/customer/get-wait-for-confirm',
    method: 'get',
    params: query
  })
}

// 确认
export function confirm(data) {
  return request({
    url: '/ecw/customer/confirm',
    method: 'put',
    data: data
  })
}

// 待分配客户
export function getWaitForDistributionList(query) {
  return request({
    url: '/ecw/customer/get-wait-for-distribution',
    method: 'get',
    params: query
  })
}

// 移交
export function handOverCustomer(data) {
  return request({
    url: '/ecw/customer/handOver',
    method: 'put',
    data: data,
    })
}
export function handoverApproval(data) {
  return request({
    url: '/ecw/customer/handover/approval',
    method: 'post',
    data: data,
    })
}
 export function handoverApprovalDetails(params){
   return request({
      url:'/ecw/customer/handover/approval',
     method:'get',
     params
   })
 }
// 公海池客户
export function getPublicList(query) {
  return request({
    url: '/ecw/customer/get-public',
    method: 'get',
    params: query
  })
}

//捞取
export function setFishing(query){
  return request({
    url:'/ecw/customer/catch-open-sea-customer',
    method:'put',
    params:query,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    }
  })
}
//待分配 客户列表
export function getCustomerToBeAssigned(query){
  return request(
    {
      url:'ecw/customer/get-wait-for-distribution',
      method: 'get',
      params: query

    }
  )
}
//我的客户列表
export function getMyCustomerService(query){
  return request({
    url:'/ecw/customer/get-mine',
    method:'get',
    params:query,
  })
}
//获取会员列表
export  function userMemberUserList(params){
  return request({
    url:'/member/user/member-user-list',
    method:'get',
    params
  })
}
export function memberUserList(params){
  return request({
    url:'/member/user/list',
    method:'get',
    params
  })
}
//查看某客户授权的品牌
export function getBrankByCustomer(data){
  return request({
    url:'/ecw/product-brank/getBrankByCustomer',
    method:'post',
    data,
  })
}
//
export function levelLogPage(params){
  return request({
    url:'/customer/detail/infoList/levelLogPage',
    method:'get',
    params
  })
}
//获取信用等级日志列表
export function customerCreditLogPage(params){
  return  request({
    url:'/customer/detail/infoList/creditLogPage',
    method:'get',
    params
  })
}
//客户详情订单分页
export function infoListOrderPage(params){
  return request({
    url:'/ecw/order/customer-order-page',
    method:'get',
    params
  })
}
//客户详情订单统计
export function infoListStatisticsOrder(params){
  return request({
    url:'/ecw/order/customer-statistics-order',
    method:'get',
    params
  })
}
//客户详情 --- 报价
export  function infoListOfferPage(params){
  return request({
    url:'/customer/detail/infoList/offerPage',
    method:'get',
    params
  })
}
//客户数据
export function orderStatistics(params){
  return request({
    url:'/customer/detail/infoList/orderStatistics',
    method:'get',
    params
  })
}
//创建客户信用日志
export function creditLogCreate(data){
  return request({
    url:'/customer/credit-log/create',
    method:'post',
    data
  })
}
//获得客户统计
export function creditScoreStatistic(params){
  return request({
    url:'/customer/detail/infoList/creditScoreStatistic',
    method:'get',
    params
  })
}
//获取账单数据
export function infoListReceiptPage(params){
  return request({
    url:'/customer/detail/infoList/receiptPage',
    method:'get',
    params
  })
}

// 获取用户
export function getMember(id){
  return request({
    url: "/member/user/get",
    params: {id}
  })
}

// 获得客户路线
export function getCustomerLines(customerId){
  return request({
    url: '/ecw/customer-line/get-by-customer',
    params: {customerId}
  })
}

// 获取客户延期调入公海池的审批详情
export function getDelayInfo(query) {
  return request({
    url: '/ecw/customer/delay/approval/info',
    method: 'get',
    params: query
  })
}

//客户延期调入公海池的审批申请
export function creatDelayApproval(data){
  return request({
    url:'/ecw/customer/delay/approval',
    method:'post',
    data
  })
}

// 取消客户延期调入公海池的审批申请
export function cancelDelayApproval(query) {
  return request({
    url: '/ecw/customer/cancel/delay/approval',
    method: 'put',
     params:query,
    })
}

// 获取客户审批详情
export function getApproval(id) {
  return request({
    url: '/ecw/customer-approval/get',
    method: 'get',
    params: {id}
  })
}
//调入公海池
export function testEnterToOpenSea(customerId) {
  return request({
    url: '/ecw/customer/test-enter-to-open-sea',
    method: 'get',
    params: {customerId}
  })
}

/**
 * 获取常用提货网点
 * */
 export function getServiceNetwork(){
   return request({
     url:'/ecw/node/list',
     method:'get',
   })
}
//设置空运客户
export function changeCustomerAir(data){
   return request({
     url:'/ecw/customer/change-customer-air',
     method:'put',
     data

   })
}
// 设置整柜
 export function setChangeCustomerFcl(data){
   return request({
     url:'/ecw/customer/change-customer-fcl',
     method:'put',
     data
   })
 }
//获得客户日志
 export function getCustomerOperatelogPage(params){
   return request({
     url:'/customer/operate-log/page',
     method:'get',
     params
   })
 }
//  获得客户日志详情
export function getCustomerOperatelog(params){
   return request({
     url:'customer/operate-log/get',
     method:'get',
     params
   })
}
//全部导出
export function customerExportExcel(){
  return request({
    url:'/ecw/customer/export-excel',
    method:'get'
  })
}
// 导出我的客户列表
//全部导出
export function mineExportExcel(){
  return request({
    url:'/ecw/customer/mine-export-excel',
    method:'get'
  })
}
// 导出我的待接收客户
 export function waiteConfirEexportExcel(){
   return request({
     url:'/ecw/customer/waite-confirm-export-excel',
     method:'get'
   })
 }
//公海池客户列表导出
export  function publicExportExcel(){
   return request({
     url:'/ecw/customer/public-export-excel',
     method:'get'
   })
}
//待分配客户
export function waitDistributionExportExcel(){
   return request({
     url:'/ecw/customer/wait-distribution-export-excel',
     method:'get'
   })
}

//导出潜在客户
export function potentialExportExcel(){
   return request({
     url:'ecw/customer/potential-export-excel',
     method:'get'
   })
}

// 导出部门客户
export function deptExportExcel(){
   return request({
     url:'ecw/customer/dept-export-excel',
     method:'get'
   })
}

export function recycleUnconfirmedCustomer(data){
   return request({
     url:'ecw/customer/recycle-unconfirmed-customer',
     method:'put',
     data
   })

}

export function updatecustomerToOld(params){
   return request({
     url:'ecw/customer/update-customer-new-or-old',
     method:'put',
     params
   })
}

export function changeCustomerDefaultPay(data){
  return request({
    url:'ecw/customer/change-customer-default-pay',
    method:'put',
    data
  })
}

export function changeCustomerNoConsignee(data){
  return request({
    url:'ecw/customer/change-customer-no-consignee',
    method:'put',
    data
  })
}

export function changeCustomerDefaultBilling(data){
  return request({
    url:'ecw/customer/change-customer-default-billing',
    method:'put',
    data
  })
}

export function customerSettingButton(data){
  return request({
    url:'ecw/customer/update-customer-setup',
    method:'put',
    data
  })
}

export function addCompetitor(data){
  return request({
    url:'customer/competitor/create',
    method:'post',
    data
  })
}


// 获得客户
export function getCompetitor(id) {
  return request({
    url: '/customer/competitor/get?id=' + id,
    method: 'get'
  })
}

export function competitorListAll(params){
  return request({
    url:'customer/competitor/listAll',
    method:'get',
    params
  })
}

export function customerMergeCus(params){
  return request({
    url:'ecw/customer/mergeCus',
    method:'get',
    params
  })
}
