import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InventoryDetailsForm, InventoryDetailsQuery, InventoryDetailsVO } from '@/api/wms/inventoryDetails/types';

/**
 * 查询库存明细列表
 * @param query
 * @returns {*}
 */

export const listInventoryDetails = (query?: InventoryDetailsQuery): AxiosPromise<InventoryDetailsVO[]> => {
  return request({
    url: '/wms/inventoryDetails/list',
    method: 'get',
    params: query
  });
};
export const listCountQuery = (query?: InventoryDetailsQuery): AxiosPromise<InventoryDetailsVO[]> => {
  return request({
    url: '/wms/inventoryDetails/listCount',
    method: 'get',
    params: query
  });
};

/**
 * 查询库存明细详细
 * @param inventoryDetailsId
 */
export const getInventoryDetails = (inventoryDetailsId: string | number): AxiosPromise<InventoryDetailsVO> => {
  return request({
    url: '/wms/inventoryDetails/' + inventoryDetailsId,
    method: 'get'
  });
};

/**
 * 新增库存明细
 * @param data
 */
export const addInventoryDetails = (data: InventoryDetailsForm) => {
  return request({
    url: '/wms/inventoryDetails',
    method: 'post',
    data: data
  });
};

/**
 * 修改库存明细
 * @param data
 */
export const updateInventoryDetails = (data: InventoryDetailsForm) => {
  return request({
    url: '/wms/inventoryDetails',
    method: 'put',
    data: data
  });
};

/**
 * 删除库存明细
 * @param inventoryDetailsId
 */
export const delInventoryDetails = (inventoryDetailsId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/inventoryDetails/' + inventoryDetailsId,
    method: 'delete'
  });
};

/**
 * 下拉框查询库存明细列表
 * @param query
 * @returns {*}
 */
export function getWmsInventoryDetailsList(query) {
  return request({
    url: '/wms/inventoryDetails/getWmsInventoryDetailsList',
    method: 'get',
    params: query
  });
}

export function getWmsInventoryDetailbyProductId(productId: number) {
  return request({
    url: '/wms/inventoryDetails/getWmsInventoryDetailbyProductId',
    method: 'get',
    params: {
      productId: productId
    }
  });
}
