import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InventoryLedgerVO, InventoryLedgerForm, InventoryLedgerQuery } from '@/api/wms/inventoryLedger/types';

/**
 * 查询库存变动台账列表
 * @param query
 * @returns {*}
 */

export const listInventoryLedger = (query?: InventoryLedgerQuery): AxiosPromise<InventoryLedgerVO[]> => {
  return request({
    url: '/wms/inventoryLedger/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询库存变动台账详细
 * @param ledgerId
 */
export const getInventoryLedger = (ledgerId: string | number): AxiosPromise<InventoryLedgerVO> => {
  return request({
    url: '/wms/inventoryLedger/' + ledgerId,
    method: 'get'
  });
};

/**
 * 新增库存变动台账
 * @param data
 */
export const addInventoryLedger = (data: InventoryLedgerForm) => {
  return request({
    url: '/wms/inventoryLedger',
    method: 'post',
    data: data
  });
};

/**
 * 修改库存变动台账
 * @param data
 */
export const updateInventoryLedger = (data: InventoryLedgerForm) => {
  return request({
    url: '/wms/inventoryLedger',
    method: 'put',
    data: data
  });
};

/**
 * 删除库存变动台账
 * @param ledgerId
 */
export const delInventoryLedger = (ledgerId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/inventoryLedger/' + ledgerId,
    method: 'delete'
  });
};

/**
 * 下拉框查询库存变动台账列表
 * @param query
 * @returns {*}
 */
export function getWmsInventoryLedgerList (query) {
    return request({
        url: '/wms/inventoryLedger/getWmsInventoryLedgerList',
        method: 'get',
        params: query
    });
};
