/**
 * 任务分发,实验室检测
*/
import request from '../../index'
import type { ILabQuery, ISendBack, ITaskQuery } from '@/views/business/schedule/task/task-interface'
const prefix = '/meter'

// 任务分发列表查询
export function getTaskList(data: ITaskQuery) {
  return request({
    url: `/business/labExecutive/handOut/list?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 任务分发详情
export function getTaskDetail(data: { orderId: string; sampleId: string }) {
  return request({
    url: '/business/labExecutive/handOut/detail',
    method: 'post',
    data,
  })
}

// 部门检测我的检测详情
export function executiveDetail(data: { orderId: string; sampleId: string }) {
  return request({
    url: '/business/labExecutive/executive/detail',
    method: 'post',
    data,
  })
}

// 导出列表
export function exportTaskList(data: Omit<ITaskQuery, 'limit' | 'offset'>) {
  return request({
    url: '/business/labExecutive/handOut/listExport',
    method: 'post',
    responseType: 'blob',
    data,
  })
}

// 初始化检定流程
export function init(data: { measureContent: string; orderId: string; sampleId: string }) {
  return request({
    url: '/business/labExecutive/handOut/initList',
    method: 'post',
    data,
  })
}

// 收发员任务分发
export function setMeasureProcess(data: { orderId: string; sampleId: string; measureProcessList: any[] }) {
  return request({
    url: '/business/labExecutive/handOut/execute',
    method: 'post',
    data,
  })
}

// 实验室编辑实验室检测列表
export function setMeasureProcessByFfy(data: { orderId: string; sampleId: string; measureProcessList: any[] }) {
  return request({
    url: '/business/labExecutive/handOut/updateList',
    method: 'post',
    data,
  })
}

// 退回(待检测/检测中->退回)
export function sendBackProcess(data: ISendBack) {
  return request({
    url: '/business/labExecutive/executive/sendBack',
    method: 'post',
    data,
  })
}

// 收入（待检测->检测中）->收入)
export function myExecutiveReceive(data: object) {
  return request({
    url: '/business/labExecutive/myExecutive/receive',
    method: 'post',
    data,
  })
}

// 分配
export function allocate(data: any) {
  return request({
    url: '/business/labExecutive/deptExecutive/allocate',
    method: 'post',
    data,
  })
}

// 实验室收入样品
export function takeInSample(data: { orderId: string; sampleId: string }[]) {
  return request({
    url: `${prefix}/schedule/task/setSchedule`,
    method: 'post',
    data,
  })
}

// 检完样品-手动/批量
export function overSample(data: { orderId: string; sampleId: string }[]) {
  return request({
    url: `${prefix}/schedule/task/setSchedule`,
    method: 'post',
    data,
  })
}

// 我的检测-列表
export function getMyMeasureList(data: ILabQuery) {
  return request({
    url: `/business/labExecutive/myExecutive/list?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
// 我的检测-检测完成
export function myExecutiveDone(data: object) {
  return request({
    url: '/business/labExecutive/myExecutive/complete',
    method: 'post',
    data,
  })
}

// 部门检测-列表
export function getDeptMeasureList(data: ILabQuery) {
  return request({
    url: `/business/labExecutive/deptExecutive/List?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 证书监控
export function certificateMonitorsById(data: { offset: number; limit: number }) {
  return request({
    url: `/business/certificateReport/certificateMonitorsById?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

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

// 检定证书
export function certificateRecordsById(data: { offset: number; limit: number }) {
  return request({
    url: `/business/certificateReport/certificateRecordsById?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
