import http from '@/utils/http'
import type { EquipmentApprovalReq, EquipmentApprovalResp, EquipmentApprovalListReq } from './type'

/**
 * 设备审批管理API
 */
export const equipmentApprovalApi = {
  /**
   * 分页查询待审批的设备采购申请
   */
  getPendingApprovals: (params: EquipmentApprovalListReq) => {
    return http.get<ApiRes<PageRes<EquipmentApprovalResp>>>('/equipment/approval/pending', { params })
  },

  /**
   * 分页查询已审批的设备采购申请
   */
  getApprovedApprovals: (params: EquipmentApprovalListReq) => {
    return http.get<ApiRes<PageRes<EquipmentApprovalResp>>>('/equipment/approval/approved', { params })
  },

  /**
   * 审批通过
   */
  approve: (approvalId: string, data: EquipmentApprovalReq) => {
    return http.post<ApiRes<null>>(`/equipment/approval/${approvalId}/approve`, data)
  },

  /**
   * 审批拒绝
   */
  reject: (approvalId: string, data: EquipmentApprovalReq) => {
    return http.post<ApiRes<null>>(`/equipment/approval/${approvalId}/reject`, data)
  },

  /**
   * 获取审批详情
   */
  getApprovalDetail: (approvalId: string) => {
    return http.get<ApiRes<EquipmentApprovalResp>>(`/equipment/approval/${approvalId}`)
  },

  /**
   * 获取审批统计信息
   */
  getApprovalStats: () => {
    return http.get<ApiRes<unknown>>('/equipment/approval/stats')
  }
}
