import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseMaterialInfoVO, BaseMaterialInfoForm, BaseMaterialInfoQuery } from '@/api/mes/baseMaterialInfo/types';
import {BaseMaterialTypeQuery, BaseMaterialTypeVO} from "@/api/mes/baseMaterialType/types";

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

export const listBaseMaterialInfo = (query?: BaseMaterialInfoQuery): AxiosPromise<BaseMaterialInfoVO[]> => {
  return request({
    url: '/mes/baseMaterialInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料信息详细
 * @param materialId
 */
export const getBaseMaterialInfo = (materialId: string | number): AxiosPromise<BaseMaterialInfoVO> => {
  return request({
    url: '/mes/baseMaterialInfo/' + materialId,
    method: 'get'
  });
};

/**
 * 新增物料信息
 * @param data
 */
export const addBaseMaterialInfo = (data: BaseMaterialInfoForm) => {
  return request({
    url: '/mes/baseMaterialInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料信息
 * @param data
 */
export const updateBaseMaterialInfo = (data: BaseMaterialInfoForm) => {
  return request({
    url: '/mes/baseMaterialInfo',
    method: 'put',
    data: data
  });
};

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


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


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

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