import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseMaterialInfoVO, BaseMaterialInfoForm, BaseMaterialInfoQuery } from '@/api/wms/baseMaterialInfo/types';

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

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

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

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

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

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


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