/**
 * 设备领用接口
 */
import request from '../index'
import type{ IlistQuery } from '@/views/device/receive/receive'
const prefix = '/equipmentApply'

/**
 * ----------------------------------设备领用申请----------------------------------
 */

// 列表
export function getReceiveApplyList(data: IlistQuery) {
  return request({
    url: `${prefix}/equipmentApplyList?limit=${data.limit}&offset=${data.offset}`,
    method: 'post',
    data,
  })
}

// 列表导出
export function exportReceiveApplyList(data: IlistQuery) {
  return request({
    url: `${prefix}/exportList`,
    method: 'post',
    responseType: 'blob',
    data,
  })
}

// 列表删除
export function delReceiveApplyList(data: { id: string; taskId: string }) {
  return request({
    url: `${prefix}/deleteEquipmentApply`,
    method: 'post',
    data,
  })
}

// 新建--点击保存
export function saveAddReceiveApplyList(data: { applyUnit: string; applyPerson: string; time: string ;applyDesc: string; applyType: string; equipmentList: { equipmentId: string }[] }) {
  return request({
    url: `${prefix}/addEquipmentApply`,
    method: 'post',
    data,
  })
}
// 新建--提交
export function submitReceiveApplyList(data: { formId: string; id: string }) {
  return request({
    url: `${prefix}/submitEquipmentApply`,
    method: 'post',
    data,
  })
}

// 编辑--保存
export function saveEditReceiveApplyList(data: { applyUnit: string; applyPerson: string; time: string ;applyDesc: string; applyType: string; equipmentList: { equipmentId: string }[] }) {
  return request({
    url: `${prefix}/updateEquipmentApply`,
    method: 'post',
    data,
  })
}

// 详情
export function getReceiveApplyListDetail(data: { id: string }) {
  return request({
    url: `${prefix}/equipmentApplyInfo`,
    method: 'post',
    data,
  })
}

// 领用-退领
export function updateProcessResult(data: { id: string; processResult: string }) {
  return request({
    url: `${prefix}/updateProcessResult`,
    method: 'post',
    data,
  })
}
