import request from '@/config/axios'

export interface DeviceBomVO {
  id?: number
  name: string
  code: string
  parentId: number
  deviceCategoryId: number
  deviceId: number
  status: number
  sort: number
  type: string
  createTime: Date
}

// 查询设备bom（精简/树)列表
export const getSimpleDeviceBomList = async (params: PageParam): Promise<DeviceBomVO[]> => {
  return await request.get({ url: '/pms/iot-device-bom/simple-list', params})
}

// 查询 设备Bom树 列表
export const getBomPage = async (params: PageParam) => {
  return await request.get({ url: '/pms/iot-device-bom/list', params })
}

// 查询Bom树节点详情
export const getBom = async (id: number) => {
  return await request.get({ url: '/rq/iot-bom/get?id=' + id })
}

// 新增Bom树节点
export const createBomNode = async (data: DeviceBomVO) => {
  return await request.post({ url: '/rq/iot-bom/create', data: data })
}

// 修改Bom树节点
export const updateBomNode = async (params: DeviceBomVO) => {
  return await request.put({ url: '/rq/iot-bom/update', data: params })
}

// 删除Bom树节点
export const deleteBomNode = async (id: number) => {
  return await request.delete({ url: '/rq/iot-bom/delete?id=' + id })
}
