import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InventoryVO, InventoryForm, InventoryQuery } from '@/api/wms/inventory/types';

/**
 * 查询物料库存列表
 * @param query
 * @returns {*}
 */

export const listInventory = (query?: InventoryQuery): AxiosPromise<InventoryVO[]> => {
  return request({
    url: '/wms/inventory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料库存告警列表
 * @param query
 * @returns {*}
 */

export const listInventoryAlarm = (query?: InventoryQuery): AxiosPromise<InventoryVO[]> => {
  return request({
    url: '/wms/inventory/listInventoryAlarm',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料库存详细
 * @param inventoryId
 */
export const getInventory = (inventoryId: string | number): AxiosPromise<InventoryVO> => {
  return request({
    url: '/wms/inventory/' + inventoryId,
    method: 'get'
  });
};

/**
 * 新增物料库存
 * @param data
 */
export const addInventory = (data: InventoryForm) => {
  return request({
    url: '/wms/inventory',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料库存
 * @param data
 */
export const updateInventory = (data: InventoryForm) => {
  return request({
    url: '/wms/inventory',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料库存
 * @param inventoryId
 */
export const delInventory = (inventoryId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/inventory/' + inventoryId,
    method: 'delete'
  });
};

export const getMaterialInfoList = (query) => {
  return request({
    url: '/wms/inventory/getMaterialInfoList',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料库存告警列表
 * @param query
 * @returns {*}
 */

export const getListInventoryAlarm = (query?: InventoryQuery): AxiosPromise<InventoryVO[]> => {
  return request({
    url: '/wms/inventory/getListInventoryAlarm',
    method: 'get',
    params: query
  });
};
