/**
 * 任务分发,实验室检测
*/
import request from '../index'
import type { 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 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: `${prefix}/schedule/task/setSchedule`,
    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: ITaskQuery) {
  return request({
    url: `/business/labExecutive/myExecutive/list?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

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