/**
 * 客户管理请求接口
 */
import request from '../index'
import type { ICustomerQuery } from '@/views/customer/customerInfo/customer_interface'

// 列表查询
export function getCustomerList(data: ICustomerQuery) {
  return request({
    url: `/customer/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 列表查询
export function getCustomerListSimple(data: ICustomerQuery) {
  return request({
    url: '/customer/listPage',
    method: 'post',
    data,
  })
}

// 数据删除
export function deleteCustomer(data: { id: string }) {
  return request({
    url: '/customer/delete',
    method: 'post',
    data,
  })
}

// 查看详情
export function getCustomerDetail(data: { id: string }) {
  return request({
    url: '/customer/detail',
    method: 'post',
    data,
  })
}

// 新增数据
export function addCustomer(data: object) {
  return request({
    url: '/customer/add',
    method: 'post',
    data,
  })
}
// 编辑数据
export function updateCustomer(data: object) {
  return request({
    url: '/customer/update',
    method: 'post',
    data,
  })
}

// 导出列表
export function exportCustomerList(data: Omit<ICustomerQuery, 'limit' | 'offset'>) {
  return request({
    url: '/customer/export',
    method: 'post',
    responseType: 'blob',
    data,
  })
}

// 根据客户查样品id
export function getSampleByCustomer(data: { id: string; offset: number; limit: number }) {
  return request({
    url: `/customer/certificateRecords?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 根据客户查合同记录
export function getContractByCustomer(data: { id: string; offset: number; limit: number }) {
  return request({
    url: `/customer/certificateRecords?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 根据客户查检定记录
export function getOrderByCustomer(data: { sampleId: string; customeId: string }) {
  return request({
    url: '/customer/fake/interface',
    method: 'post',
    data,
  })
}
//
export function getCertificationByCustomer(data: { id: string; offset: number; limit: number }) {
  return request({
    url: `/customer/certificateRecords?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
