import request from '@/config/axios'

// 维修工单对应物料 VO
export interface IotMaintainMaterialsVO {
  id: number // 主键
  maintainId: number // 维修工单id
  bomId: number // 维修项id
  bomNodeId: number // 保养工单明细设备BOM节点id
  materialId: number // 物料id
  materialCode: string // 物料编码
  materialName: string // 物料名称
  quantity: number // 消耗数量
  unitPrice: number // 单价(元)
  totalPrice: number // 总金额(元)
  totalInventoryQuantity: number // 总数量
  materialSource: string // 物料来源 (SAP库存 本地库存...)
  inventoryAddress: string // 库存地点
  sort: number // 排序
  status: number // 状态 0启用  1停用
  remark: string // 备注
}

// 维修工单对应物料 API
export const IotMaintainMaterialsApi = {
  // 查询维修工单对应物料分页
  getIotMaintainMaterialsPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-maintain-materials/page`, params })
  },

  // 查询维修工单对应物料详情
  getIotMaintainMaterials: async (id: number) => {
    return await request.get({ url: `/rq/iot-maintain-materials/get?id=` + id })
  },

  // 新增维修工单对应物料
  createIotMaintainMaterials: async (data: IotMaintainMaterialsVO) => {
    return await request.post({ url: `/rq/iot-maintain-materials/create`, data })
  },

  // 修改维修工单对应物料
  updateIotMaintainMaterials: async (data: IotMaintainMaterialsVO) => {
    return await request.put({ url: `/rq/iot-maintain-materials/update`, data })
  },

  // 删除维修工单对应物料
  deleteIotMaintainMaterials: async (id: number) => {
    return await request.delete({ url: `/rq/iot-maintain-materials/delete?id=` + id })
  },

  // 导出维修工单对应物料 Excel
  exportIotMaintainMaterials: async (params) => {
    return await request.download({ url: `/rq/iot-maintain-materials/export-excel`, params })
  },
}
