/**
 * 原始记录接口
*/
import request from '../../index'
import type { IListQuery, IListQuerySample } from '@/views/business/lab/primitiveLog/primitiveLogList'
const prefix = '/business/originalRecord'

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

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

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

// 新建
export function addPrimitiveLog(data: any) {
  return request({
    url: `${prefix}/add`,
    method: 'post',
    data,
  })
}

// 编辑
export function updatePrimitiveLog(data: any) {
  return request({
    url: `${prefix}/update`,
    method: 'post',
    data,
  })
}

// 获取详情
export function getPrimitiveLogDetail(data: { id: string }) {
  return request({
    url: `${prefix}/detail`,
    method: 'post',
    data,
  })
}

// 根据委托单id查询关联样品信息(分页)
export function getSamplesByOderId(data: IListQuerySample) {
  return request({
    url: `${prefix}/samplesByOderId?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 下载原始记录(半成品)
export function downPrimitiveLog(data: object) {
  return request({
    url: '/business/originalRecord/exportFile',
    method: 'post',
    data,
    responseType: 'blob',
  })
}

