import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialBomVersionVO, MaterialBomVersionForm, MaterialBomVersionQuery } from '@/api/mes/materialBomVersion/types';

/**
 * 查询物料bom版本列表
 * @param query
 * @returns {*}
 */

export const listMaterialBomVersion = (query?: MaterialBomVersionQuery): AxiosPromise<MaterialBomVersionVO[]> => {
  return request({
    url: '/mes/materialBomVersion/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料bom版本详细
 * @param materialBomVersion
 */
export const getMaterialBomVersion = (materialBomVersion: string | number): AxiosPromise<MaterialBomVersionVO> => {
  return request({
    url: '/mes/materialBomVersion/' + materialBomVersion,
    method: 'get'
  });
};

/**
 * 新增物料bom版本
 * @param data
 */
export const addMaterialBomVersion = (data: MaterialBomVersionForm) => {
  return request({
    url: '/mes/materialBomVersion',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料bom版本
 * @param data
 */
export const updateMaterialBomVersion = (data: MaterialBomVersionForm) => {
  return request({
    url: '/mes/materialBomVersion',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料bom版本
 * @param materialBomVersion
 */
export const delMaterialBomVersion = (materialBomVersion: string | number | Array<string | number>) => {
  return request({
    url: '/mes/materialBomVersion/' + materialBomVersion,
    method: 'delete'
  });
};


/**
 * 下拉框查询物料bom版本列表
 * @param query
 * @returns {*}
 */
export function getProdMaterialBomVersionList (query) {
    return request({
        url: '/mes/materialBomVersion/getProdMaterialBomVersionList',
        method: 'get',
        params: query
    });
};
