import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseMaterialCategoryVO, BaseMaterialCategoryForm, BaseMaterialCategoryQuery } from '@/api/mes/baseMaterialCategory/types';

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

export const listBaseMaterialCategory = (query?: BaseMaterialCategoryQuery): AxiosPromise<BaseMaterialCategoryVO[]> => {
  return request({
    url: '/mes/baseMaterialCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料大类信息详细
 * @param materialCategoryId
 */
export const getBaseMaterialCategory = (materialCategoryId: string | number): AxiosPromise<BaseMaterialCategoryVO> => {
  return request({
    url: '/mes/baseMaterialCategory/' + materialCategoryId,
    method: 'get'
  });
};

/**
 * 新增物料大类信息
 * @param data
 */
export const addBaseMaterialCategory = (data: BaseMaterialCategoryForm) => {
  return request({
    url: '/mes/baseMaterialCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料大类信息
 * @param data
 */
export const updateBaseMaterialCategory = (data: BaseMaterialCategoryForm) => {
  return request({
    url: '/mes/baseMaterialCategory',
    method: 'put',
    data: data
  });
};

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


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