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

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

// 任务分发详情
export function getTaskDetail(data: { orderId: string; sampleId: string }) {
  return request({
    url: `${prefix}/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: `${prefix}/listExport`,
    method: 'post',
    responseType: 'blob',
    data,
  })
}

// 我的任务导出
export function exportMyTaskList(data: any) {
  return request({
    url: '/business/distribute/myExecutive/export',
    method: 'post',
    responseType: 'blob',
    data,
  })
}

// 实验室任务导出
export function exportLabTaskList(data: any) {
  return request({
    url: '/business/distribute/deptExecutive/export',
    method: 'post',
    responseType: 'blob',
    data,
  })
}

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

// 收发员任务分发
export function setMeasureProcess(data: { orderId: string; sampleId: string; measureProcessList: any[] }) {
  return request({
    url: `${prefix}/execute`,
    method: 'post',
    data,
  })
}
// 批量分发
export function batchExecute(data: any) {
  return request({
    url: `${prefix}/batch/execute`,
    method: 'post',
    data,
  })
}

// 分发员编辑实验室检测列表
export function setMeasureProcessByFfy(data: { orderId: string; sampleId: string; measureProcessList: any[] }) {
  return request({
    url: `${prefix}/updateList`,
    method: 'post',
    data,
  })
}

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

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

// 分配（分配给具体人员）
export function allocate(data: any) {
  return request({
    url: '/business/distribute/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 getMyMeasureList(data: any) {
  return request({
    url: `/business/distribute/myExecutive/list?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
// 我的任务-检测完成
export function myExecutiveDone(data: any) {
  return request({
    url: '/business/distribute/myExecutive/complete',
    method: 'post',
    data,
  })
}

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