/**
 * 样品列表接口
 */
import request from '../index'
import type { ISampleListQuery } from '@/views/customer/sample/list/sample_list_interface'
const prefix = '/customer'

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

// 数据删除
export function deleteSample(data: { id: string }) {
  return request({
    url: `${prefix}/sample/delete`,
    method: 'post',
    data,
  })
}

// 导出列表
export function exportSapmleList(data: Omit<ISampleListQuery, 'limit' | 'offset'>) {
  return request({
    url: `${prefix}/sample/export`,
    method: 'post',
    responseType: 'blob',
    data,
  })
}

// 新增数据
export function addSample(data: object) {
  return request({
    url: `${prefix}/sample/add`,
    method: 'post',
    data,
  })
}
// 编辑数据
export function updateSample(data: object) {
  return request({
    url: `${prefix}/sample/update`,
    method: 'post',
    data,
  })
}

// 查看详情
export function getSapmleDetail(data: { id: string }) {
  return request({
    url: `${prefix}/sample/detail`,
    method: 'post',
    data,
  })
}

// 查询检定记录
export function getMesureRecords(data: { customerId?: string; sampleId?: string; offset: number; limit: number }) {
  return request({
    url: `${prefix}/sample/measureRecordsById?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 查询检定证书
export function getCertification(data: { customerId?: string; sampleId?: string; offset: number; limit: number }) {
  return request({
    url: `/business/certificateReport/certificateRecordsById?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
// 批量导入
export function batchImportSample(data: FormData) {
  return request({
    url: '/customer/sample/import',
    method: 'post',
    data,
  })
}
