import request from '@/config/axios'

// 工单物料 VO
export interface IotMaintainMaterialVO {
  id: number // 主键
  code: string // 物料编码
  name: string // 物料名称
  unit: string // 单位
  price: number // 单价
  sourceType: string // 物料来源
  depleteCount: number // 消耗数量
  totalCount: number // 总库存数量
  sapCode: string // SAP系统中的物料唯一编号
  status: number // 状态 0启用  1停用
  remark: string // 备注
  materials:[]
}

// 工单物料 API
export const IotMaintainMaterialApi = {
  // 查询工单物料分页
  getIotMaintainMaterialPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-maintain-material/page`, params })
  },

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

  // 新增工单物料
  createIotMaintainMaterial: async (data: IotMaintainMaterialVO) => {
    return await request.post({ url: `/rq/iot-maintain-material/create`, data })
  },

  // 修改工单物料
  updateIotMaintainMaterial: async (data: IotMaintainMaterialVO) => {
    return await request.put({ url: `/rq/iot-maintain-material/update`, data })
  },

  // 删除工单物料
  deleteIotMaintainMaterial: async (id: number) => {
    return await request.delete({ url: `/rq/iot-maintain-material/delete?id=` + id })
  },

  // 导出工单物料 Excel
  exportIotMaintainMaterial: async (params) => {
    return await request.download({ url: `/rq/iot-maintain-material/export-excel`, params })
  },
  getMaterialsByDeviceId: async (params) => {
    return await request.get({ url: `/rq/iot-maintain-material/choose`, params })
  },
}
