// 设备借用相关接口api
import request from '../index'
import type{ IlistQuery } from '@/views/device/borrow/borrow'

// 设备借用申请列表
export function getBorrowApplyList(data: IlistQuery) {
  return request({
    url: `/equipmentApply/equipmentApplyList?limit=${data.limit}&offset=${data.offset}`,
    method: 'post',
    data,
  })
}
// 设备借用申请新建
export function addApply(data: object) {
  return request({
    url: '/equipmentApply/addEquipmentApply',
    method: 'post',
    data,
  })
}

// 设备借用取消审批
export function cancelApproval(data: { processInstanceId?: string; comments: string }) {
  return request({
    url: '/approval/operate/revoke',
    method: 'post',
    data,
  })
}

// 设备借用申请详情
export function getBorrowApplyListDetail(data: object) {
  return request({
    url: '/equipmentApply/equipmentApplyInfo',
    method: 'post',
    data,
  })
}

// 设备借用申请编辑
export function editApply(data: object) {
  return request({
    url: '/equipmentApply/updateEquipmentApply',
    method: 'post',
    data,
  })
}

// 设备借用驳回后编辑
export function failUpdate(data: object) {
  return request({
    url: '/equipmentApply/failUpdate',
    method: 'post',
    data,
  })
}
// 设备借用申请删除
export function deleteApply(data: object) {
  return request({
    url: '/equipmentApply/deleteEquipmentApply',
    method: 'post',
    data,
  })
}

// 状态管理提交
export function submitApply(data: object) {
  return request({
    url: '/meter/stateManage/submitStandardEquipmentApply',
    method: 'post',
    data,
  })
}

// 设备借用设备-借用
export function borrowApply(data: object) {
  return request({
    url: '/equipmentApply/borrowEquipmentApply',
    method: 'post',
    data,
  })
}

// 设备借用-归还
export function returnApply(data: object) {
  return request({
    url: '/equipmentApply/returnEquipmentApply',
    method: 'post',
    data,
  })
}
// 设备借用申请导出
export function exportApply(data: IlistQuery) {
  return request({
    url: '/equipmentApply/exportList',
    method: 'post',
    data,
    responseType: 'blob',
  })
}
