import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsBaseDeviceBomVO, DmsBaseDeviceBomForm, DmsBaseDeviceBomQuery } from '@/api/dms/dmsBaseDeviceBom/types';

/**
 * 查询设备BOM信息列表
 * @param query
 * @returns {*}
 */

export const listDmsBaseDeviceBom = (query?: DmsBaseDeviceBomQuery): AxiosPromise<DmsBaseDeviceBomVO[]> => {
  return request({
    url: '/dms/dmsBaseDeviceBom/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备BOM信息详细
 * @param deviceBomId
 */
export const getDmsBaseDeviceBom = (deviceBomId: string | number): AxiosPromise<DmsBaseDeviceBomVO> => {
  return request({
    url: '/dms/dmsBaseDeviceBom/' + deviceBomId,
    method: 'get'
  });
};

/**
 * 新增设备BOM信息
 * @param data
 */
export const addDmsBaseDeviceBom = (data: DmsBaseDeviceBomForm) => {
  return request({
    url: '/dms/dmsBaseDeviceBom',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备BOM信息
 * @param data
 */
export const updateDmsBaseDeviceBom = (data: DmsBaseDeviceBomForm) => {
  return request({
    url: '/dms/dmsBaseDeviceBom',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备BOM信息
 * @param deviceBomId
 */
export const delDmsBaseDeviceBom = (deviceBomId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsBaseDeviceBom/' + deviceBomId,
    method: 'delete'
  });
};


/**
 * 下拉框查询设备BOM信息列表
 * @param query
 * @returns {*}
 */
export function getDmsBaseDeviceBomList (query) {
    return request({
        url: '/dms/dmsBaseDeviceBom/getDmsBaseDeviceBomList',
        method: 'get',
        params: query
    });
};

//连表查询 通过设备类型查询bom信息
export function selectBomByDeviceType(data) {
  return request({
    url: '/dms/dmsBaseDeviceBom/selectBomByDeviceType',
    method: 'post',
    data: data
  })
};
