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

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

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

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

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

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

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


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

