import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialsInventoryForm, MaterialsInventoryQuery, MaterialsInventoryVO } from '@/api/materials/materialsInventory/types';

/**
 * 查询材料出/入库列表
 * @param query
 * @returns {*}
 */

export const listMaterialsInventory = (query?: MaterialsInventoryQuery): AxiosPromise<MaterialsInventoryVO[]> => {
  return request({
    url: '/materials/materialsInventory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询材料出/入库详细
 * @param id
 */
export const getMaterialsInventory = (id: string | number): AxiosPromise<MaterialsInventoryVO> => {
  return request({
    url: '/materials/materialsInventory/' + id,
    method: 'get'
  });
};

/**
 * 新增材料出/入库
 * @param data
 */
export const addMaterialsInventory = (data: MaterialsInventoryForm): AxiosPromise<string | number> => {
  return request({
    url: '/materials/materialsInventory',
    method: 'post',
    data: data
  });
};

/**
 * 修改材料出/入库
 * @param data
 */
export const updateMaterialsInventory = (data: MaterialsInventoryForm) => {
  return request({
    url: '/materials/materialsInventory',
    method: 'put',
    data: data
  });
};

/**
 * 删除材料出/入库
 * @param id
 */
export const delMaterialsInventory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/materials/materialsInventory/' + id,
    method: 'delete'
  });
};
