import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseEqualMaterialInfoVO, BaseEqualMaterialInfoForm, BaseEqualMaterialInfoQuery } from '@/api/mes/baseEqualMaterialInfo/types';

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

export const listBaseEqualMaterialInfo = (query?: BaseEqualMaterialInfoQuery): AxiosPromise<BaseEqualMaterialInfoVO[]> => {
  return request({
    url: '/mes/baseEqualMaterialInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询等同物料信息详细
 * @param equalMaterialInfoId
 */
export const getBaseEqualMaterialInfo = (equalMaterialInfoId: string | number): AxiosPromise<BaseEqualMaterialInfoVO> => {
  return request({
    url: '/mes/baseEqualMaterialInfo/' + equalMaterialInfoId,
    method: 'get'
  });
};

/**
 * 新增等同物料信息
 * @param data
 */
export const addBaseEqualMaterialInfo = (data: BaseEqualMaterialInfoForm) => {
  return request({
    url: '/mes/baseEqualMaterialInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改等同物料信息
 * @param data
 */
export const updateBaseEqualMaterialInfo = (data: BaseEqualMaterialInfoForm) => {
  return request({
    url: '/mes/baseEqualMaterialInfo',
    method: 'put',
    data: data
  });
};

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


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