/**
 * 设备台账管理接口
 */
import request from '../../index'
import type { IListQuery } from '@/views/equipement/info/book/book-interface'
const prefix = 'equipment'

// 列表查询
export function getEquipmentList(data: IListQuery) {
  return request({
    url: `${prefix}/approval/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

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

// 编辑--草稿箱
export function updateEquipment(data: object) {
  return request({
    url: `${prefix}/draftUpdate`,
    method: 'post',
    data,
  })
}
// 编辑
export function failUpdateEquipment(data: object) {
  return request({
    url: `${prefix}/failUpdate`,
    method: 'post',
    data,
  })
}

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

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

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

// 设备审批删除
export function approvalDelete(data: { id: string; taskId: string }) {
  return request({
    url: `${prefix}/approval/delete`,
    method: 'post',
    data,
  })
}

// 设备流转日志
export function getEquipmentFlowLog(data: { equipmentNo: string }) {
  return request({
    url: `${prefix}/circulationLog/listPage`,
    method: 'post',
    data,
  })
}

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

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

