import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseMaterialTypeVO, BaseMaterialTypeForm, BaseMaterialTypeQuery } from '@/api/mes/baseMaterialType/types';

/**
 * 查询物料类型信息列表
 * @param query
 * @returns {*}
 */

export const listBaseMaterialType = (query?: BaseMaterialTypeQuery): AxiosPromise<BaseMaterialTypeVO[]> => {
  return request({
    url: '/mes/baseMaterialType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料类型信息详细
 * @param matrialTypeId
 */
export const getBaseMaterialType = (matrialTypeId: string | number): AxiosPromise<BaseMaterialTypeVO> => {
  return request({
    url: '/mes/baseMaterialType/' + matrialTypeId,
    method: 'get'
  });
};

/**
 * 新增物料类型信息
 * @param data
 */
export const addBaseMaterialType = (data: BaseMaterialTypeForm) => {
  return request({
    url: '/mes/baseMaterialType',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料类型信息
 * @param data
 */
export const updateBaseMaterialType = (data: BaseMaterialTypeForm) => {
  return request({
    url: '/mes/baseMaterialType',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料类型信息
 * @param matrialTypeId
 */
export const delBaseMaterialType = (matrialTypeId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseMaterialType/' + matrialTypeId,
    method: 'delete'
  });
};


/**
 * 下拉框查询物料类型信息列表
 * @param query
 * @returns {*}
 */
export function getBaseMaterialTypeList (query) {
    return request({
        url: '/mes/baseMaterialType/getBaseMaterialTypeList',
        method: 'get',
        params: query
    });
};
