import request from '@/config/axios'

export interface CommonBomMaterialVO {
  id: number
  name: string
  code: string
  deviceCategoryId: number
  bomNodeId: number
  materialId: number
  quantity: number
  status: number
  remark: string
  createTime: Date
}


export const CommonBomMaterialApi = {
  getCommonBomMaterialPage: async (params: PageParam) => {
    return await request.get({ url: '/pms/iot-common-bom-material/page', params })
  },
  getCommonBomMaterial: async (id: number) => {
    return await request.get({ url: '/pms/iot-common-bom-material/get?id=' + id })
  },
  createCommonBomMaterial: async (data: CommonBomMaterialVO) => {
    return await request.post({ url: '/pms/iot-common-bom-material/create', data })
  },
  addMaterials: async (data: any) => {
    return await request.post({ url: '/pms/iot-common-bom-material/addMaterials', data })
  },
  updateCommonBomMaterial: async (data: CommonBomMaterialVO) => {
    return await request.put({ url: '/pms/iot-common-bom-material/update', data })
  },
  deleteCommonBomMaterial: async (id: number) => {
    return await request.delete({ url: '/pms/iot-common-bom-material/delete?id=' + id })
  },
  deleteBomMaterial: async (bomNodeId: number, code: string) => {
    return await request.delete({ url: '/pms/iot-common-bom-material/deleteBomMaterial?bomNodeId=' + bomNodeId + '&code=' + code })
  }
}
