/**
 * 测试、校准或检定合格分包方名录
 */
import request from '../../index'
import type { IListQuery } from '@/views/business/subpackage/directories/directories-interface'
const prefix = 'business'

// 列表查询
export function getDirectoriesList(data: IListQuery) {
  return request({
    url: `${prefix}/outsource/outsourcer/approval/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
// 导出
export function exportDirectoriesList(data: IListQuery) {
  return request({
    url: `${prefix}/outsource/outsourcer/listExport`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

// 新建(保存至草稿箱)
export function addDirectories(data: object) {
  return request({
    url: `${prefix}/outsource/outsourcer/save`,
    method: 'post',
    data,
  })
}

// 编辑--草稿箱
export function updateDirectories(data: object) {
  return request({
    url: `${prefix}/outsource/outsourcer/draftUpdate`,
    method: 'post',
    data,
  })
}
// 编辑--未通过、已取消
export function failUpdateDirectories(data: object) {
  return request({
    url: `${prefix}/outsource/outsourcer/failUpdate`,
    method: 'post',
    data,
  })
}

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

// 提交
export function submit(data: { id: string; formId: string; processId?: string }) {
  return request({
    url: `${prefix}/outsource/outsourcer/submit`,
    method: 'post',
    data,
  })
}

// 删除--草稿箱
export function draftDelete(data: { id: string }) {
  return request({
    url: `${prefix}/outsource/outsourcer/draftDelete`,
    method: 'post',
    data,
  })
}

// 审批删除--已取消、全部
export function approvalDelete(data: { id: string; taskId: string }) {
  return request({
    url: `${prefix}/outsource/outsourcer/approval/delete`,
    method: 'post',
    data,
  })
}

// 取消
export function cancelApproval(data: { processInstanceId?: string; comments: string; id: string }) {
  return request({
    url: `${prefix}/outsource/outsourcer/approval/revoke`,
    method: 'post',
    data,
  })
}

// 拒绝
export function refuseApproval(data: { id: string; taskId: string; comments: string }) {
  return request({
    url: `${prefix}/outsource/outsourcer/approval/refuse`,
    method: 'post',
    data,
  })
}

// ----------------------------------------分包方人员-----------------------------------------
// 删除
export function deletePerson(data: { ids: string[] }) {
  return request({
    url: `${prefix}/outsource/outsourcer/person/delete`,
    method: 'post',
    data,
  })
}

// 新增
export function addPerson(data: any) {
  return request({
    url: `${prefix}/outsource/outsourcer/person/add`,
    method: 'post',
    data,
  })
}

// 列表
export function getPersonList(data: { id: string; offset: number; limit: number }) {
  return request({
    url: `${prefix}/outsource/outsourcer/person/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// ---------------------------------------业务能力-------------------------------------------

// 删除
export function deleteAbility(data: { ids: string[] }) {
  return request({
    url: `${prefix}/outsource/outsourcer/ability/delete`,
    method: 'post',
    data,
  })
}

// 新增
export function addAbility(data: any) {
  return request({
    url: `${prefix}/outsource/outsourcer/ability/add`,
    method: 'post',
    data,
  })
}

// 列表
export function getAbilityList(data: { id: string; offset: number; limit: number }) {
  return request({
    url: `${prefix}/outsource/outsourcer/ability/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
